Question
Can the execution timeout limit for Twilio Functions be raised beyond 10 seconds (the current limit)?
Product
Twilio Functions/Serverless
Environment
Twilio Console, legacy Twilio Console
Answer
No, the maximum execution timeout for a Twilio Function is 10 seconds, and is a hard, non-configurable platform limit. Due to this restriction, the limit cannot be increased for individual functions or accounts.
If your function takes longer than 10 seconds to complete its execution, the runtime will time out automatically and return an 'application runtime timed out' error.
To prevent timeout errors, consider implementing the following strategy within your application:
Invoke the Callback Promptly: Ensure your code always triggers the
callback()method as soon as processing is complete. Forgetting to invoke the callback will force the Function to continue running until it hits the hard 10-second limit.Optimize function execution: Reduce latency by optimizing external queries, external API requests, and synchronous operations.
Implement asynchronous processing: Offload heavy computations or long-running tasks to external queue systems or worker services rather than processing them synchronously within the function.
Modularize architecture: Break complex logic down into smaller, lightweight functions that execute quickly.