Does Python scale for heavy web loads?

Brad Knotwell knotwell at
Wed Sep 6 02:31:32 CEST 2000

markhaliday at writes:
> Question: Using Python as a CGI and running it under Apache, would
> Python realistically be able to handle 5,000 hits an hour and not
> degrade performance?  With Python's threading, (ex: using a
> script as an example) I call to render some information,
> only one thread runs right?  No other people can hit
> until finishes with its original request and
> serving the information back...Correct?

You'll need to be way more specific that this.  I don't generally do cgi 
stuff, but I can't imagine any reasonable machine would have trouble 
executing 1.4 progs/s (I just executed a virtually empty python 10 times 
in .5s).  Of course, if each of the programs does a huge amount of computation
or communication then you'll have trouble.  Bottom line:  you'll need to 
throw together a prototype and validate it for yourself.

WRT threading, you've asked the wrong question.  If you create a thread,
you'll give it a function as an argument.  If the function updates any
shared state, you'll need to protect the state variable with a mutex.  OTOH, 
if the function doesn't update any shared state, you are fewer gotchas to 
worry about.  I find the question a bit odd anyhow, since Apache spawns a 
separate process for all cgi requests on Unix systems (FWIW, it probably uses
threading on NT).

Lastly, in my experience, I've never seen a cgi script that couldn't be
run multiple times by a webserver.  I can imagine a script that uses 
lockfile (or something similar) to arbitrate access to a particular resource.

> Thanks.


More information about the Python-list mailing list