Questions about GIL and web services from a n00b

Chris H chris.humphres at windsorcircle.com
Wed Apr 20 22:01:52 CEST 2011


On 4/19/11 3:48 AM, Lamont Nelson wrote:
>   >  1. Are you sure you want to use python because threading is not
> good due
>> to the Global Lock (GIL)?  Is this really an issue for multi-threaded
>> web services as seems to be indicated by the articles from a Google
>> search?  If not, how do you avoid this issue in a multi-threaded process
>> to take advantage of all the CPU cores available?
> To take advantage of the cores on your server you'll want to consider
> a multi-process design instead of multi-threading. You can achieve
> this with something like http://projects.unbit.it/uwsgi/, which will
> allow you to manage the processes. I've used this behind apache
> successfully.
>
>> 2. Are there good web services frameworks available for building a REST
>> based service?  I admit I have looked at web2py, Django, pyramid/pylons,
>> and a few others.  SOAP seems to be pretty well supported but I'm not
>> finding the same for quick development of REST based services for
>> exchanging JSON or XML formatted data.  This is probably just my n00b
>> status, but what tools are best for building a simple REST data exchange
>> API?
> I've personally used Pyramid to implement REST web services with
> multiple data transport formats (json, xml) for the same endpoints
> with minimal fuss. It's basically as simple as returning an object
> from your view and defining a renderer that knows how to translate
> this object to the desired format. Look at
> http://docs.pylonsproject.org/projects/pyramid/1.0/narr/renderers.html#views-which-use-a-renderer
> and http://docs.pylonsproject.org/projects/pyramid/1.0/narr/viewconfig.html#view-config-chapter
> for more information.
>
> Lamont

Thanks to everyone who has replied.  I have a better understanding of 
the limitations around the GIL as well as the relatively architectures 
for avoiding the issue.  Now to find the right framework for a simple 
web service.  So far I've heard pyramid the most, but others we are 
looking into include rest.ish.io, web2py, and flask.  Anyone with 
experience across these as to what is best for someone starting from 
scratch now?

Chris




More information about the Python-list mailing list