I am running a Django app using mod_wsgi, and am trying to understand how the apache processes work.
Here is my apache httpd.conf:
<VirtualHost *:80>
ServerName www.example.com
ServerAlias example.com
WSGIDaemonProcess example.com processes=2 threads=15 user=django1 group=django1
WSGIProcessGroup example.com
WSGIScriptAlias / /path/to/django.wsgi
</VirtualHost>
I set two processes, but when I look at top
, I see two processes under user django1 and two more processes under user www-data:
PID USER VIRT RES COMMAND
14035 django1 524m 350m apache2
14116 django1 499m 326m apache2
11800 root 347m 299m apache2
17486 www-data 347m 292m apache2
17689 www-data 347m 292m apache2
Why are those www-data processes there? Am I running something else and not know it? It seems like they are wasting memory. Only the two apache2 processes for user django1 processes show any CPU load. The www-data users don't have any CPU load.
When you use daemon mode and your Django application is therefore running in a separate process to main Apache processes, you still need the Apache parent process and at least one Apache child process. The later is what accepts requests and proxies them through to the mod_wsgi daemon processes. Read:
http://code.google.com/p/modwsgi/wiki/ProcessesAndThreading