Simple threaded web-server based on BaseHTTPServer?

Thomas Weholt thomas at gatsoft.no
Thu Jan 31 08:02:06 EST 2002


> You almost certainly don't want that for the real world.  Having a
> thread per connection will not scale well at all.

What are we talking about here; scale in regards of number of concurrent
connections? What could one expect to in terms of performance?
I'm not making a web-server for slashdot-like sites in regards of number of
daily hits. This is webserver for personal sites, with a small to medium
amount ( 10 to 1000 hits pr. day ??) of traffic. It's more important that
it's stable, easy to understand and use.

> Medusa offers scalability.  The main thread can handle a large number of
> connections, as no connection ever blocks the main thread.

My earlier tests showed that Medusa "generates" exceptions when hit with
even a small number ( compared to Apache or MS IIS. On pretty similar boxes
Medusa took about 10% of the same hits before it caved in, either returning
trash to the browser or locking up, spewing out exceptions ) of concurrent
users, and the lack of threads made it unsuitable for serving nothing but
simple web-pages. If the process of generating the content took some time,
the user had to wait, and it blocked each incoming request. The result was
awful. Mind you, this was not using threads of any kind, just plain
Medusa-setup and I'm not exactly a HTTP/Web-server professor, so I might
have missed some vital points. My request for info about threads in medusa
didn't seem to get a great, warm welcome either. From the info I've seen so
far ( things said in Programming Python, 2nd ed. and on Medusa mailing-lists
and its webpage ) Medusa is best suited for serving content with very short
response time. My objects may take a few seconds to populate and then some
time to generate the html based on them.

The exceptions occured somewhere inside Medusa, and the thing was hard to
debug .The BaseHTTPServer-module seem smaller and easier to use. I do have
to parse headers manually and do a lot of stuff that Medusa would handle for
me, but at least I get full control ( without having looked inside the
BaseHTTPServer-module at all. I might be wrong here too ).

> It would make sense on multiple CPU machines to have a small thread-pool

My target audience won't have the money to buy multi-CPU machines, but ...

And what about SSL and BaseHTTPServer?? SSL is a requirement later on in the
project. Medusa offers HTTP/1.1 too and it would really help to be able to
use compression. What about BaseHTTPServer and HTTP/1.1 ? Is it just another
case of doing it the hard way; manually?

PS! I *do* think Medusa is great. I just want a lightweight, easy to use and
stable framework to base my application-server on. The keyword here is
application-server; many of the pages will server content taking up to 10
seconds or more to produce from the subsystems -> threads required ??

Thanks for your input Mark !! :-)

Best regards,
Thomas Weholt





More information about the Python-list mailing list