Skip to content
ES EN
Theme: automatic

How to Increase Your Lambda Timeout to 30 Minutes Without Breaking Everything Around It

A practical guide to extending a Lambda function from 15 to 30 minutes: calculating concurrency, adjusting queues and mappings, and avoiding blind spots.

Software engineering

AWS has doubled the maximum timeout for on-demand Lambda functions: from 15 to 30 minutes, in all commercial regions, without opt-in and at the usual price. They announced it on their compute blog, and the previous limit had been intact for eight years, since 2018.

Changing the value is trivial; the difficult part is what happens around it. In this guide, we review the order we would follow to intelligently increase the timeout, based on InfoQ's coverage and a practitioner's tests.

What you need

You need an event-driven Lambda function (synchronous or asynchronous invocation, or via event source mapping), access to the AWS CLI, and permissions to modify the function's configuration and its sources. It's also helpful to have the duration and concurrency metrics from the last few days on hand.

Keep in mind what doesn't change: Web Functions remain at 15 minutes, and Amazon MQ, DocumentDB, and Kafka mappings created before November 19th remain at 14 minutes, so they need to be recreated.

Conceptual diagram of a serverless function connected to a message queue and an event stream
The function is just one piece: queues, streams, and networks also have their own limits.

Steps to increase the timeout

  1. Verify that you actually need it: if the code is slow behind an API, 30 minutes is not the solution. Cases that do fit according to AWS: AI agents chaining calls, transcoding, Monte Carlo simulations, or reports.
  2. Calculate concurrency: requests per second multiplied by the average duration in seconds. With 1 request per second and 30 minutes per execution, you need 1,800 concurrent executions, twice as many as with 15.
  3. Adjust the source queue: in SQS, the visibility timeout must be at least six times the function's timeout, i.e., three hours for 30 minutes.
  4. Review the mappings: Kinesis and DynamoDB Streams read one batch per shard at a time, and Amazon MQ, DocumentDB, and Kafka mappings prior to November 19th must be recreated.
  5. Apply the change to the function and verify that validation does not fail (the maximum is 1,800 seconds).
  6. Monitor the cost per invocation and failure handling before moving batch jobs.
aws lambda update-function-configuration \
  --function-name my-demo-function \
  --timeout 1800

If you exceed 1,800 seconds, Lambda rejects the value with a validation error. That's the easy part of the change.

Limits that remain at 15 (or less)

Wibo van der Sluis tested the SQS rule in eu-west-1. He set a function to 1,800 seconds behind a 90-minute queue, then lowered the queue to 60 seconds: both changes were accepted with the mapping active, but a new mapping from that queue was rejected. The check exists, but only upon creation. Additionally, upon creation, it compared the queue to the function's timeout, not six times its value, so you have to enforce that ratio yourself.

Other blind spots: a NAT gateway still cuts inactive connections at 350 seconds, the Init phase retains its 10-second limit, and an asynchronous function that expires three times will have consumed 90 minutes before the event reaches the dead-letter queue.

Tip A 30-minute job is billed for the full duration at the configured memory. Make the handler idempotent and configure a dead-letter queue: a failure mid-execution can leave partial work. For multi-step flows with state and clear retries, Step Functions with Fargate or ECS remains, according to several practitioners, the cleanest option.

For context, the competition was already ahead: Cloud Run supports 60 minutes per request and Azure Functions in Flex Consumption and Premium plans imposes no maximum. AWS has not said whether the Lambda limit will move again.

Original source: infoq.com

Article generated with AI.larebelion

Kernel

· Head of Technology · Spain

«More execution time doesn't fix slow code: it just makes it more expensive and shifts the problem to the queue.»

Comments (0)

No comments yet. You can be the first.

Write a comment