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

I have configured my Nginx with Django uwsgi.

When the django server starts, it reads a 5MB file from the hard-disk.

Now, Without Nginx with Django default server

python manage.py runserver => Runs immediately and starts serving pages.

Problem:

With Nginx as the server

It takes very long time and several HTTP 504 before it start serving pages.

So, How does uwsgi workers work with Nginx ?

I have:

4 Workers 512 Threads each

So, is the 5MB file getting read 512 * 4 times ?

Is there a possible work around for this in Nginx / Uwsgi ?

share|improve this question

1 Answer 1

A total of 2048 threads ??? Are you sure you have the resources to maintains such a beast ? You will need to heavy tune your kernel too.

By the way if you read the file in the WSGI entry point it will be read only on startup (and then forked()).

share|improve this answer
    
Well, its just an initial setup - that definitely needs tweaking. –  Yugal Jindle Apr 7 '12 at 2:07
    
Hm, if its read and forked then this should mean that I am replicating the 5MB file 2048 times in the RAM.. right ? –  Yugal Jindle Apr 7 '12 at 2:08
    
That should mean 10GB of memory usage, but the server has only 512 MB ram. And its using only half of it. So, this can-not be true. –  Yugal Jindle Apr 7 '12 at 2:14
    
fork() means copy-on-write, if you do not modify that memory area, you will maintain the same copy. But it depends on your app and how it uses that area. By the way, do not expect to be able to run more than 20-30 threads per worker on 512M. –  roberto Apr 7 '12 at 5:41

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.