Why is uWSGI using more memory than Apache?
django, nginx, uwsgi
Solution
It all comes down to configuration. Because most of the memory comes from your fat Python web application, actual underlying WSGI server memory use generally contributes very little.
You should go watch my PyCon talk where I cover this specific issue and how people are deceived over the defaults the different WSGI server solutions use.
http://lanyrd.com/2012/pycon/spcdg/
In short, it is a bit of a mistruth that Apache/mod_wsgi will use a lot more memory. Configure it in a comparable way to other solutions and it would use comparable memory for same Python web application.
Problem
I decided to try out NGINX/uWSGI for my Django application instead of Apache/mod_wsgi. My reason for giving this a try is that I heard NGINX/uWSGI uses less memory, performs better in high traffic situations, and NGINX is great for serving static content. However I'm finding that uWSGI is using almost 5x more RAM than Apache. ``` ubuntu@domU-12-31-39-0A-9C-1A:~$ sudo ps_mem.py Private + Shared = RAM used Program 184.0 KiB + 31.5 KiB = 215.5 KiB atd 220.0 KiB + 94.0 KiB = 314.0 KiB upstart-socket-bridge 260.0 KiB + 101.0 KiB = 361.0 KiB upstart-udev-bridge 340.0 KiB + 63.0 KiB = 403.0 KiB cron 392.0 KiB + 82.0 KiB = 474.0 KiB sudo 560.0 KiB + 14.0 KiB = 574.0 KiB dhclient3 612.0 KiB + 189.0 KiB = 801.0 KiB getty (6) 816.0 KiB + 35.5 KiB = 851.5 KiB dbus-daemon 660.0 KiB + 359.0 KiB = 1.0 MiB udevd (3) 960.0 KiB + 74.0 KiB = 1.0 MiB rsyslogd 1.1 MiB + 38.5 KiB = 1.2 MiB redis-server 1.1 MiB + 146.5 KiB = 1.2 MiB init 1.7 MiB + 1.1 MiB = 2.9 MiB nginx (3) 1.3 MiB + 1.8 MiB = 3.1 MiB sshd (3) 7.5 MiB + 69.5 KiB = 7.6 MiB bash 14.4 MiB + 5.7 MiB = 20.1 MiB apache2 (6) 23.6 MiB + 113.0 KiB = 23.7 MiB mysqld 95.5 MiB + 8.6 MiB = 104.1 MiB uwsgi (7) --------------------------------- 169.7 MiB ================================= ``` Is this expected? Have I possibly configured something incorrectly? (master=true, 4 workers) Do you only see the benefit when the server is under stress?