High Frequency Trading - TCP> UDP?

I was told that for a high frequency trading (HFT) system that requires low latency, TCP is used over UDP. I was told that with TCP you can connect dots to dots while you cannot work with UDP, however from my understanding you can send UDP packets to a specific IP port.

This article has a few arguments as to why UDP> TCP is for games, but I see relevance for HFT.

Why should TCP be the best protocol to use in HFT?

(Admins: my previous post on this question was deleted without explanation without explanation. If I violate the terms of use, please warn me about this, and do not silently delete the question)

+4
source share
5 answers

UDP is superior to TCP if you do not need some of the features provided by TCP. Each function has a cost, and therefore, if you do not need functions, you pay this cost for no reason.

In an HFT application, you need almost every function required by TCP. Therefore, if you chose UDP, you will have to implement these functions yourself. This means that you will need to implement connection establishment, disconnections, retransmissions, baud rate, windows, etc.

If there was a way to do everything that was better than how TCP did it, TCP would do it that way. You would have one hand tied behind your back, because TCP is highly optimized by some of the best minds on the planet and implemented in / with the kernel.

+11
source

There is no reason to expect that data flow over an already established TCP connection will be slower than the same UDP data, plus you will receive checksums, retries, and all other TCP benefits. UDP generally benefits when you can afford to give up reliability or when the overhead of many TCP handshakes is too expensive, for example, with normal DNS queries.

+5
source

TCP is faster when using multiple connections. An important difference is that modern network adapters perform a significant amount of TCP acceleration, and in fact, not so much for UDP. This means that it takes more overhead to process each UDP packet and therefore cannot compete unless you need to send to multiple recipients at once.

However, the UDP multicast route is still experiencing the same problems as the unicast UDP for the datagram overhead. Therefore, many HFT systems use hardware accelerated systems that can multiplex streams in many network adapters via TCP, such as Solace.

These days, although you want to completely bypass the kernel, say, the stack of user IP spaces, such as Solarflare or Mellanox, or even skip both the kernel and the IP stack with RDMA.

+3
source

Simply put, if you need reliable connections (so that every byte of transmitted data is received), you must use TCP independently.

As you already mentioned, UDP is more suitable for games where 100% accurate real-time tracking for each object will use quite a lot of bandwidth and is not necessary (this means that slow connections encounter a delay).

There is not much difference between a TCP port and a UDP port, apart from the type of connection used (sending a packet and forgetting it, UDP style or negotiating a connection and supporting it, TCP style) and listening to the service on the server side. for example, usually TCP / 25 detects an SMTP server, while UDP / 25 will not.

+2
source

Basically, modern TCP implementations will be as fast as UDP if you support the connection. If TCP has to resend the packet, you also need to send it to UDP. In addition, for UDP, you are going to implement the same reliability code (retransmission of dropped packets) that TCP has already implemented.

+2
source

All Articles