[uWSGI] on-demand multi-app setup

chuck odonnell chuck at odonnellpdc.com
Mon Apr 6 17:55:10 CEST 2015


Hosting 200-300 WSGI apps. At any given time only 5-10 are active. The
goal is to have app load on demand, then die-on-idle. Active apps may
see a few hits a day, or a million hits a day. Others may sit for a
month with no traffic at all. Some apps use a unique virtualenv, so I
do not want them embedded in the same process. I would like each app
to be a process.

Basically we want to duplicate an on-demand FastCGI setup, but remove
fastcgi from the equation.

So far had luck implementing under nginx using:

  emperor = /usr/local/etc/uwsgi/sites
  emperor-on-demand-directory = /var/run/uwsgi

And for each file in /usr/local/etc/uwsgi/sites

  callable = app
  mount = /run/p1=proj.py
  chdir = /sites/p1
  manage-script-name = true
  workers = 20
  cheaper-initial = 1
  cheaper-step = 1
  idle = 10
  cheaper = 0
  die-on-idle = true
  fastcgi-socket = /var/run/uwsgi/p1.socket

However, I need this to work with Apache, but Apache/mod_proxy_uwsgi
does support dynamic Unix sockets.

So the question is, is there another approach I can take using
something like an emperor with a fastrouter that starts an app upon
regex match, and then lets the app die-on-idle after a time?

If I can do that, then I can configure Apache to route matching
requests to this single uWSGI process.

Suggestions welcome.

 Freebsd 10.1 Apache 2.4.12 uwsgi-2.0.10

Thank you.



More information about the uWSGI mailing list