Forums

Web Apps "Cold" Starts

Hello,

I have a machine learning focused web app that behaves well (returns results under 60s usually). The issue is that the app is for a demo purpose so its not constantly accessed. For example, we may have a large number of requests for one day and then go 1 - 2 weeks without having another busy day.

I notice that when using the site after a period of downtime, sometimes endpoints fail (without any errors) on the first try and it usually results in the following log in the server.log,

2022-11-08 18:44:50 *** Starting uWSGI 2.0.19.1 (64bit) on [Tue Nov 8 23:44:23 2022] *** After trying again though, the site works as expected.

What I think is happening is that because our app does not have a lot of traffic, it is 'suspended' until a request comes in and then it is restarted. Is my understanding correct? And if so, how can I mitigate this issue?

Thanks in advance!

Web apps are not being suspended due to lack of traffic, but we do have to reboot our web servers periodically for maintenance reasons. After such reboot the web app will wait for a first request to load. To mitigate this issue, you could have a simple scheduled task (or maybe an always-on task) that would send a request to the web app, say, once per few minutes, or -- if you know when you need the web app to be up -- before that times.

Thank you pafk!

I think that solution makes sense, I'll look into adding a health check endpoint and then setting up a scheduled task to hit that endpoint in regular intervals.

Cool! An alternative solution might be delegating the heavy processing part of the web app outside of it (e.g. to an always-on task) and making the web app as light as possible, see this help page.