Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Run django application on apache with uWSGI

I wanted to run my django application using apache and uWSGI. So I installed apache which use worker_module. When I finally run my app and tested its performance using httperf I noticed that system is able to serve only one user at the same time. The strange thing is that when I run uWSGI using the same command as below with nginx I can serve 97 concurrent users. Is it possible that apache works so slow?

My apache configuration looks like (most important elements - the extant settings are default):

<IfModule mpm_worker_module>
    StartServers          2
    MinSpareThreads      25
    MaxSpareThreads      75
    ThreadsPerChild      25
    MaxClients           63
    MaxRequestsPerChild   0
</IfModule>
...
<Location />
    SetHandler uwsgi-handler
    uWSGISocket 127.0.0.1:8000
</Location>

I run uwsgi using:

uwsgi --socket :8000 --chmod-socket --module wsgi_app --pythonpath /home/user/directory/uwsgi -p 6
like image 651
szaman Avatar asked Nov 14 '22 08:11

szaman


1 Answers

I recommend that you put Apache behind Nginx. For example:

  • bind Apache to 127.0.0.1:81
  • bind nginx to 0.0.0.0:80
  • make nginx proxy domains that Apache should serve

It's not a direct answer to your question but that's IMHO the best solution:

  • best performance
  • best protection for Apache
  • allows to migrate Apache websites to Nginx step by step (uWSGI supports PHP now ...), again for best performance and security
like image 126
jpic Avatar answered Dec 21 '22 23:12

jpic