ExerciseDifficulty: Intermediate1 min

Practice: Choosing a Transport for Five Applications

A game's position updates, a file upload, a log shipper, a voice call and a payment; choose and say why.

Choosing a transport means asking what a late or lost packet costs each application. A team is designing five pieces of a new product and asks which transport each should use. For each, choose TCP or UDP and give the reason in one sentence.

  1. A multiplayer game sends every player's position to the others 20 times a second.
  2. Users upload photos of up to 20 MB.
  3. A log shipper sends every server's audit logs to a central store, where each line is kept for compliance.
  4. The product adds voice calls between users.
  5. A checkout service sends a payment request to a payment provider.
Show the answers
The transport for each application and the reason
ApplicationTransportReason
Game positionsUDPA newer position arrives 50 ms later, so a lost one is better skipped than waited for.
Photo uploadTCPA file with a missing piece is corrupt, and a short wait costs nothing.
Audit log shipperTCPEvery line must arrive, and logs are not time critical.
Voice callsUDPA late sound sample is useless, and waiting for it freezes the call.
Payment requestTCPA missing or reordered byte changes the request, and the cost of a delay is small.

The two UDP choices share one property: new data replaces old. Everything else needs every byte, so TCP's waiting is a price worth paying. Some log shippers do use UDP and accept loss, which is fine for debugging logs and wrong for logs kept for compliance.