mod_python versus mod_wsgi

January 6, 2009 at 7:09 pm | Posted in General | 8 Comments

So at work recently, we started looking at switching our django setups from mod_python to mod_wsgi, as we kept having memory and cpu use issues with mod_python, and mod_wsgi was supposed to be far better with performance.

Well, it’s only been a day so far, but the results have been very promising. Our memory usage was cut in half, and load bottomed out.

Edit: this is daemon mode with threads=1

Initial testing showed more drastic improvements, so for anyone else testing, take initial results with a grain of salt 🙂

With that said, here are the actual results:

Just after switching:

mod_python to mod_wsgi

A day after switching:

mod_python-to-mod_wsgi-day-after

Too early to be absolutely sure that everything is working well, but it’s all looking good so far 🙂

Advertisement

8 Comments

  1. Interesting. What kind of user load does Chesspark see? That is a drastic improvement.

  2. Or more importantly (can’t edit comments!) — Have you noticed a speed difference? Not sure how quick mod_wsgi is compared to mod_python, despite the decrease in load.

    • Well the busy times that used to cripple the site with 10+ load and made it unreachable now only resulted in a slightly slower page loading time – 3s by me just counting it 🙂

  3. Interesting results. While I can see an explanation for the reduction of memory usage I am wondering if you can add some more details like:
    – what is the memory footprint of the Django app
    – is the Apache instance a default one or have you cut out most of the modules

    Let me explain myself: if configured with same number of subprocesses the memory difference for the 2 approaches is due only to the memory footprint difference between an Apache process and a mod_wsgi process. A massive reduction of the memory makes me believe that:
    a) either your Apache is using tons of modules
    b) the 2nd configuration might not be using the same number of subprocesses
    c) your Django app memory footprint is ignorable

    CPU usage cut is even harder to explain because basically the 2 approaches are equivalent and the only major change is that instead of spawning new httpd processes the 2nd approach is spawning mod_wsgi processes. Basically, it is hard to explain why spawning mod_wsgi processes is so much lightweight in terms of CPU utilization than spawning httpd subprocesses.

    I’d really appreciate if somebody would be able to shed some more light on the CPU usage changes.

  4. It’s not hard to explain at all – mod_wsgi in daemon mode is just that much better – NOTHING else changed between mod_python and mod_wsgi – I didn’t remove other modules at the same time or change other settings, I merely switched it from mod_python to mod_wsgi.

  5. Collin, I tend not to believe in IT miracles 🙂 and I must confess that it’s quite difficult to accept that spawning httpd processes is tens up to hundreds of time more expensive than spawning modwsgi processes.

  6. But it isn’t just httpd processes – it’s mod_python being so much worse.

    You’re focusing on httpd vs wsgi process instead of what matters :p

  7. You’re absolutely right! I’ve lost it from sight, when it actually is the elephant in the room.


Sorry, the comment form is closed at this time.

Create a free website or blog at WordPress.com.
Entries and comments feeds.

%d bloggers like this: