Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

256
Visualizações
Running Spring Boot on Amazon Lambda

I am trying to deploy a Spring Boot application on Amazon Lambda. I noticed that if the handler is called in quick succession - spring tries to reload itself, re-setup the datsources, reload beans etc

Is there anyway to tell Spring Boot not to reinitialize itself if the main method has already been called?

Thanks Damien

about 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

As far as I know, a Amazon Lambda is a stateless function, that is instantiated for every request.

If you call the Lambda many times, it is quite normal, that you see a Spring Boot initialization for every request.

If the requests come slowly, its possible that AWS is reusing the same Lambda again, so only one Spring initialization is done.

If the request come fast, or in parallel, AWS will launch more instances of Lambdas to scale dynamically. This explains what you are facing.

I think, using a whole Spring application as an AWS Lambda is not the right approach. A Lambda should be a stateless function, that can be instantiated quickly.

You might try to make your spring app as small as possible, to decrease load time and save resources, as explained in this tutorial.

about 4 years ago · Santiago Trujillo Relatório

0

I came across this searching for an answer and agree that Spring is typically way too slow to startup for Lambda.

I think Spring Cloud has solved this problem now with Spring Cloud Function:

This project provides an adapter layer for a Spring Cloud Function application onto AWS Lambda. You can write an app with a single @Bean of type Function, Consumer or Supplier and it will be deployable in AWS

https://github.com/spring-cloud/spring-cloud-function

UPDATE: I've been working with Spring Cloud Function on AWS lambda a little more now. For most of my functions, the startup time is 4-5 seconds which isn't fantastic, but at the time of writing it is dirt cheap (free for the first millions requests/ $0.20 per million thereafter) and a strategy to prevent slow startups is to prevent the function(s) from ever shutting down (a.k.a. "Keeping them warm") by setting up a CloudWatch rule to constantly kickoff the function and keep it alive.

about 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda