1 thread per connection limitation?

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

1 thread per connection limitation?

Shawn Walker-2

Greetings,

As I understand it, cherrypy is currently limited to a one thread ==
one connection mapping.  Apache and other servers (from what I
understand) allow a single thread to serve multiple connections for an
increased performance and better resource utilisation. Has there been
any discussions about changing cherrypy to do the same?

Thanks,
-Shawn
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "cherrypy-users" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/cherrypy-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: 1 thread per connection limitation?

Tim Roberts

Shawn wrote:
> As I understand it, cherrypy is currently limited to a one thread ==
> one connection mapping.  Apache and other servers (from what I
> understand) allow a single thread to serve multiple connections for an
> increased performance and better resource utilisation. Has there been
> any discussions about changing cherrypy to do the same?
>  

Apache and CherryPy both use a thread pool concept.  One thread handles
one request AT A TIME.  As soon as the thread has completed a request,
it is assigned another connection to handle.  If you run out of spare
threads, you add a new one to the pool.

Your post implies that you believe CherryPy creates a new thread for
each request, then kills it when the request is complete.  Not so.
Given the thread overhead on Linux, that would suck.

--
Tim Roberts, [hidden email]
Providenza & Boekelheide, Inc.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "cherrypy-users" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/cherrypy-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: 1 thread per connection limitation?

Shawn Walker-2

On Dec 15, 3:09 pm, Tim Roberts <[hidden email]> wrote:

> Shawn wrote:
> > As I understand it, cherrypy is currently limited to a one thread ==
> > one connection mapping.  Apache and other servers (from what I
> > understand) allow a single thread to serve multiple connections for an
> > increased performance and better resource utilisation. Has there been
> > any discussions about changing cherrypy to do the same?
>
> Apache and CherryPy both use a thread pool concept.  One thread handles
> one request AT A TIME.  As soon as the thread has completed a request,
> it is assigned another connection to handle.  If you run out of spare
> threads, you add a new one to the pool.

That wasn't my understanding of how Apache can be configured to work,
I know that CherryPy works that way already.

In short, my understanding was that the classic configuration for
Apache was one connection per thread, but that Apache 2 could be
configured differently.

> Your post implies that you believe CherryPy creates a new thread for
> each request, then kills it when the request is complete.  Not so.
> Given the thread overhead on Linux, that would suck.

No, sorry if I implied that.  I know that it doesn't do that.

-Shawn
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "cherrypy-users" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/cherrypy-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: 1 thread per connection limitation?

Andrew Maizels
Actually, the 1.x version of Apache supported one connection per process.

In 2.x, Apache can support multiple threads per process, and one connection per thread.  That's the same model as CherryPy.

There is an alternative, which is non-blocking I/O, but I'm not sure how you'd make that work outside of just serving static files.


On Tue, Dec 16, 2008 at 9:51 AM, Shawn <[hidden email]> wrote:

On Dec 15, 3:09 pm, Tim Roberts <[hidden email]> wrote:
> Shawn wrote:
> > As I understand it, cherrypy is currently limited to a one thread ==
> > one connection mapping.  Apache and other servers (from what I
> > understand) allow a single thread to serve multiple connections for an
> > increased performance and better resource utilisation. Has there been
> > any discussions about changing cherrypy to do the same?
>
> Apache and CherryPy both use a thread pool concept.  One thread handles
> one request AT A TIME.  As soon as the thread has completed a request,
> it is assigned another connection to handle.  If you run out of spare
> threads, you add a new one to the pool.

That wasn't my understanding of how Apache can be configured to work,
I know that CherryPy works that way already.

In short, my understanding was that the classic configuration for
Apache was one connection per thread, but that Apache 2 could be
configured differently.

> Your post implies that you believe CherryPy creates a new thread for
> each request, then kills it when the request is complete.  Not so.
> Given the thread overhead on Linux, that would suck.

No, sorry if I implied that.  I know that it doesn't do that.

-Shawn




--
Do not complain to us about your MAKO defying natural laws and proper physics. Physics is for the weak. You are not weak. You are strong.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "cherrypy-users" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/cherrypy-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: 1 thread per connection limitation?

Graham Dumpleton-2



On Dec 16, 10:09 am, "Andrew Maizels" <[hidden email]>
wrote:
> Actually, the 1.x version of Apache supported one connection per process.
>
> In 2.x, Apache can support multiple threads per process, and one connection
> per thread.  That's the same model as CherryPy.

No. Apache prefork MPM on UNIX is still single threaded. Apache worker
MPM on UNIX and winnt MPM on Windows are multithreaded. Worker MPM on
UNIX could technically be configured to act like prefork, but not sure
why you would want to.

Thus depends on platform and which MPM is being used. Also, this only
applies if using mod_python or mod_wsgi embedded mode. If using
mod_wsgi daemon mode you have control over number of processes and
threads and thus depends on how you configure it.

Graham

> There is an alternative, which is non-blocking I/O, but I'm not sure how
> you'd make that work outside of just serving static files.
>
>
>
> On Tue, Dec 16, 2008 at 9:51 AM, Shawn <[hidden email]> wrote:
>
> > On Dec 15, 3:09 pm, Tim Roberts <[hidden email]> wrote:
> > > Shawn wrote:
> > > > As I understand it, cherrypy is currently limited to a one thread ==
> > > > one connection mapping.  Apache and other servers (from what I
> > > > understand) allow a single thread to serve multiple connections for an
> > > > increased performance and better resource utilisation. Has there been
> > > > any discussions about changing cherrypy to do the same?
>
> > > Apache and CherryPy both use a thread pool concept.  One thread handles
> > > one request AT A TIME.  As soon as the thread has completed a request,
> > > it is assigned another connection to handle.  If you run out of spare
> > > threads, you add a new one to the pool.
>
> > That wasn't my understanding of how Apache can be configured to work,
> > I know that CherryPy works that way already.
>
> > In short, my understanding was that the classic configuration for
> > Apache was one connection per thread, but that Apache 2 could be
> > configured differently.
>
> > > Your post implies that you believe CherryPy creates a new thread for
> > > each request, then kills it when the request is complete.  Not so.
> > > Given the thread overhead on Linux, that would suck.
>
> > No, sorry if I implied that.  I know that it doesn't do that.
>
> > -Shawn
>
> --
> Do not complain to us about your MAKO defying natural laws and proper
> physics. Physics is for the weak. You are not weak. You are strong.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "cherrypy-users" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/cherrypy-users?hl=en
-~----------~----~----~----~------~----~------~--~---