xmlrpc slow in windows 7 if hostnames are used

Jean-Michel Pichavant jeanmichel at sequans.com
Fri Feb 5 05:58:18 EST 2010


News123 wrote:
> Yhanks  a lot I'll check whether this is the root cause.
>
> Currently my machine could live without IPV6
>
>
> bye
>
> N
>
>
> Gabriel Genellina wrote:
>   
>> En Thu, 04 Feb 2010 19:34:20 -0300, News123 <news123 at free.fr> escribió:
>>
>>     
>>> I wrote a small xmlrpc client on Windows 7 with python 2.6
>>>
>>> srv = xmlrpclib.Server('http://localhost:80')
>>>
>>> I was able to perform about 1 rpc call per second
>>>
>>>
>>> After changing to
>>> srv = xmlrpclib.Server('http://127.0.0.1:80')
>>>
>>> I was able to perform about 10 to 16 rpc calls per second.
>>>
>>> So it seems, that under windows 7 the host name lookup occurs for every
>>> RPC call
>>>       
>> Not necesarily. There is another difference: 127.0.0.1 is an IPv4
>> address, localhost maps to both IPv4 and IPv6 addresses (::1)
>>
>> I vaguely remember a problem with that - IPv6 is tried first, doesn't
>> work, only then IPv4, and that slows down the whole process.
>> Try disabling completely the IPv6 stack, if you don't need it.
>>
>>     
Or you can simply use an explicit external address. Most of the time 
xmlRPC server/clients are used between distant machines.
If your are using localhost for test purpose, then binding your server 
on its external IP instead of the local one could solve your problem 
(wihtout removing the IPV6 stack).

import socket

# server
server = SimpleXMLRPCServer((socket.gethostname(), 5000), 
logRequests=False, allow_none=True)


# client
xmlrpclib.ServerProxy("http://%s.yourdomain.com:%s" % 
(socket.gethostname(), 5000))

JM

PS : please don't top post :o)
PS : just wondering if using the port 80 is legal



More information about the Python-list mailing list