Search code examples
amazon-web-servicesaws-lambdadropwizardserverless

Does Lambda shutdown the entire container when the traffic is zero?


It is said that lambda shutdown the container when there is no traffic and when first request came after long time, there is a cold start problem. Is that right? Eg. If I am running a drop wizard application on AWS lambda, will the server gets shutdown if no traffic is coming and it will again starts the server on first request? Is that correct?

Or it does not shutdown the server running in the container but does something else? Please explain?


Solution

  • Yes that is correct, once a lambda function does not receive any traffic for a period of time (in my experience approximately 15 mins), the container is destroyed and the next request will result in a new container being started (known as a cold-start).

    One thing to note however, is that lambda containers can be shut down at any time between requests, so even if you have constant traffic to the lambda, you may still experience the occasional cold-start.

    Additionally, each lambda container will only process a single request at a time, so if you have one lambda container which is "warm" and two requests come in simultaneously, one request will be processed by the pre-warmed lambda, and the other will encounter a cold-start.