Miserlou / Zappa

Serverless Python
https://blog.zappa.io/
MIT License
11.89k stars 1.2k forks source link

"keep_warm":"true" settings does`nt work #1854

Open navenchary opened 5 years ago

navenchary commented 5 years ago

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

jneves commented 5 years ago

Have you tried reducing the rate? People have found that useful in some regions.

navenchary commented 5 years ago

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.

M0dM commented 5 years ago

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