xmlprclib/server not reusing connections

Roger Binns rogerb at rogerbinns.com
Mon Feb 23 18:55:08 EST 2004


> Connection reuse would be done at a lower level I think.  Take a look at the
> httplib module.  Take a look at xmlrpclib's MultiCall class for another way
> to improve performance in some situations.


multicall is of no use to me because my following requests depend on the results
of the preceding ones.  SSL is really important since the traffic is going
over the open Internet.  I needed to do some certificate validation which
the Python 2.3 library has no facilities for.

On the server side, things were hopeless as well.  Since it would be
listening on the open Internet, and had to work on Windows as well as
Linux and Mac, the threading server initially seemed appealing, but
sadly it has no facilities for limiting the number of threads spawned.
It also makes a new thread per request, rather than the more normal
design of having a thread pool to deal with requests/connections.

xmlrpclib is coded to use the Python 1.5 compatible names (and lack of
HTTP/1.1 and persistent connections).  SimpleXMLRPCRequestHandler is
hard-coded to close connections after one request (see last line of
do_POST).  The M2Crypto code that added SSL to both inherited those
implementations and design.

Basically the existing xmlrpclib and SimpleXMLRPCServer are hard coded
(and IMHO go out of their way) to do one request per connection, and
then shut things down.  Throw in that I needed to do SSL on both ends, with
HTTP authentication, and some "light" firewalling in order to prevent
DOS attacks, I had to spend several days mashing the various classes
together with M2Crypto together.

You can see the results here:

http://cvs.sf.net/viewcvs.py/bitpim/bitpim/bitfling/xmlrpcstuff.py?view=markup

Roger





More information about the Python-list mailing list