Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

171
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda