Python: moving from dev server to production server
<p>I am developing an application with the <code>bottlepy</code> framework. I am using the standard library <code>WSGIRefServer()</code> to run a development server. It is a single threaded server.</p>

<p>Now when going into production, I will want to move to a multi-threaded production server, and there are many choices. Let's say I choose CherryPy.</p>

<p>Now, in my code, I am initializing a single <code>wsgi</code> application. Other than that, I am also initializing other things...</p>

<ul>
<li>Memcached connection</li>
<li>Mako templates</li>
<li>MongoDB connection</li>
</ul>

<p>Since standard library <code>wsgiref</code> is a single threaded server, and I am creating only a single wsgi app (wsgi callable), everything works just fine.</p>

<p>What I want to know is that when I move to the multi-threaded server, how will my wsgi app, initialization code, connections to different server, etc. behave.</p>

<ul>
<li><p>Will a multi-threaded server create a separate instance of wsgi app for every thread. And will a new thread be spawned for each new request (which then means a new wsgi app for each request)?</p></li>
<li><p>Will my connections to memcached, mongoDB, etc, be shared across threads or not. What else will be shared between threads</p></li>
<li><p>Please explain the request-response cycle for a threaded server</p></li>
</ul>
