Re:Reining in the thundering herd: Getting to 80% CPU utiliz...
by scrollaway on Sunday August 15, 2021 @10:40PM
(#28194476)
There's a few reasons why this scenario wouldn't be a good fit for cloud functions, but that "couple of seconds start-up time" can be almost entirely removed from the equation by keeping the Django instance alive (all cloud function type offerings will have a concept of cold and warm starts, and some way to control persistence across calls on the same "instance").
I've run Django on AWS Lambda in a a scenario that scaled between 25-250 calls per second depending on time of day (for a runtime of 5-30 sec). Moving Django's bootstrapping so it would stay warm across calls was very easy.
Re:Reining in the thundering herd: Getting to 80% CPU utiliz...
by stuaxo on Monday August 16, 2021 @05:16AM
(#28196283)
Silly question, but under nginx or apache do django instances persist or are they recreated for every new request?
Re:Reining in the thundering herd: Getting to 80% CPU utiliz...
by aeyes on Monday August 16, 2021 @03:24PM
(#28201809)
The standard gunicorn configuration (and the one shown in the blog post) never restarts worker processes.
gunicorn has an option --max-requests to restart every X requests but unless you have unfixable memory leaks there is no reason to do this.
Nginx can't directly run WSGI applications, you can do it with Nginx Unit which also never restarts processes.
Re:Reining in the thundering herd: Getting to 80% CPU utiliz...
by zbentley on Tuesday August 17, 2021 @05:18AM
(#28207793)
> unless you have unfixable memory leaks there is no reason to do this.
It's also useful to set this threshold to prevent long-lived connections to services/datastores not used by every request from accumulating and consuming resources on those services.
Django also has in-memory caches, for example for templates which can be extremely slow (seconds) and CPU intensive to render. So you really don't want to have AWS or Google restart your application on AppEngine whenever they feel like it.