Update to original post: colleague indicated that I am doing wrong. I will give an explanation at the bottom of the post, as this may be useful to others.
I am trying to get a basic understanding of python program network performance limitations and have run into an anomaly. Code snippet
while 1: sock.sendto("a",target)
sends UDP packets to the target machine as soon as the host sends. I measure the sending speed of just over 4000 packets per second, or 250 us per packet. This seems slow even for an interpreted language such as python (the program runs on a dual-processor AMD, Linux, python version 2.6.6). I have seen much better performance in python for TCP, so I find this a bit strange.
If I ran this in the background and ran the top, I found that python uses only 25% of the processor, assuming that python might artificially delay UDP packets.
Has anyone else experienced something like this? Does anyone know if python limits the packet transfer rate, and if there is a way this is disabled?
BTW, a similar C ++ program, can send more than 200,000 packets per second, so it is not the internal limit of a platform or OS.
So it turns out I made a stupid newbie mistake. I forgot to call gethostbyname explicitly. Therefore, the destination address in the sendto command contained a symbolic name. This caused a name resolution every time a packet was sent. After that, I measure the maximum sending speed of about 120,000 p / s. Much better.
user1644373
source share