Skip to content

AWS Lambda Now Supports 15 Minute Timelimit

What more can I say?

AWS Announced that the time limit for AWS Lambda has been increased to 15 minutes. When first released, the time limit was 3 minutes, then it was increased to 5 minutes, and now 15 minutes.

Now it’s even more feasible to run longer running batch jobs for data processing.  If 15 minutes is not long enough, it’s even possible to create recursive AWS Lambda functions.  Here is a high-level overview of how you do that:

By using context.getRemainingTimeInMillis() you can determine what time your function is invoked.  Using the context object you can also find out how much time is left for the current process.  The key here is you  must be able to split up your job into a few different sub-jobs (within the same lambda function); this is pretty much the norm for well-written code anyway.  As each task is complete, then use ontext.getRemainingTimeInMillis() to see how much overall time is left before the process terminates.  If it’s not safe to assume there is enough time to complete the next task (be conservative here) then recall the same function and pass a parameter to designate where you left off last time.

For a performance boost, you can also use local state to store lookup data, and if it’s been wiped, then just recreate it.

Together with the new timeout increase, a lot of opportunities are available to continue to push “Serverless Architecture” at it’s finest.

Written for ServerlessArchitecture.com
Written by Jeff Mangan

Leave a Reply