Most networks lose packets occasionally. For example, if you ping an Ethernet node that has been inactive for ten minutes or so, you will generally notice that the first packet is lost. This is due to the arp cache entry that maps the IP address to the MAC address of the ethernet card being aged out. Wide area networks that become congested will lose packets. Line errors that corrupt packets will cause CRC errors; except for wireless networks, those packets are dropped.
A TCP stack will notice that a packet has not been acknowledged and will retransmit it transparently to the application. A UDP stack utterly ignores packet loss. The application will have to start a timer, wait for an acknowledgment, and handle retransmissions in the application. You also have to count retransmissions and quit after some limit. Oh, and the receiving application needs code to send the ack... and more code to handle the case where the ack itself gets lost and the sender retransmits, so the duplicate request doesn't cause problems.
Generally, most people will accept the extra overhead of TCP in return for not having to reinvent the wheel. The only really common application programs that use UDP do it because they need to handle packet loss with a different, application-dependent strategy. Voice over IP doesn't request retransmissions when packets are lost because the retransmitted data would arrive much too late to be turned into audio. Video over IP also skips over lost packets without requesting a retransmission, usually by freezing the screen until new data arrives.
I would avoid UDP for this if you have any choice in the matter at all. There are just too many way for that kind of multithreaded code with many little-used timeout and recovery mechanisms to fail in rare non-repeatable ways. (Or as a coworker once put it, "it always almost works.")
In reply to Re: Cache::Memcached via UDP?
by Anonymous Monk
in thread Cache::Memcached via UDP?
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |