Does Python scale for heavy web loads?
Brad Knotwell
knotwell at ix.netcom.com
Tue Sep 5 20:31:32 EDT 2000
markhaliday at my-deja.com 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 Default.py
> script as an example) I call Default.py to render some information,
> only one thread runs Default.py right? No other people can hit
> Default.py until Default.py 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.
--Brad
More information about the Python-list
mailing list