Study Index
Core Concepts  ·  System Design in a Hurry

Networking
Essentials

The parts of networking that actually show up in system design interviews — protocols, load balancing, and the failure modes that bite you at 3 a.m.

OSI L3 · L4 · L7 TCP / UDP / QUIC HTTP · gRPC · WS · WebRTC Load Balancing Fault Tolerance
01 — FUNDAMENTALS

Networking 101

At its core, networking is about connecting devices and letting them communicate. Systems are nearly always built from independent devices talking over a network.

Networks use a layered architecture (the OSI model) that greatly simplifies life for application developers sitting on top. Each layer is an abstraction: when you request a webpage you don't care which voltages represent a 1 or a 0 on the wire — you just use the next layer down. It's like calling open() instead of instructing the disk how to read bytes.

Who's tested on this? Networking is a stronger focus in infrastructure and distributed-systems interviews. For full-stack and product roles you mostly need surface understanding — but if your interviewer just got off an on-call rotation fighting load balancers, be ready for probes.
02 — THE STACK

Networking Layers

The full stack is fascinating, but three layers come up most in interviews. Hover a layer to lift it.

7APPLICATION
Application Layer

Application protocols that abstract data for web apps. Built on TCP (or UDP, for WebRTC). Processed in User Space — flexible, easy to modify.

DNSHTTP/SWebSocketsWebRTCgRPC
4TRANSPORT
Transport Layer

End-to-end communication services — reliability, ordering, flow control — layered on top of the network layer. Processed in Kernel Space (hard to change, very efficient).

TCPUDPQUIC
3NETWORK
Network Layer

IP handles routing and addressing — breaking data into packets, forwarding between networks, and best-effort delivery to any destination IP.

IPInfiniBand (ML)

These layers work together to enable every network communication. The higher up the stack you go, the more latency and processing is required — a fact that matters directly for the load-balancer discussion later.

03 — END TO END

A Simple Web Request

Type a URL and several layers spring into action. Here's a plain HTTP-over-TCP page load, start to finish.

DNS Resolution

Resolve the domain (e.g. hellointerview.com) to an IP like 32.42.52.62.

TCP Handshake (three-way)

SYN → client requests connection · SYN-ACK → server acknowledges · ACK → client confirms, connection established.

HTTP Request

Client sends an HTTP GET for the page.

Server Processing

Server builds the response. (Usually the only latency most engineers think about and control.)

HTTP Response

Server returns the page content.

TCP Teardown (four-way)

FIN → ACK → FIN → ACK. Both sides close their half of the connection.

Takeaway 1

Application code can take reliability and ordering for granted — TCP delivers data correctly, in order, and tells the app if it can't.

Takeaway 2

One conceptual "request" hides many packets and round trips. Each adds latency you ignore until you can't.

Takeaway 3

The connection is shared state. Without keep-alive or HTTP/2 multiplexing, you repeat setup for every request — real overhead for persistent-connection systems.

04 — NETWORK LAYER

IP: Routing & Addressing

The network layer is dominated by IP. Nodes get IPs (usually from a DHCP server) at boot. These addresses are arbitrary — they only mean something because we advertise them.

You can build a private network with any IPs you like, but for internet traffic to find your servers you need public IPs that are routable and allocated by a RIR. Internet routing infrastructure is optimized to find public IPs.

Fun fact: any address starting with 17 (e.g. 17.0.0.0) belongs to Apple — the internet backbone knows to route those packets straight to their routers.
05 — TRANSPORT LAYER

TCP vs. UDP

The transport layer gives you guarantees instead of a jumbled pile of packets. The three protocols are TCP, UDP, and QUIC — but the real interview choice is TCP vs. UDP. Treat QUIC as "a better TCP" without the broad adoption baseline.

UDP

Fast but Unreliable

The machine-gun of protocols — "spray and pray." Connectionless, minimal features over IP, very fast. You see source/destination IP+port; everything else is a binary blob.

  • Connectionless — no handshake
  • No delivery guarantee — packets can vanish silently
  • No ordering — packets may arrive out of order
  • Lower latency — less overhead, faster

Perfect when speed beats reliability: live video, gaming, VoIP, DNS lookups. A dropped VoIP packet is just a hiccup — far better than clogging the network with retransmits and ACKs.

