Networking Fundamentals for System Design
Build the networking knowledge needed to reason about HTTP, DNS, TLS, load balancers, proxies, and connection behavior.
DNS, IP, TCP, and UDP
A browser typically resolves a hostname through DNS, obtains an IP address, and establishes a transport connection to a server. IP routes packets between networks. TCP provides an ordered, reliable byte stream; UDP provides datagrams without TCP's built-in delivery and ordering guarantees.
DNS caching reduces repeated lookups but means record changes are not instantly visible everywhere. TTL controls how long many resolvers may cache an answer, although actual behavior can vary. TCP connection setup and congestion control affect latency, especially across distant regions. Modern protocols may reuse connections to avoid repeated setup costs.
Think in layers: application behavior, transport connections, and network routing fail differently. A timeout might be caused by DNS, connection establishment, packet loss, server overload, or a slow downstream dependency. Observability should distinguish these phases where possible.
- DNS maps names to records; it does not guarantee the service is healthy.
- TCP offers reliable ordered delivery; UDP has different trade-offs.
- Connection reuse can reduce latency and resource overhead.
What does TLS primarily provide for a typical HTTPS connection?
HTTP, TLS, and API Semantics
HTTP defines request/response semantics. Methods such as GET, POST, PUT, PATCH, and DELETE communicate intent, while status codes distinguish success, client errors, and server failures. Idempotency matters during retries: repeating an idempotent operation should have the same intended effect as performing it once.
TLS protects data in transit and authenticates the server through certificates. It does not automatically encrypt data at rest or authorize a user to access a resource. Authentication establishes identity; authorization decides whether that identity may perform an action.
Use timeouts and explicit error responses. A client that waits indefinitely can exhaust its own connection pool and upstream capacity. For operations that create payments or orders, use idempotency keys or deduplication so a retry after an ambiguous timeout does not create duplicate effects.
POST /v1/payments HTTP/1.1
Host: api.example.com
Authorization: Bearer <access-token>
Idempotency-Key: order-8472-payment-attempt-1
Content-Type: application/json
{"orderId":"order-8472","amount":1299,"currency":"INR"}- A timeout does not prove that the server did not perform the operation.
- TLS, authentication, and authorization solve different problems.
- Design retries around idempotency and bounded timeouts.
Load Balancers, Reverse Proxies, and CDNs
A forward proxy acts on behalf of clients; a reverse proxy accepts requests for servers and forwards them to backends. A load balancer distributes traffic across healthy targets. These roles can overlap in one product but remain conceptually different.
Layer 4 balancing uses transport-level information such as IP addresses and ports. Layer 7 balancing can route using HTTP paths, hostnames, headers, cookies, or other application data. Health checks should test meaningful readiness, not merely whether a process has opened a port.
A content delivery network caches eligible assets near users. Cache-control headers determine whether content can be cached and for how long. Private or personalized responses require careful cache keys and directives; a misconfigured shared cache can leak one user's response to another.
- Reverse proxies centralize routing and edge concerns.
- Health checks need to reflect readiness accurately.
- Cache configuration is both a performance and data-isolation concern.