Multithreaded Telnet sessions

Pierre-Frédéric Caillaud peufeu at free.fr
Wed Jun 30 11:42:24 EDT 2004


> I can't get over how much faster it is to push a change to 800+
> routers using 20+ threads!

	yes ? and the more ping time you have, the more you can gain by thread  
parallelism.

> Anything over 20 threads seems to take processor utilization to 100%.
> Is there any benefit to starting additional threads once the CPU is at
> 100% ?

	Probably not. With few threads your app is network-lag-limited. With too  
many threads it becomes cpu-limited and might even get slower. I have  
noticed that multithreading network code in Python gives up at a rather  
low number of threads, in the 20-50 as you noticed, which worries me  
because the OS can do a lot better than that. Perhaps is this simply that  
python with 1/20 of your CPU is too slow ? If you want to have 100 threads  
you'll have to spend a few days coding it in (argh) C++ or (argh) Java.

	Or if your brain doesn't explode, you can code it using asynchronous  
select and the asynchat module...

	Or just be happy that it's 20 times faster than before...



More information about the Python-list mailing list