Skip to content

Commit

Permalink
Increase lambda client read timeout to 15 minutes (#1065)
Browse files Browse the repository at this point in the history
As of 2018, Lambda functions [can be configured][1] to run for up to 15
minutes per execution, but the configuration for the Zappa CLI's Lambda
client had its timeout set to 5 minutes. This meant that the Lambda
client would time out waiting for a response from a long-running
invocation (e.g. a Django management command that runs for more than 5
minutes) while the actual function could continue to execute for up to
15 minutes, depending on its configuration.

I believe the comment in the README regarding the 30-second API gateway
timeout's effect on long-running management command invocations is
incorrect or misleading. Django management commands invoked via `zappa
manage` execute the Lambda function directly using a boto3 Lambda client
(in the `Zappa.invoke_lambda_function` method), so the API Gateway
timeout should not affect these invocations at all.

[1]: https://aws.amazon.com/about-aws/whats-new/2018/10/aws-lambda-supports-functions-that-can-run-up-to-15-minutes
  • Loading branch information
rolandcrosby-check authored Nov 5, 2021
1 parent 9fbec2b commit 679e98e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -420,8 +420,6 @@ Commands which require direct user input, such as `createsuperuser`, should be [

For more Django integration, take a look at the [zappa-django-utils](https://github.com/Miserlou/zappa-django-utils) project.

_(Please note that commands which take over 30 seconds to execute may time-out preventing output from being returned - but the command may continue to run. See [this related issue](https://github.com/Miserlou/Zappa/issues/205#issuecomment-236391248) for a work-around.)_

### SSL Certification

Zappa can be deployed to custom domain names and subdomains with custom SSL certificates, Let's Encrypt certificates, and [AWS Certificate Manager](https://aws.amazon.com/certificate-manager/) (ACM) certificates.
Expand Down
7 changes: 4 additions & 3 deletions zappa/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,13 +331,14 @@ def __init__(
# Some common invocations, such as DB migrations,
# can take longer than the default.

# Note that this is set to 300s, but if connected to
# APIGW, Lambda will max out at 30s.
# Config used for direct invocations of Lambda functions from the Zappa CLI.
# Note that the maximum configurable Lambda function execution time (15 minutes)
# is longer than the maximum timeout configurable in API Gateway (30 seconds).
# Related: https://github.com/Miserlou/Zappa/issues/205
long_config_dict = {
"region_name": aws_region,
"connect_timeout": 5,
"read_timeout": 300,
"read_timeout": 900,
}
long_config = botocore.client.Config(**long_config_dict)

Expand Down

0 comments on commit 679e98e

Please sign in to comment.