<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xml:base="http://www.technologicalwanderings.co.uk"  xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
 <title>Technological Wanderings - wgsi</title>
 <link>http://www.technologicalwanderings.co.uk/taxonomy/term/117</link>
 <description></description>
 <language>en</language>
<item>
 <title>mod_wsgi</title>
 <link>http://www.technologicalwanderings.co.uk/node/62</link>
 <description>&lt;div class=&quot;field field-name-taxonomy-vocabulary-1 field-type-taxonomy-term-reference field-label-above&quot;&gt;&lt;div class=&quot;field-label&quot;&gt;Keywords:&amp;nbsp;&lt;/div&gt;&lt;div class=&quot;field-items&quot;&gt;&lt;div class=&quot;field-item even&quot;&gt;&lt;a href=&quot;/taxonomy/term/117&quot;&gt;wgsi&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;field-item odd&quot;&gt;&lt;a href=&quot;/taxonomy/term/118&quot;&gt;python&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;field-item even&quot;&gt;&lt;a href=&quot;/taxonomy/term/119&quot;&gt;mod_wsgi&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;field field-name-body field-type-text-with-summary field-label-hidden&quot;&gt;&lt;div class=&quot;field-items&quot;&gt;&lt;div class=&quot;field-item even&quot;&gt;&lt;p&gt;mod_wsgi in daemon mode is a massive improvement over both mod_python and mod_wsgi in embedded mode.&lt;/p&gt;
&lt;p&gt;mod_python was causing Apache2 to use the full memory and swap of my 256MB Slicehost server; that&#039;s around 700MB total commit. The same happened with mod_wsgi initially. The reason being that for each Apache process launched, the whole of my application&#039;s footprint was fetched into memory.&lt;/p&gt;
&lt;p&gt;Partial solutions are to reduce the number of Apache processes, which bring its own problems when you don&#039;t have enough to serve your users.&lt;/p&gt;
&lt;p&gt;mod_wsgi in daemon mode solves this by launching separate python-specific processes to look after your code, leaving Apache to look after incoming requests and static files. A single python process can look after a hundred Apaches.&lt;/p&gt;
&lt;p&gt;It should have only taken a few minutes to configure daemon mode over embedded, but it was not obvious to me how to start the daemon. I spent a lot of time researching how to do it until I finally read the correct part of the documentation: mod_wsgi actually looks after this for you; there&#039;s no separate daemon to start.&lt;/p&gt;
&lt;p&gt;Here&#039;s my configuration:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;
    WSGIDaemonProcess unique_process_id processes=2 threads=4 maximum-requests=100 display-name=%{GROUP}&lt;br /&gt;
    WSGIScriptAlias / /var/www/website/wsgi.py&lt;br /&gt;
    WSGIProcessGroup unique_process_id&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;
That&#039;s all you need over the daemon mode. There are a huge number of configuration options to tweak the way it runs which I won&#039;t go into here, but you can make it do pretty much whatever you need.&lt;/p&gt;
&lt;p&gt;In terms of performance, I suspect that a daemon won&#039;t be as fast as a python-per-request, but since embedded in my experience eventually leads to swapping, daemon modes wins out overall.&lt;/p&gt;
&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;</description>
 <pubDate>Sat, 09 May 2009 11:41:22 +0000</pubDate>
 <dc:creator>techuser</dc:creator>
 <guid isPermaLink="false">62 at http://www.technologicalwanderings.co.uk</guid>
 <comments>http://www.technologicalwanderings.co.uk/node/62#comments</comments>
</item>
</channel>
</rss>