belaudiobooks / website

Catalog of belarusian audiobooks
GNU General Public License v3.0
32 stars 6 forks source link

App Engine performance improvements #129

Open frombrest opened 8 months ago

frombrest commented 8 months ago

In order to improve customer experience and minimize risk of high expenses there is an idea to adjust scaling policies to have: https://cloud.google.com/appengine/docs/standard/reference/app-yaml?tab=python#scaling_elements

min_instances at least 1
max_instances at most 10 (need to be discussed)

To apply these settings GCP recommends implement warmup requests: https://cloud.google.com/appengine/docs/standard/configuring-warmup-requests?tab=python

In addition to that, setting up persistent connections in Django to have db connections ready to serve customer requests: https://docs.djangoproject.com/en/5.0/ref/databases/#persistent-connections And persistent connection healthcheck: https://docs.djangoproject.com/en/5.0/ref/settings/#conn-health-checks

nbeloglazov commented 8 months ago

Can you elaborate more on warmup requests? From reading it seems like it's used to perform some initialization on the app site. When appengine launches a new instance of our site - it can send us a warm up request and we perform caching/initialization specific to our app. Do we have stuff that requires initialization?

nbeloglazov commented 8 months ago

Ah, I see. min_instances require warmup request handling. Even if warmup requests does nothing I guess? I don't really understand that requirement but sure, we can implement it.

frombrest commented 8 months ago

Besides of requirement in scaling policies, we can prewarm our data.json endpoint cache and by this way prepare db connection which I hope we will be able to re-use by persistent-connections feature from django

frombrest commented 8 months ago

Even if warmup requests does nothing I guess? I don't really understand that requirement but sure, we can implement it.

I think they use it like a kind of watchdog to be sure VM will not suspended/terminated