TCP

Reliable but with Overhead

The workhorse of the internet. Reliable, ordered, error-checked delivery over a three-way-handshake connection — a stateful stream. Unacknowledged messages get retransmitted.

  • Connection-oriented — dedicated connection first
  • Reliable delivery — in order, without errors
  • Flow control — won't overwhelm receivers
  • Congestion control — adapts to avoid collapse

Ideal where data integrity matters — i.e. basically everything UDP isn't a good fit for.

When to Choose Each

Interviewers assume TCP by default — it often doesn't even need mentioning. You earn points by making the case for UDP and getting the details right. Reach for UDP when:

Modern apps often use both: a video-conferencing app uses TCP/HTTP for signaling & auth and UDP/WebRTC for the actual audio/video. Browsers don't widely support UDP outside WebRTC — plan a fallback (e.g. app users get a UDP reaction stream, browser users get a batched HTTP stream spread out in the UI).

TCP vs. UDP — Quick Reference

Feature UDP TCP
Connection Connectionless Connection-oriented
Reliability Best-effort Guaranteed
Ordering No guarantee Maintains order
Flow Control No Yes
Congestion Control No Yes
Header Size 8 bytes 20–60 bytes
Speed Faster Slower (overhead)
Use Cases Streaming, gaming, VoIP Everything else
06 — APPLICATION LAYER

HTTP / HTTPS

HTTP is the de-facto standard for web data: a request-response protocol. It's stateless — each request is independent, the server holds nothing about prior requests. That's good: minimize stateful surface area. Most simple HTTP servers are just a function of the request params.

Common Request Methods

  • GET — read; idempotent, no body
  • POST — send data to server
  • PUT — update a resource
  • PATCH — partial update
  • DELETE — remove; idempotent

Anatomy of a Request

  • Method · Status code · Headers (metadata) · Body (content)

Common Status Codes

  • 2xx Success — 200 OK · 201 Created
  • 3xx Moved — 301 Permanent · 302 Found
  • 4xx Client — 401 Unauthorized · 403 Forbidden · 404 Not Found · 429 Too Many Requests
  • 5xx Server — 500 Error · 502 Bad Gateway

Headers are flexible key/value pairs — a great lesson in interface design for unknown future use-cases. Content negotiation is the classic case: a client sends Accept-Encoding: gzip, br, the server replies with Content-Encoding: br if available — backward compatibility plus graceful degradation.

HTTPS adds a TLS/SSL security layer, encrypting traffic against eavesdropping and man-in-the-middle attacks. Public website? Use HTTPS without exception.
Encrypted ≠ trustworthy. HTTPS protects contents in transit but does not prove who generated them. Never trust the request body without validating. Putting a user ID in the body and using it for a DB call lets an attacker swap the ID and read arbitrary user data. Validate everything server-side; don't ask for anything you can't trust.
07 — API PARADIGMS

REST · GraphQL · gRPC

REST — Simple & Flexible

The most common paradigm in interviews. The core idea: clients perform operations against resources (think database tables or files). REST leans on HTTP verbs plus conventions for paths and bodies, usually with JSON. Your Core Entities often map directly to resources.

# Read a user
GET /users/{id} -> User

# Update an existing user
PUT /users/{id} -> User
{ "username": "john.doe", "email": "john.doe@example.com" }

# Create (server assigns the id)
POST /users -> User
{ "username": "stefan.mai", "email": "stefan@hellointerview.com" }

# Nested resources for relationships
GET /users/{id}/posts -> [Post]
Think resources, not operations. updateUser becomes PUT /users/{id}; startGame becomes PATCH /games with {"status":"started"}. REST is the default for interviews — reach for alternatives only when REST can't meet a specific need. JSON is inefficient to (de)serialize, but most apps aren't bottlenecked there.

GraphQL — Flexible Data Fetching

Open-sourced by Facebook (~2015). It lets the frontend request exactly the data it needs, solving two problems with REST:

Under-fetching

Page needs many requests / round trips — extra overhead and latency on load.

Over-fetching

Responses pack far more than needed to guard against future cases — slow and bloated.

