CHAPTER 2
Networking and Communication Fundamentals
What happens between a click and a response, and how software services communicate.
Source: Chapter 2 PDF, pp. 1–10
Learning objective
Trace a request from browser to server, understand the basic networking terms, and choose a communication method that fits the problem.
Supplementary explanation
The problem
A page feels slow even though the server responds in 20 ms. The missing time is in DNS lookups, TCP and TLS handshakes, and extra round trips — before your code runs.
PDF page 11. What happens when you open a website? p. 1
You enter a website address and press Enter. Your device finds the destination, connects, sends a request and receives a response.
A website can feel slow even when its application code is fast. Time may be spent finding the server, setting up a secure connection, waiting for a busy service or reading data from storage.
PDF page 22. How does your browser find a server? p. 2
DNS (Domain Name System) helps translate a domain name, such as shop.example.com, into network information such as an IP address. Think of it like looking up a name in a contacts list.
DNS answers can be cached by the browser, operating system and DNS resolver. A record's TTL tells a cache how long the answer may be reused. Lowering a TTL after an outage does not immediately clear answers already cached under an older TTL.
| Record | Purpose | Example use |
|---|---|---|
| A / AAAA | Maps a name to an IPv4 / IPv6 address. | Find a server address. |
| CNAME | Points a hostname to another hostname. | Create a domain alias. |
| MX | Identifies mail servers. | Route email. |
| TXT | Stores text values. | Domain verification and SPF. |
| NS | Identifies authoritative name servers. | Delegate DNS management. |
IP address vs. port p. 2
PDF page 33. How do computers communicate? p. 3
TCP and UDP are two common transport protocols. They offer different guarantees and overhead.
| TCP | UDP | |
|---|---|---|
| Delivery | Retransmits lost data and provides an ordered byte stream. | Does not guarantee delivery or ordering. |
| Control | Provides flow and congestion control. | Minimal transport; the application adds features if needed. |
| Common uses | HTTP/1.1, HTTP/2, SSH, many database connections. | DNS queries, real-time media, QUIC. |
How TCP starts a connection p. 3
For HTTPS over TCP, a TLS handshake typically follows unless an existing connection can be reused. TLS establishes encryption and authenticates the server.
PDF page 44. How does a browser ask a server for something? p. 4
HTTP defines how clients and servers exchange requests and responses. A request includes a method and path; the response includes a status code and may include data.
HTTP versions p. 4
| Version | What improves | Important limitation |
|---|---|---|
| HTTP/1.1 | Persistent connections; commonly uses multiple connections for concurrency. | Requests can be delayed behind other requests on a connection. |
| HTTP/2 | Multiple streams over one TCP connection; compressed headers. | TCP packet loss can delay all streams on that connection. |
| HTTP/3 | Uses QUIC; streams have independent loss recovery. | Cannot eliminate slow networks or slow application processing. |
Common HTTP methods p. 4
| Method | Typical purpose | Example |
|---|---|---|
| GET | Read information. | View a product. |
| POST | Submit data or trigger an action. | Place an order. |
| PUT | Create or replace a resource at a known URI. | Replace an address. |
| PATCH | Update part of a resource. | Change a phone number. |
| DELETE | Delete a resource. | Remove a saved address. |
Idempotency: repeating an operation has the same intended effect as performing it once. GET, PUT and DELETE are defined as idempotent methods. POST is not generally idempotent; payment APIs often use idempotency keys to prevent duplicate charges on retries.
PDF page 5HTTP status codes and caching p. 5
| Code range | Meaning | Examples |
|---|---|---|
| 2xx | Success | 200 OK, 201 Created, 202 Accepted |
| 3xx | Redirect or cache-related response | 301, 304 Not Modified |
| 4xx | Client request or access problem | 400, 401, 403, 404, 429 |
| 5xx | Server or upstream failure | 500, 502, 503, 504 |
A 202 Accepted means processing has been accepted, not necessarily completed.
HTTP caching p. 5
A cache reuses a saved copy when the rules allow it. If the copy might be old, the browser can ask whether the resource has changed.
Useful headers include Cache-Control (freshness and privacy rules), ETag and If-None-Match (conditional requests), and Last-Modified. Cookies can store session-related information; attributes such as HttpOnly, Secure and SameSite help control how cookies are used. CORS is a browser security policy for cross-origin requests.
PDF page 65. How do services communicate with each other? p. 6
A product may have separate order, payment and notification services. Some work needs an immediate result; other work can happen later.
Common options p. 6
| Pattern | Simple explanation | Common use |
|---|---|---|
| REST | HTTP requests and responses, often using JSON. | Public APIs and CRUD operations. |
| GraphQL | Client requests specific data fields. | Clients with varied data needs. |
| gRPC | Typed service communication, often using Protobuf. | Internal service calls and streaming. |
| Queue / pub-sub | Messages or events are handled asynchronously. | Notifications, background processing, event-driven systems. |
Serialization: how data is represented p. 6
Services must agree on a data format. JSON is readable and common for web APIs. Protocol Buffers is a compact, schema-based binary format often used with gRPC. Avro is common in event streams, while Parquet and ORC are columnar formats for analytics storage. Choose based on readability, message size, schema evolution, compatibility and tooling; no format is best for every workload.
PDF page 76. How does an app receive live updates? p. 7
A chat app or dashboard may need fresh data without asking the user to refresh the page. Several patterns are available.
Compare the options p. 7
| Pattern | How it works | Typical use |
|---|---|---|
| Short polling | Client asks for updates at intervals. | Rarely changing data. |
| Long polling | Server waits until an update or timeout before replying. | Updates when streaming is not needed or available. |
| SSE | Server streams events to the client over HTTP. | Dashboards, notifications, LLM token streaming. |
| WebSockets | Client and server exchange messages in both directions over a persistent connection. | Chat, collaboration and multiplayer games. |
Other examples: APNs and FCM are commonly used to deliver mobile notifications. WebRTC supports real-time audio, video and data, using connectivity techniques such as STUN and TURN.
PDF page 87. How do we make websites faster? p. 8
A CDN (Content Delivery Network) stores reusable content at locations closer to users. When a copy is available and fresh, the request may not need to travel to the original server.
A cache can return content locally; on a miss, the origin is contacted.
Other network components p. 8
Illustrative request path. Real deployments may combine or reorder these responsibilities.
| Illustrative Component | request path. Real deployments may combine or reorder these responsibilities. What it does |
|---|---|
| Forward proxy | Acts on behalf of clients, for example for corporate internet access. |
| Reverse proxy | Receives requests before application servers; can route traffic or terminate TLS. |
| Load balancer | Distributes requests across multiple servers. |
| API gateway | Adds API controls such as authentication, rate limits, routing and versioning. |
| CDN | Serves cached content from distributed locations closer to users. |
PDF page 98. What this means for a product or program manager p. 9
When a page is slow, do not assume the application code is the cause. Measure the full journey and find the largest delay first.
| Check | Question to ask |
|---|---|
| DNS and connection | Was there a lookup or new connection handshake? |
| CDN / proxy / network | Was content cached? Were requests delayed on the route? |
| Application | Was the service busy or waiting for another service? |
| Database | Was the query slow or the database saturated? |
Chapter recap p. 9
- DNS helps your device find the destination; caching affects lookup and failover.
- TCP and UDP offer different transport guarantees. QUIC uses UDP and adds transport features for HTTP/3.
- HTTP defines client-server requests and responses; versions differ in connection handling.
- REST, GraphQL, gRPC and queues serve different communication needs.
- Polling, SSE and WebSockets offer different approaches to live updates.
- Caches, proxies, load balancers and CDNs help manage traffic and reduce delays.
PDF page 109. Check your understanding p. 10
Choose an answer for each question, then check the answer key at the end.
1. A new TCP connection plus a full TLS 1.3 handshake typically needs how many round trips before an HTTPS request can be sent?
- A. 0
- B. About 2
- C. About 5
2. Which transport does HTTP/3 use?
- A. TCP
- B. UDP through QUIC
- C. ICMP
3. You lower a DNS record TTL during an outage. Why might clients still use the old address temporarily?
- A. DNS ignores TTL
- B. Some clients or resolvers still have an answer cached under the previous TTL
- C. TCP permanently stores DNS answers
4. Which pattern best suits frequent two-way chat messages?
- A. Short polling only
- B. WebSockets
- C. A static CDN response
5. A page is slow although its application handler takes only 20 ms. What should you do first?
- A. Add application servers immediately
- B. Measure DNS, network, connection, queueing and downstream delays
- C. Shard the database immediately
Answer key and explanations
- B. One TCP handshake RTT plus one full TLS 1.3 handshake RTT, ignoring DNS and other delays.
- B. HTTP/3 runs over QUIC, which uses UDP.
- B. Lowering a TTL does not retroactively remove answers already cached.
- B. WebSockets support persistent, bidirectional communication.
- B. Measure end-to-end timing to identify the dominant source of latency before selecting a fix.
Program / product lens Supplementary
Network round trips dominate user-perceived latency for global users; region placement and CDN decisions are product decisions with cost implications.
Recap
- Every hop (DNS, CDN, LB, app, cache, DB) adds latency and a failure mode; caches short-circuit the path.
- TCP + TLS 1.3 costs about two round trips before the first request byte; HTTP/3 (QUIC) reduces this.
- DNS answers are cached per TTL, which also delays failover.
- Pick the simplest real-time mechanism that meets the latency need.
Check your understanding
1. Roughly how many round trips does a new TCP + TLS 1.3 connection need before the first HTTP request byte?
2. Which transport is used by QUIC (HTTP/3)?
3. You lowered a DNS record's TTL after an outage began. Why might clients still hit the old IP?
Try it
References
Chapter 2 PDF, pp. 1–10; figures 1, 2, 3, 4, 5, 6, 7, 8.
Tip: use ← and → keys to move between chapters.