-2

When Django server gets started, I can see only one instance of Django server running in the background. But after a while, I can see multiple instances are running.

Output:

root@GoldenGate:~# ps |grep python 
 1592 root     79636 S    /usr/bin/python /root/celestial_NAS/manage.py runserver 0.0.0.0:80
 2749 root     27936 S    python /root/celestial_NAS/manage.py runsslserver --certificate /etc/ssl/certs/server.crt --key /etc/ssl/private/ser
 2750 root     21056 S    python /root/celestial_NAS/manage.py runserver 0.0.0.0:80
 3156 root     60160 S    /usr/bin/python /root/celestial_NAS/manage.py runserver 0.0.0.0:80
 3185 root     87764 S    /usr/bin/python /root/celestial_NAS/manage.py runserver 0.0.0.0:80
 3193 root     61188 S    /usr/bin/python /root/celestial_NAS/manage.py runserver 0.0.0.0:80
 8023 root     42732 S    /usr/bin/python /root/celestial_NAS/manage.py runserver 0.0.0.0:80
 8107 root     68360 S    /usr/bin/python /root/celestial_NAS/manage.py runserver 0.0.0.0:80
 8145 root     43760 S    /usr/bin/python /root/celestial_NAS/manage.py runserver 0.0.0.0:80
 9163 root     82712 S    /usr/bin/python /root/celestial_NAS/manage.py runserver 0.0.0.0:80
12351 root     73484 S    /usr/bin/python /root/celestial_NAS/manage.py runserver 0.0.0.0:80
13567 root      1304 S    /bin/sh -c python /root/celestial_NAS/changeadminpassword.py
13568 root     16684 R    python /root/celestial_NAS/changeadminpassword.py
13578 root      1304 S    grep python
16450 root     78608 S    /usr/bin/python /root/celestial_NAS/manage.py runserver 0.0.0.0:80
19979 root     48884 S    /usr/bin/python /root/celestial_NAS/manage.py runserver 0.0.0.0:80
24374 root     56060 S    /usr/bin/python /root/celestial_NAS/manage.py runserver 0.0.0.0:80
25372 root     59132 S    /usr/bin/python /root/celestial_NAS/manage.py runserver 0.0.0.0:80
root@GoldenGate:~#

This effects performance of the system, Can you please help me to figure out what is the root cause behind start of multiple instances of single runserver(Django server) with multiple process ids.

T.Chmelevskij
  • 1,904
  • 17
  • 30
  • Have you made any modifications to settings.py? – T.Chmelevskij Nov 21 '15 at 14:48
  • 2
    The django server isn't built for a production environment. You should be using some WSGI server (mod_wsgi, uwsgi, gunicorn, etc..) plus some kind of HTTP server like Nginx, Apache, etc.. Normally when a file changes the dev server spawns a new process and kills the old one. If the user that is running django doesn't have permissions to terminate processes (or maybe something along those lines) the processes will stick around. The proper solution is to have a production set-up on remote machines. – theWanderer4865 Nov 21 '15 at 15:31
  • @T.Chmelevskij ... Hi Thanks for reply...I modified settings.py for adding django packages and others settings for session security, session time out. – Naga Pavan Kumar Nov 22 '15 at 07:52
  • @theWanderer4865, Hi Thanks for information...As you expected, I am using WSGI server, but "the point you told If the user that is running django doesn't have permissions to terminate processes (or maybe something along those lines) the processes will stick around. ", here user is root have all permissions, so that might not be the issue. – Naga Pavan Kumar Nov 22 '15 at 18:21
  • @T.Chmelevskij, http://stackoverflow.com/questions/5576305/django-in-pydev-spawns-multiple-processes , this is the link raised some other person got the same issue, But I could not find the solution from it, Can you please look into this as well – Naga Pavan Kumar Nov 22 '15 at 18:22
  • @NagaPavanKumar You are clearly running the development server which is NOT production ready. The process spawning you are experiencing is some kind of consequence of not using a proper WSGI, HTTP Server combination. – theWanderer4865 Nov 23 '15 at 20:57

1 Answers1

0

Please follow these instructions: How to use Django with uWSGI

And here is another good one.

I believe theWanderer4865 has already explained the reason in details (patience, wow).

Art
  • 2,235
  • 18
  • 34