Configure Lambda durable functions
Durable execution settings control how long your Lambda function can run and how long the service retains execution history. Configure these settings to enable durable execution for your function.
Enable durable execution
Configure the DurableConfig object when creating your function to set execution timeout and history retention. You can only enable durable execution when creating a function. You cannot enable it on existing functions.
Configuration parameters:
ExecutionTimeout– The maximum time in seconds that a durable execution can run before Lambda stops the execution. This timeout applies to the entire durable execution, not individual function invocations. Valid range: 1–31622400.RetentionPeriodInDays– The number of days to retain execution history after a durable execution completes. After this period, execution history is no longer available through theGetDurableExecutionHistoryAPI. Valid range: 1–90.
For the full API reference, see DurableConfig in the Lambda API Reference.
Configuration best practices
Follow these best practices when configuring durable functions for production use:
-
Set appropriate execution timeouts – Configure
ExecutionTimeoutbased on your workflow's maximum expected duration. Do not set unnecessarily long timeouts as they affect cost and resource allocation. -
Balance retention with storage costs – Set
RetentionPeriodInDaysbased on your debugging and audit requirements. Longer retention periods increase storage costs. -
Monitor state size – Large state objects increase storage costs and can impact performance. Keep state minimal and use external storage for large data.
-
Configure appropriate logging – Enable detailed logging for troubleshooting long-running workflows, but consider the impact on log volume and costs.
Production configuration example:
{ "ExecutionTimeout": 86400, "RetentionPeriodInDays": 7 }
This example sets a 24-hour (86,400 seconds) execution timeout with a 7-day retention period, which balances debugging visibility with storage costs for most production workloads.