'API takes longer to load first time opening my webpage
I have a Django app configured on AWS Lambda with zappa.
In this app I created some basic APIs with DRF.
On the otherside I have a ReactJS frontend that makes these GET requests to load in my data.
On my frontend I make a call to get my ID's based on some condition, with this response I get max. 30 ID's where I loop through and make another call for every ID to get their data.
The first time I do this, my api to get the ID's loads perfectly and fast enough, but then when it loops, some api's to get the data goes really fast and some just takes around 10-20 seconds to load.
this only happens the FIRST time I load my page, after that, if I refresh my page, it is up and running in under 1s.
I did some research and I know that AWS Lambda is serverless and shuts down when no one is using the application, so with that in mind, I thought this was why its always slower the first time.
But then I found a setting on zappa "keep_warm" to keep my server running, I also made sure that "keep_warm_expression" is set to 1minute so I thought that my server will keep running.
Yet I still have this problem.
I don't except a fully answer for this as I didn't give any information of my configuration. But because I can't really figure out if this problem is Backend, Frontend or AWS related, I'd just like some tips on where to look or how to figure this out.
Thanks in advance
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|