|
|
|
|
|
by takeda
4226 days ago
|
|
UDP does not give any significant benefits to TCP when latency is not as important (e.g. playing previously recorded movies as opposed live streaming). In fact UDP makes things much harder, for example unlike TCP with UDP you need to worry about the rate at which you're sending the data. Too slow and you're not utilizing the full bandwidth, too fast and packets are getting dropped because the client can't receive it fast enough. If you don't have a real good reason for UDP you should stick with TCP otherwise be prepared to re-implement your own congestion/rate control, and unless you're familiar with the subject it might be a challenge. IMO an good example of unnecessarily using UDP is Etsy's statsd. Their argument is that it's ok when data is lost so no need for TCP. Unfortunately with their approach when there's enough of traffic on the LAN to cause router to drop packets, there's not much traffic left for other data as well. If they instead would use TCP with (optionally) low send/receive buffer and use O_NONBLOCK socket. When sending data if send() returns EAGAIN, simply ignore it. This approach still causes data being dropped when there's too much of it, but at the same time it minimizes amount of data in the network and plays nice with other services sharing the same routers. |
|