1

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 ?

Yugal Jindle
  • 161
  • 1
  • 6

1 Answers1

0

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()).

roberto
  • 1,827
  • 12
  • 8
  • Well, its just an initial setup - that definitely needs tweaking. – Yugal Jindle Apr 07 '12 at 02: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 07 '12 at 02: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 07 '12 at 02: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 07 '12 at 05:41