pythonxml-rpcxmlrpclibsimplexmlrpcserver

Python's xmlrpc extremely slow: one second per call


I built an xml-rpc server in Python using SimpleXMLRPCServer, according to the example in the Python documentation. I'm calling it from a Python client on the same machine. The body of the server function executes very fast on its own.

But I find that xmlrpc client performance is excruciatingly slow, taking one second per call. (Using xmlrpclib.)

A speed-up technique I found on the web (skipping the getfqdn resolution) didn't help.

My connect URI is:

'http://localhost:50080'

I'm running Python 2.7 x64 on Windows 7, but it works the same for 32-bit Python 2.7.


Solution

  • The problem seemed to be with the client resolving localhost.

    New (fast) connect URI:

    'http://127.0.0.1:50080'
    

    Similarly, adding this line in the hosts file %SystemRoot%\System32\drivers\etc\hosts has essentially the same effect:

    127.0.0.1 localhost

    Either of these changes increased the speed from 1 call/second to 88 calls/second, and skipping the getfqdn resolution might speed it up slightly more. Not extremely high-capacity, but acceptable for my application.

    Correction: the new performance isn't 88 calls/second, but ~1000 calls/second.