12

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.

JimB
  • 971
  • 8
  • 20

1 Answers1

29

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.

JimB
  • 971
  • 8
  • 20
  • Can confirm. Had this issue using PyMols xmlrpc server and it was very, very slow. Hosts file had the line `127.0.0.1 localhost` commented. Simply uncommenting it solved the issue. Great! – beginner_ Mar 03 '16 at 05:39
  • 1
    NOTE: using localhost can be *dangerous*. If some sysadmin sticks "localhost.yourdomain.com" in some DNS server, boom... all your programs stop working. I prefer 127.0.0.1 ... directly. – Erik Aronesty Apr 21 '20 at 22:53