← Back to Computer Fundamentals

TCP and UDP in Online Gaming

Online games mix UDP and TCP to match latency and reliability needs.

Computer FundamentalsNetworkingProtocols

Online games use both UDP and TCP, but fast multiplayer games usually rely on UDP for the latency critical parts of gameplay. The reason is not that UDP is universally better. It is that games often care more about timeliness than perfect delivery. If a player's position update arrives too late, receiving it reliably is less valuable than getting the next, newer position quickly.

TCP guarantees ordered delivery and retransmits lost packets automatically. That is excellent for web pages, file downloads, login flows, and anything where every byte must arrive correctly. The downside is that lost packets can stall later data until the missing piece is retransmitted. For a first person shooter, racing game, or sports game, that delay can feel worse than a small amount of loss because the world state keeps changing while the client waits.

UDP is connectionless and does not provide built in reliability, ordering, or congestion handling in the same way. That sounds primitive, but it gives game developers control. They can decide which messages must be reliable, which can be dropped, and which newer updates should overwrite older ones. Position snapshots, aim direction, or rapidly changing physics state are often sent over UDP because the newest packet matters most. Critical events such as match start, inventory changes, or purchase confirmations may be handled with custom acknowledgements on top of UDP or through separate reliable channels.

Many real games therefore use a hybrid model. TCP may handle account login, chat history, patching, and store transactions. UDP carries the real time simulation traffic. Some engines implement a "reliable UDP" layer that adds acknowledgements, sequencing, and selective retransmission only for specific message types instead of forcing every message through TCP style ordering.

There are tradeoffs. Because UDP gives the application more responsibility, developers must implement correctness features themselves: packet sequencing, rate control, prediction, reconciliation, and anti abuse measures. Games also have to cope with NAT traversal, jitter, and varying network quality across home routers and mobile networks. The networking model is tightly linked to game design. A turn based game can tolerate much more delay than a twitch shooter.

Another subtle point is that the protocol decision is only part of the latency story. Tick rate, server authority, interpolation, lag compensation, and regional matchmaking all matter. A badly designed game over UDP can feel worse than a well designed slower paced game over TCP.

So the right answer is not simply "games use UDP". The better answer is that online games choose transport based on what the player action needs. Real time state updates usually favour UDP because late data is almost as bad as lost data. Reliable account and transactional flows often favour TCP because correctness matters more than immediacy. Good multiplayer networking comes from matching the delivery semantics to the kind of game data being sent.