Game Server Development Series β€” Part 2: Networking Fundamentals

Learn TCP, UDP, WebSocket, gRPC, and custom binary protocols used by online games.

Networking is the communication layer between player clients and the game server.
It is the foundation that defines how fast, how reliable, and how scalable your online game can be.

This chapter introduces the most widely used networking models in modern game development:

  • TCP
  • UDP
  • WebSocket
  • gRPC
  • Custom binary protocols

Along the way, we discuss latency, reliability, packet handling, and real-world usage patterns.

1. Why Networking Matters in Multiplayer Games

Every time a player moves, shoots, crafts, chats, or interacts with the world, the client and server must exchange data.

Good networking ensures:

  • Low latency β†’ responsive gameplay
  • Reliability β†’ important data is never lost
  • Bandwidth efficiency β†’ works on mobile networks
  • Predictability β†’ consistent behavior
  • Fairness β†’ no client-side manipulation

Different types of games require different networking strategies.

flowchart LR
    Client([Player Client])
    Net((Networking Layer))
    Server((Game Server))

    Client --> Net --> Server
    Server --> Net --> Client

2. TCP vs UDP β€” The Core Transport Protocols

The two foundational transport protocols on the Internet are TCP and UDP.
Understanding their differences is crucial for choosing the right approach for your game.

3. TCP: Reliable, Ordered, Easy to Use

TCP guarantees:

  • Reliable delivery
  • Ordered delivery
  • Automatic congestion control
  • Automatic packet reassembly

This makes TCP perfect for:

  • Turn-based games
  • MMORPG & SLG backends
  • Chat systems
  • Marketplace / social systems
  • Login, authentication, HTTP APIs

But TCP is not ideal for real-time action games.

3.1 Why Real-Time Games Rarely Use TCP

TCP enforces ordering and reliability.
If one packet is lost:

  • All following packets get blocked
  • The connection stalls until retransmission arrives
  • This is called head-of-line blocking

For an FPS running at 60 ticks/sec, this creates lag spikes.

sequenceDiagram
    Client->>Server: Packet #1 (lost)
    Server--XClient: Packet #2 (blocked)
    Server--XClient: Packet #3 (blocked)
    Note over Client,Server: All later packets wait until #1 is retransmitted

Thus, TCP = great for important data, not ideal for fast gameplay.

4. UDP: Lightweight, Fast, and Perfect for Real-Time Games

UDP provides:

  • No guarantees
  • No ordering
  • No retransmission
  • Minimal overhead
  • Very fast delivery

Real-time games often send quick, frequent updates every 16–33ms.
If a packet is lost, it’s often better to just send the next update.

UDP is used by:

  • FPS (Valorant, CS2, Apex)
  • Racing games
  • Fighting games
  • Sports games
  • Competitive MOBA movement

4.1 UDP Benefits

  • Minimal latency
  • No blocking
  • Perfect for tick-based simulation
  • Developers can build custom reliability only when needed

4.2 But UDP is not enough alone

Developers must implement:

  • Custom packet formats
  • Checksums / integrity validation
  • Optional reliability layers
  • Sequencing for important events
  • Anti-cheat logic

This is why many high-end studios build custom UDP protocols.

5. WebSocket: Real-Time Networking for Browsers & Mobile

WebSocket is built on top of TCP but supports:

  • Full-duplex communication
  • Persistent connections
  • Event-driven messaging
  • Works in browsers and mobile

WebSocket is ideal for:

  • Casual multiplayer games
  • Turn-based and asynchronous games
  • Real-time cooperative games
  • Chat, social features
  • Mobile-friendly online experiences

5.1 Why WebSocket Works Well for Many Indie Games

Advantages:

  • Easy to integrate
  • Works everywhere (web, mobile, desktop)
  • Fits cloud deployment models
  • Easier than handling raw TCP sockets

Limitations:

  • Still has TCP’s head-of-line blocking
  • Not ideal for high-performance shooters
flowchart LR
    BrowserClient((Browser))
    WS([WebSocket])
    GameServer((Game Server))

    BrowserClient --WS--> WS --WS--> GameServer

If performance requirements are moderate β†’ WebSocket is usually the best choice.

6. gRPC: High-Performance RPC for Game Services

gRPC is built on HTTP/2 and Protocol Buffers.
It is not used for gameplay, but is foundational for game backend microservices.

6.1 gRPC is ideal for:

  • Matchmaking
  • Inventory & item services
  • Economy systems
  • Player profile services
  • Social services
  • Leaderboards
  • Admin tools and live operations

6.2 Why gRPC Works for Backend, Not Gameplay

Gameplay requires:

  • Minimal latency
  • Local prediction
  • High-frequency updates

gRPC is:

  • Request/response
  • Uses streams but still has TCP ordering
  • Slightly heavier than raw UDP

So gRPC = meta layer, not simulation layer.

7. Custom Binary Protocols (Used by AAA Games)

Many studios build proprietary binary protocols because they provide:

  • Smaller packet sizes
  • Faster parsing
  • Built-in compression
  • Security through obscurity (mild protection)
  • Custom reliability rules
  • Optimized bandwidth for low-end mobile networks

Examples include:

  • Overwatch NetCode
  • Riot’s custom UDP Layer
  • Unity Transport (MLAPI)
  • Unreal’s replication system

Binary protocols are often built on top of UDP, not TCP.

8. Choosing the Right Protocol for Your Game

Here’s a quick reference to help you decide:

Real-Time Shooter / MOBA / Racing:
    β†’ UDP (custom protocol + prediction)

Turn-Based / Strategy / Card Games:
    β†’ WebSocket or TCP

Mobile Casual Multiplayer:
    β†’ WebSocket

MMORPG / SLG Backend Services:
    β†’ TCP / HTTP / gRPC

Microservices Between Backend Components:
    β†’ gRPC or REST

Chat, Lobby, Social Features:
    β†’ WebSocket or TCP

More officially:

flowchart TB
    A[Game Type] --> B{Real-Time?}
    B -->|Yes| UDP
    B -->|No| C{Browser or Mobile?}
    C -->|Yes| WebSocket
    C -->|No| D{Backend Microservice?}
    D -->|Yes| gRPC
    D -->|No| TCP

9. Example Real-Time Network Flow (UDP)

sequenceDiagram
    Client->>Server: Input packet (move/shoot)
    Server->>Server: Validate + simulate
    Server->>Client: State delta update
    Client->>Client: Prediction + interpolation

This pattern enables fast and responsive gameplay even with packet loss.

10. Summary

You now understand the networking foundations of modern multiplayer gaming:

  • TCP β†’ reliable, ordered, best for meta systems
  • UDP β†’ fast, lightweight, ideal for real-time action
  • WebSocket β†’ easy, universal, great for casual & mobile
  • gRPC β†’ perfect for backend service-to-service communication
  • Custom protocols β†’ AAA studios optimizing performance

Choosing the right protocol shapes the entire design of your game server.

Keep Reading

Follow the engineering thread

Get the next practical Birdor note, or browse the archive for related systems, tooling, and architecture work.

Join newsletter Browse articles