query GetUsersWithProfilesAndGroups($limit: Int = 10, $offset: Int = 0) {
  users(limit: $limit, offset: $offset) {
    id
    username
    profile { id fullName avatar }
    groups { id name description category { id name icon } }
    status { isActive lastActiveAt }
  }
  _metadata { totalCount hasNextPage }
}

The query names the fields and nested objects; the backend responds in exactly that shape. Sweet spot: complex clients and multiple teams making wide queries over overlapping data — where the frontend needs to iterate fast.

For interviews, benefits are murky. You'll have fixed requirements (not moving targets), and interviewers often want to see query-pattern optimization — where GraphQL frequently gets in the way. Bring it up when the problem is explicitly about flexibility or deliberately uncertain requirements.

gRPC — Efficient Service Communication

A high-performance RPC framework from Google using HTTP/2 and Protocol Buffers — like JSON but with a rigid schema for better performance and serialization.

message User {
  string id = 1;
  string name = 2;
}

service UserService {
  rpc GetUser (GetUserRequest) returns (GetUserResponse);
}

A chunky JSON object (~40 bytes) becomes a skinny binary encoding (~15 bytes) — less space, less CPU to parse:

{ "id": "123", "name": "John Doe" }   // ~40 bytes JSON
0A 03 31 32 33 12 08 6A 6F 68 6E ... // ~15 bytes protobuf

Definitions compile into client + server stubs across many languages. gRPC ships streaming, deadlines, client-side load balancing, and more — built for microservices at scale. Some benchmarks show ~10× throughput over JSON-over-HTTP.

Recommendation: use REST for public-facing APIs and gRPC for internal service-to-service — especially with binary data or performance-critical paths. gRPC tooling is less mature and no browser supports it today. In many interviews, REST for both is fine. Don't hyper-optimize your RPC protocol before handling bigger bottlenecks — premature optimization is the root of all evil.
08 — REAL-TIME

SSE · WebSockets · WebRTC

Server-Sent Events (SSE) — Push over HTTP

A spec on top of HTTP that lets a server stream many messages over a single HTTP response. Normal HTTP gives one cohesive JSON blob you process once fully received — useless for push. SSE sends chunks:

data: {"id": 1, "timestamp": "2025-01-01T00:00:00Z", "description": "Event 1"}
data: {"id": 2, "timestamp": "2025-01-01T00:00:01Z", "description": "Event 2"}
data: {"id": 100, ...}

Each line is a separate message the client processes as it arrives (one TCP connection, many small packets).

Acute limitations. Connections can't stay open forever — servers, load balancers, and middle-box proxies close them. The EventSource object auto-reconnects with the ID of the last message received, and servers are expected to resend anything missed. Some misbehaving networks batch all SSE responses into one — recreating the exact problem you were avoiding. Most interviewers don't know these; people who've actually shipped SSE do.

Where to use: notifications/events as soon as they happen — e.g. keeping bidders updated on an auction's current price.

WebSockets — Bidirectional & Persistent

A persistent, TCP-style connection enabling real-time, bidirectional communication with broad support (browsers included). Both sides push without waiting for a request. Initiated via an HTTP "upgrade" so you can reuse existing session info (cookies, headers).

  1. Client initiates a WebSocket handshake over HTTP (backed by a TCP connection)
  2. Connection upgrades to the WebSocket protocol, taking over the TCP connection
  3. Both client and server send binary messages over the connection
  4. The connection stays open until explicitly closed

WebSockets don't dictate an application protocol — you have a binary channel and define your own messages (serialized JSON is a great option).

Infra must cooperate. Every firewall, proxy, and load balancer between client and server must support WebSocket connections. Don't launch into a WebSocket design without justifying it — stateful connections at scale are expensive and force accommodations. Use them only for high-frequency, persistent, bi-directional needs (real-time apps, games). Otherwise SSE or plain request/response is enough.

WebRTC — Peer-to-Peer

The most unusual protocol — direct peer-to-peer communication between browsers, no intermediary server for the data exchange. The only app-level protocol here that uses UDP. Great for video/audio calling and conferencing.

P2P is harder than client-server because most clients block inbound connections and sit behind a NAT. WebRTC works around this:

STUN

