Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I have about a dozen small Django sites I want to run using Nginx and uWSGI. They are on a 4-core server with 8 gigs of ram. Should each site be configured on its own socket and how can I control the total number of processes across all instances of uWSGI? If each up app has 30 processes, how can I prevent running out of ram?

share|improve this question

1 Answer 1

up vote 2 down vote accepted

add --limit-as option to each instance and limit the number of requests each process will manage after being restarted (-R 1000 is normally a good value, this will mitigate leaks)

30 processes per app looks a bit too much for me, start with 8 (ncpu*2) and increase them if you need it

If you want, you can use the development tree (take it via mercurial) and use jailing features:

http://projects.unbit.it/uwsgi/wiki/UseCgroups

http://projects.unbit.it/uwsgi/wiki/LinuxNamespace

share|improve this answer
    
That is pretty handy, but the situation I am most worried about is that one site gets a lot of traffic on one day and needs most of the server resources, on a different day another site needs the same thing. If site one has enough idle processes to fill memory what will happen when site two needs the memory? –  Jason Christa Feb 19 '11 at 14:10
1  
In such situation (no deterministic resource allocation) you can go for multiple application mode + virtual hosting. You will spawn a relatively big number of processes that hosts all the apps. It is a bit complex to setup, but once you get it you will add new apps in no time. projects.unbit.it/uwsgi/wiki/VirtualHosting –  roberto Feb 19 '11 at 17:23
    
I tried to get that working for hours but it seems whatever app started first is the only one it would show. In the wsgi.py I add two relative directories 'apps' and 'sites' that live inside the project directory to the python path. Is it possible the python path is being shared across apps even though I am using a virtual env and running uWSGI with the correct pyhome and with vhost and no-sites. –  Jason Christa Feb 21 '11 at 3:56
    
@Jason Christa: Did you succeed on this? I'm having the same problem. –  Sergio May 21 '11 at 15:34
    
@Sergio: Yes, I use one uWSGI config (you must use xml and not ini here) and use Nginx vhosts to pass in the correct import paths and the location of the configuration file for each site. –  Jason Christa May 23 '11 at 18:49

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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