0

So far I have been experimenting with uWSGI to replace a lot of kludgy server code that builds and does setup for Python wsgi applications under supervise. I am running dozens of these small projects (Django, Flask, other) at once.

Currently I am running in Virtualhost mode and I allow NGINX to basically invoke applications at will. However, it seems the reload feature "touch-reload" is meant for a specific file.

Is there a way to use "touch-reload" to monitor the module that is running either by specifying it per site or automatically? Or is there a way to allow touch-reload to be configured per application?

I have also looked at emperor mode, which seems like it could be a slightly less awesome substitute but I am not sure if my use case would cause dozens if not hundreds of processes to spawn. I like the virtualhost mode because it essentially shares a pool of workers over all of the applications, this seems most efficient to me.

Current Configs:

uWSGI

<uwsgi>
    <vhost-host/>
    <master/>
    <gid>www-data</gid>
    <uid>www-data</uid>
    <catch-exceptions/>
    <socket>/var/tmp/uwsgi.sock</socket>
    <chmod-socket/>
    <idle>300</idle>
    <processes>6</processes>
    <no-orphans/>
    <enable-threads/>
    <reload-mercy>5</reload-mercy>
    <threads>10</threads>
    <no-default-app/>
    <touch-reload/>
    <!-- <reload-on-rss>128</reload-on-rss> Reload at 128MB of RSS (memory usage) -->
</uwsgi>

Update:

After doing some research about how uWSGI handles shutting down idle workers, I think I will need the emperor mode after all.

What I am trying to do is let seldom used applications take no resources and oft used applications take more resources. I am trying to do that while maintaining a hosting deployment as simple as PHP-FPM. The virtual mode achieves this but seems to shut down all workers only after all applications have been idle, which isn't useful if any app receives a steady stream of traffic. I would love to be corrected on this issue if it's untrue.

The downside to going with emperor mode is that I will have to make socket files and config files for each application (blech!). I would still like to know if it's possible to implement per application reloading as mentioned above though.

2

you should ask it in the official mailing-list, all of your statements are true, so you should try to ask for an improvement in the list.

  • Unfortunate, but I will refer the mailing list here. Thanks for the info. – Xealot Jun 18 '11 at 15:57
0

If you're running multiple apps, you probably want emperor mode which superceded vhost mode for most use cases (including what you describe).

For dynamically scaling workers across all the apps, you have several options.

The simplest is probably uWSGI's cheaper subsystem. It provides very fine-grained controls for setting minimum and maximum number of workers for each app, as well as enforcing a global memory limit across all apps (so you don't have a complete blowup if all apps spike at once.)

If you want a single pool of workers that are shared across all apps (rather than spinning workers up/down for each app), then the slightly more complex solution is Emperor + Broodlord + Zergs. The best place to start is probably the official docs on Broodlord mode: http://uwsgi-docs.readthedocs.org/en/latest/Broodlord.html

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.