Session Traversal Utilities for NAT. Techniques like "hole punching" that let peers discover publicly routable addresses/ports, shared via the signaling server.

TURN

Traversal Using Relays around NAT. A relay service that bounces traffic through a central server when a direct connection fails.

  1. Clients connect to a central signaling server to learn about peers
  2. Clients hit a STUN server to get their public IP and port
  3. Clients exchange that info via the signaling server
  4. Clients establish a direct P2P connection and start sending data (TURN relay as fallback)
Niche and painful. Even the best implementations suffer connection losses. Most problems don't need P2P, and candidates go off the rails trying to force it. Stick to WebRTC for video/audio calling and conferencing and you'll be in good shape. (Google Docs-style editors usually use WebSockets + a central server instead — though WebRTC + CRDTs is a true-P2P alternative.)
09 — SCALING

Load Balancing

To scale you go vertical (bigger servers) or horizontal (more servers). Modern hardware is powerful, so vertical scaling goes further than people think — but in interviews, horizontal scaling is the common pattern. Adding boxes only helps if clients know which server to talk to. Enter load balancing.

Client-Side Load Balancing

The client picks the server, usually after pulling a list from a service registry/directory and periodically syncing. Fast and efficient — no extra network hop per request, only periodic sync.

Example · Redis Cluster

Nodes gossip to share cluster membership and status. The client hashes the key to find the shard, then uses locally cached node info to pick the node. Wrong node? Redis replies MOVED.

Example · DNS

The resolver returns a rotated list of IPs per request, so clients hit different servers — load balancing for free. Run two LBs in different regions and rotate via DNS to avoid a single point of failure.

