Open navenchary opened 5 years ago
Have you tried reducing the rate? People have found that useful in some regions.
Yes I did. I had modified the keep_warm_expression to 2 minutes. But there is no difference in the API response time. I could see the keep_warm_callback event fired in zappa tail every 2 minutes. But Still the API is taking around 8 seconds to respond.
Aws lambda cold start is for one "lambda instance" only.
This article explains it in details : https://theburningmonk.com/2018/01/im-afraid-youre-thinking-about-aws-lambda-cold-starts-all-wrong/
You can see also a patch I have made to make zappa work with lambda-warmer-py to deal with this issue : https://github.com/Miserlou/Zappa/issues/1790
I have written an API using django rest framework. I have deployed it using aws zappa. It takes at least 7 to 10 seconds to respond if I leave the API without using for 15 minutes.
I am usnig django 2.1.3 and djangorestframework 3.9.0. I am running into the cold start issue. I have tried "keep_warm" settings in zappa_settings.json file. But it does not solve my problem. I can see the lambda call back function is called every 5 minutes but still my API is taking minimum 8 seconds to respond for the first time. I am unable to solve this.
Please help.
Your Environment
zappa_settings.py
: { "dev": { "aws_region": "ap-south-1", "django_settings": "trubloqapi.settings", "profile_name": "default", "project_name": "xxxxxxx-xxx", "runtime": "python3.6", "s3_bucket": "xxxxx-xxx", "slim_handler": true, "vpc_config" : { "SubnetIds": [ "subnet-000000e86b94b75c3" ], // use the private subnet "SecurityGroupIds": [ "sg-87yt5644c413a2b00","sg-4rt56yd75b14cda33"] }, "memory_size": 1024, // Lambda function memory in MB. Default 512. "log_level": "DEBUG", // Set the Zappa log level. Can be one of CRITICAL, ERROR, WARNING, INFO and DEBUG. Default: DEBUG "keep_warm": true, // Create CloudWatch events to keep the server warm. Default true. To remove, set to false and thenunschedule
. "keep_warm_expression": "rate(4 minutes)", // How often to execute the keep-warm, in cron and rate format. Default 4 minutes. "lambda_description": "Test Description", // However you want to describe your project for the AWS console. Default "Zappa Deployment". "extra_permissions": [{ // Attach any extra permissions to this policy. Default None "Effect": "Allow", "Action": "lambda:InvokeFunction", "Resource": ["arn:aws:lambda:ap-south-1:9877678916:function:trubloq-xxxx4-dev"],// AWS Service ARN }], } }