Questions about GIL and web services from a n00b

Raymond Hettinger python at rcn.com
Fri Apr 15 21:05:23 EDT 2011


> > Is the limiting factor CPU?
>
> > If it isn't (i.e. you're blocking on IO to/from a web service) then the
> > GIL won't get in your way.
>
> > If it is, then run as many parallel *processes* as you have cores/CPUs
> > (assuming you're designing an application that can have multiple
> > instances running in parallel so that you can run over multiple servers
> > anyway).
>
> Great question.  At this point, there isn't a limiting factor, but yes
> the concern is around CPU in the future with lots of threads handling
> many simultaneous transactions.

In the Python world, the usual solution to high transaction loads is
to use event-driven processing (using an async library such as
Twisted) rather than using multi-threading which doesn't scale well in
any language.

Also, the usual way to take advantage of multiple-cores is to run
multiple pythons in separate processes.

Threading is really only an answer if you need to share data between
threads, if you only have limited scaling needs, and are I/O bound
rather than CPU bound


Raymond




More information about the Python-list mailing list