DEV Community

Cover image for Lambda now runs for 30 minutes: the traps behind the bigger number
Sascha Mirow-Stanitzok
Sascha Mirow-Stanitzok

Posted on Originally published at sascha-ms.de

Lambda now runs for 30 minutes: the traps behind the bigger number

You know the job: it usually finishes in eight minutes, but once in a while it needs twenty. Until now, that outlier forced a redesign, because Lambda stopped at 15 minutes. Since November 19, 2026, on-demand Event Functions can run for up to 30 minutes. That sounds like a simple config change, and sometimes it is. Often, though, it is the beginning of new problems: duplicate processing, callers that gave up long ago, and retries that quietly double your bill.

I went through what really changes in Lambda 30 minute timeout: what to check now. Here are the points I would check before typing 1,800 into any configuration.

What the new limit covers

The 30 minutes apply to synchronous and asynchronous invocations as well as event source mappings such as SQS, in all commercial Regions and without a surcharge. You still set the value in seconds, from 1 to 1,800, and the default stays at 3 seconds. On Lambda Managed Instances, asynchronous invocations and most event source mappings can even run up to 90 minutes. Durable functions and Step Functions Standard workflows benefit too, since a single function execution inside them may now take longer.

The caller decides how long anyone waits

This is the part I consider most important. Your function may now run for half an hour, but its caller probably will not wait that long:

  • API Gateway REST APIs stop waiting after 29 seconds by default, HTTP APIs after 30 seconds at most
  • Cognito user pool triggers wait only 5 seconds
  • Step Functions and function URLs wait until the function returns

Behind API Gateway, the client gets an error while your function keeps running at your expense. For long work behind an API, the job pattern with a 202 response and a status endpoint stays the right answer. The good news: the worker behind it can now use the full 30 minutes.

The sneakiest trap is your own SDK client. The AWS CLI and SDKs retry automatically on a client timeout, and boto3's default read timeout is 60 seconds. A Python script that calls a 20-minute function synchronously with defaults can start several parallel runs and still end with an error. If you really need to wait, configure the client deliberately:

const lambda = new LambdaClient({
  maxAttempts: 1, // no silent second run
  requestHandler: new NodeHttpHandler({
    requestTimeout: 31 * 60 * 1000, // longer than the function timeout
    httpsAgent: new Agent({ keepAlive: true }),
  }),
});
Enter fullscreen mode Exit fullscreen mode

SQS needs the queue changed first

For SQS-triggered functions, order matters. Lambda checks that the function timeout is not greater than the queue's visibility timeout, and AWS recommends at least six times the function timeout. For 1,800 seconds that means three hours. On an existing setup, deploy the new visibility timeout first, then raise the function timeout.

In my example, a fictional photo book print shop renders albums page by page. A 1,200-page wedding album does not fit into one run even with 30 minutes. So the handler watches context.getRemainingTimeInMillis() before every page. When the remaining time drops below a safety margin, it saves a checkpoint in DynamoDB, sends a continuation message to the queue and exits cleanly instead of being killed mid-page. A cap on continuations and a dead-letter queue prevent an endless loop.

Do the math before raising the limit

A 2,048 MB function running 30 minutes costs roughly USD 0.06 per run on x86. That is cheap until runs multiply: asynchronous invocations retry twice on errors by default, so a function that times out can cost three times as much without delivering anything. Set retries deliberately and watch Duration next to timeouts.

My honest view: this update removes a limit that pushed many teams into architecture nobody wanted. But a function that hit 14 minutes often points to a slow dependency or missing pagination. Thirty minutes hides the symptom, not the cause. I would raise the timeout only for functions whose runtime I have measured. For work that can take hours or waits for approvals, durable functions, Step Functions Standard or containers remain the better fit.

What the full article covers

  • Complete serverless.yml and an AWS CDK variant, including the schema and cdk synth warnings you will hit at 1,800 seconds
  • The full checkpoint-and-continuation handler with DynamoDB, plus tests with a fake clock
  • Client settings for TypeScript, Python and the AWS CLI for long synchronous calls
  • A decision guide between Lambda, Managed Instances, durable functions, Step Functions and containers, plus common mistakes and an FAQ

All details and the runnable code are in the original article: Lambda 30 minute timeout: what to check now

๐Ÿ“– This is the condensed version. The full article on sascha-ms.de goes deeper โ€“ with all code samples, diagrams and a short knowledge check.


๐Ÿ‘‰ Next step: Curious what your own Lambda functions cost? Try my Lambda cost calculator โ€“ it runs right in your browser.

๐Ÿ“ฌ Stay updated: New articles on serverless, AI and leading tech teams via RSS, browser push or the weekly newsletter (in German).

Originally published on sascha-ms.de. More articles on serverless, AI in everyday development and leading tech teams: sascha-ms.de/en

Top comments (0)