4 ms·
I couldn't agree more. TCP is wonderful when you need it, but you very often don't need it (and pay a heavy price for features you don't need). I wouldn't want
by kstrauser 12y ago
I couldn't agree more. TCP is wonderful when you need it, but you very often don't need it (and pay a heavy price for features you don't need).
I wouldn't want to write HTTP over UDP, but neither would I want to send telemetry data ('{"timestamp":343821902, "value": 43}') over TCP. UDP is brilliant for systems where you're more concerned about tracking the current state of things than accurately replaying the last n set of transactions.
- mholt 12y agoWell, there's QUIC, which serves HTTP over UDP. But I see your point, and you're correct. TCP and UDP have different advantages (at least for now).
- dtech 12y agoHowever, QUIC provides a lot of the features TCP has but very fine-tuned for HTTP. This is fine, HTTP is probably the largest layer 7 protocol on the internet, but if you were to design a layer 7 protocol that needed a lot of the features that TCP provides it would be quite dump to reimplement them yourself on top of UDP.
- lechuga 12y agoDisagree. In most cases you want TCP. Rarely do applications gracefully deal with loss.
- kstrauser 12y agoThat's completely dependent on the application. SNMP over TCP would be a net loss because 1) it doesn't buy you anything as SNMP doesn't have any requirements that TCP meets above what UDP provides, 2) TCP would be exceedingly expensive, requiring connection buildup and teardown, ACKs, etc., and 3) it's way easier to implement UDP than TCP, so dumb devices basically need to only construct a single Ethernet frame to make it work. Many, many applications deal much better with loss than they do with delayed retries. You don't want a VOIP app to perfectly recreate what the other part said 30 seconds ago, games usually only care about current state, and so on. In many of those cases, TCP is the wrong choice but a lot of people use it out of familiarity. Remember, UDP came after TCP. One isn't "better" than the other and they serve different requirements.
- lechuga 12y agoYes. You can show me a relative corner case. But in most cases you want TCP.
- fla 12y agoSimple example: Player positions in a FPS. Would you rather wait for a transmission of the missing position update 1 sec ago or just forget about it and continue processing the next one ? In this context, you'll prefer the second option. It will probably cause a visual glitch but the game can go on, and players will say "lag" :)
- lechuga 12y agoYes. You can show me a relative corner case. But in most cases you want TCP.
- fla 12y agoIt's far from being a corner case. UDP is commonly used in multiplayer games to provide a channel for unreliable data.
- kstenerud 12y agoIf you want to go with that argument, why not go all the way and say that the common case is HTTP and the corner cases are everything else? It still won't change the fact that application needs won't always match TCP exactly. And that's the whole point.
- rjsw 12y agoIsn't that kind of use case what DCCP was designed for ?
- KaiserPro 12y agoWhy you want TCP: you care about the data, you want it to arrive in order, and you need it arrive. You want to be notified if there is a problem at the other end. You want the data sent to match exactly the data delivered. File transfer, simple protocols, advanced critical protocols. Anything where the dev doesn't want to think about how to account for packet loss. Its already done for you in a standard interface. Why you want UDP: You want the latest packet of data, and you want it now. it doesn't matter if you lose a few packets. Telephony is the classic example. if you loose a frame its not the end of the world. Streaming video is another, Use FEC to cope with loss. Tedious real world analogy: When you send a letter or a parcel, you have two options: Send it recorded, and pay slightly more per go, but not have the worry about phoning up the recipient to see if they received it. However if the letter is of little worth (like a flyer or something similar) then the notification and or guarantee that it has/will arrive is a pointless cost.
- lechuga 12y agoI'm intimately familiar with cases where you actually would prefer to use UDP. My point is most of the time these cases aren't what you're dealing with. In addition to reliability, TCP provides congestion control which provides approximate fairness of bandwidth utilization per connection. Fairness here meaning given a limited pipe of size W each connection gets a W/N slice of the pipe's available bandwidth. I don't know that I'd like to live on an internet where every hipster made their own decision about how to handle congestion control, see also congestive collapse.
- dtech 12y ago> My point is most of the time these cases aren't what you're dealing with Which is why the "default" protocol for most things is still TCP.
- KaiserPro 12y ago>every hipster made their own decision about how to handle congestion control Unless they had access to a tier 1/2 network provider it'd be mostly harmless I suspect. They'd spam their local gateway. "Look I can send 300k packets a second over standard DSL" But yes, TCP is generally a good thing.
- vacri 12y agoIP telephony and video streaming are hardly rare applications.
- tetha 12y agoInteresting. I wouldn't want to shove my base monitoring data over UDP. Without my base monitoring, our product devs are blind and things go to shit. I can't risk that. And, with a bunch of per-site monitoring frontends with batching, compression and deduplication, thrift/protobuf and long-running connections, the TCP overhead is meh.
- vidarh 12y agoIf your network is so about to fall apart under load, or so broken due to network issues, or your servers are so overloaded that you start seeing appreciable packet loss with UDP internally at a site, then chances are the last thing you want is loading your system even more and slowing things down by retransmitting samples that are obsolete in a couple of seconds anyway.... Serious exceptions, sure, retry. But serious exceptions are rare. What's not rare is sampled memory usage, cpu usage etc..
- deleted 12y ago[deleted]
- rkangel 12y agoSure, you can't cope without monitoring. But you can absolutely cope if 1 out of 10 of each of those status updates doesn't get to you. This is the completely standard connection-oriented vs connectionless link tradeoff.