Best practices of high-performance network applications

后端 未结 4 763
被撕碎了的回忆
被撕碎了的回忆 2021-02-04 11:19

While testing out a UDP multicast server that I\'ve written on Windows 7 Ultimate x64, I came across a most curious thing. Playing music with foobar2000 in the background signif

4条回答
  •  眼角桃花
    2021-02-04 11:43

    It has been many years since I wrote network protocol related code, but I'll offer a guess.

    I suspect this is an issue of throughput and latency. Playing music is introducing I/O contention and adding latency in transmitting the packets. However, the added latency is likely causing the packets to queue and thus batched increasing throughput.

    To address this in your code, you might try sending the packets in batches yourself. I am assuming that you are sending each packet to the system for transmission as the data becomes ready. Group multiple packets and send them to the system at the same time. Even just a group of two or three packets could make a dramatic difference especially if you are introducing your own small delay between each system call.

    I couldn't find any directly relevant links from a quick search on Google. However, you can see the concept in this discussion of network tuning for Linux or in this FAQ which describes techniques such as batching to improve throughput.

提交回复
热议问题