When to use: (1) a small number of clients you control (Redis client, gRPC's built-in client-side LB), or (2) many clients where slow updates are tolerable (DNS — bounded by TTL). Works remarkably well for internal microservices.

Dedicated Load Balancers

When clients shouldn't know about multiple backends, or you have many uncontrolled clients needing fast updates, use a dedicated LB sitting between client and servers. It adds a hop but gives fast server-list updates and fine-grained routing control.

Layer 4

Transport-Layer LB

Routes on IP + port without inspecting packet content. Effectively a direct TCP connection between client and a randomly-selected backend.

  • Maintains persistent TCP connections
  • Fast & efficient (minimal inspection)
  • Can't route on application data
  • Used when raw performance is the priority

Use for: WebSockets and other protocols needing persistent connections; high-performance, low-processing traffic.

Layer 7

Application-Layer LB

Understands HTTP and inspects request content for smarter routing. Terminates incoming connections and opens new ones to backends.

  • Routes on URL, headers, cookies
  • More CPU-intensive (inspection)
  • More flexibility & features
  • Better for HTTP-based traffic

Use for: HTTP traffic — API vs. web routing (like an API Gateway), sticky sessions by cookie, long polling.

Rule of thumb: WebSockets → L4; everything else → L7. (Some L7 LBs do support WebSockets, but generally L4 wins for persistent connections.)

Health Checks & Fault Tolerance

LBs also monitor backend health and stop routing to a crashed server until it recovers — automatic failover, the basis of high availability. A TCP health check simply confirms the server accepts connections; an L7 health check makes an HTTP request and verifies a success code (200 vs. 500 or no response).

Load Balancing Algorithms

Algorithm How it distributes
Round Robin Sequentially across servers
Random Randomly across servers
Least Connections To the server with fewest active connections
Least Response Time To the fastest-responding server
IP Hash Client IP picks the server (session persistence)

Round robin / random suit stateless apps and naturally absorb new servers. For persistent connections (SSE, WebSockets), prefer Least Connections so one server doesn't slowly hoard every active connection.

Hardware

F5 Networks BIG-IP — physical devices, can scale to 100s of millions of req/s.

Software

HAProxy, NGINX, Envoy — more limited throughput.

Cloud

AWS ELB/ALB/NLB, Google Cloud LB, Azure Load Balancer.

10 — DEEP DIVE

Regionalization & Latency

Global services distribute servers worldwide. A common pattern: multiple data centers per region (Amazon's "availability zones") so one building's failure doesn't take you down, replicated across cities.

Physics is the ceiling. Light in fiber travels ~200,000 km/s (~⅔ of c). A New York ↔ London round trip (~5,600 km) has a theoretical minimum of ~56 ms before any processing — vs. <1 ms to a nearby server. Geographic distribution is essential for low latency.

The fix is data locality: keep the data needed to satisfy a query close together and close to the user. Some latency is unavoidable when users are simply far apart, but two strategies help.

Content Delivery Networks

Networks of servers in hundreds/thousands of cities ("edge locations"). If the edge can answer a request, response times are lightning-fast — the data is "just up the road." Works because of caching: data that changes rarely (images, video, static assets) is cached at the edge.

In interviews, use CDNs for highly cacheable data queried globally — e.g. caching search results to cut latency and backend load.

Regional Partitioning

Partition data by region so each region holds only what's relevant. Uber: a Miami rider never books a New York driver. Bundle nearby cities into a local region, give each its own database and co-located servers. Queries are answered regionally (fast) against a local DB (very fast).

11 — FAULT TOLERANCE

Handling Failures

Servers crash, bits flip from solar flares, power is cut — and networks fail too: cables get cut, routers die, packets drop. Robust design plans for all of it.

"The network is reliable" is a dangerous fallacy. Always design expecting calls to fail, be delayed, or return unexpected results.

Timeouts & Retries with Backoff

The most basic hygiene: set a timeout, and retry if a request takes too long. Retries handle transient failures well — a temporarily slow server often succeeds on retry. Idempotent APIs are key so retries don't cause harm.

But retries are double-edged: hammering a failing system makes things worse. Add backoff — wait longer between each attempt — to give the system room to recover. Add jitter (randomness) so clients don't synchronize into a jackhammer of simultaneous retries.

The magic phrase interviewers want: "retry with exponential backoff." In senior interviews, be ready to add jitter.

Idempotency

Retries with side effects are dangerous — retrying a $10 charge could bill the user $20 or $2,000. Idempotent APIs produce the same result no matter how many times they're called. Reads (GET) are naturally idempotent; for writes, use an idempotency key — a unique request identifier.

For a payment where a user buys one item per day, set the key to userID + date. The server checks whether it has already processed (or is processing) that key and runs it once. Friendly APIs wait and return the result to all callers; less-friendly ones error that the request already exists — either way, no double charge.

Circuit Breakers

The defense against cascading failures. If a database goes cold and must boot one instance at a time, a firehose of retries (a "thundering herd") can pin every instance and prevent recovery. A circuit breaker protects against this:

  1. Monitor failures when calling an external service
  2. When failures exceed a threshold, the circuit trips open
  3. While open, requests fail immediately without making the call
  4. After a timeout, the circuit goes half-open
  5. A test request decides whether to close the circuit or keep it open

Fail Fast

Reject calls to failing services instead of waiting for timeouts.

Reduce Load

Stop overwhelming a struggling service with more requests.

Self-Healing

Automatically test recovery without full traffic.

Apply at: external/third-party API calls, database connections & queries, service-to-service calls in microservices, resource-intensive operations, and any network call that could fail or slow down. A great answer when an interviewer deep-dives on reliability, failure modes, or disaster recovery.

12 — RECAP

Wrapping Up

Networking is the foundation connecting every component in a distributed system. The field is vast, but these four areas cover most interviews:

1 · Basics

IP addressing, DNS, and the TCP/IP model.

2 · Protocols

TCP vs. UDP, HTTP/HTTPS, WebSockets, gRPC.

3 · Load Balancing

Client-side LB and dedicated L4/L7 load balancers.

4 · Practical Realities

Regionalization, CDNs, and failure-handling patterns.

Networking choices ripple into latency, throughput, reliability, and security. In interviews, justify your choices against the specific requirements — there's rarely one right answer, and interviewers want to see how you reason about tradeoffs.

Test Yourself

1. Which protocol would you choose for VoIP / live video, where a dropped packet is acceptable?
2. You need a persistent WebSocket connection to stay pinned to one backend server. Which load balancer?
3. What's the phrase interviewers look for when handling transient request failures?
4. Which prevents a "thundering herd" from stopping a struggling service from recovering?
5. WebRTC is the only application-layer protocol here that runs over…

Score: 0 / 5