just brew it! wrote:Generally you'll want to aggregate small data items together to reduce the per-packet overhead penalty.
- If there are parts of the protocol which require low latency, and other parts which require efficient operation to move large amounts of data, you will need to make intelligent decisions about when to aggregate things and when to flush them out to the network interface immediately.
- For applications which are extremely latency and/or time sensitive, but which can tolerate a certain amount of packet loss, you may wish to consider using UDP instead of TCP.
So, an interesting point about your suggestion of aggregating small data items together and flushing them out: on most systems, the TCP implementation is often using something like
Nagle's algorithm to do that underneath your application anyway. The socket option TCP_NODELAY is there to disable this for interactive applications. Of course, even with Nagle's algorithm disabled TCP is still not idea for low-latency games, but one could use both, keeping a TCP connection for when bulk reliable transfer is necessary and using UDP for continuous latency-critical signaling updates.
Nitrodist wrote:How are you paid to use it? Thanks for the link -- looks very useful.
Well, I'm not really paid to use it specifically, but we use it extensively at Google.