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.

Core PDF content

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.

Figure 1. A simplified request path. Some steps can be skipped when connections or responses are cached. · PDF p. 1

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.

Figure 2. If a valid answer is cached, the browser may not need a new DNS lookup. · PDF p. 2

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.

RecordPurposeExample use
A / AAAAMaps a name to an IPv4 / IPv6 address.Find a server address.
CNAMEPoints a hostname to another hostname.Create a domain alias.
MXIdentifies mail servers.Route email.
TXTStores text values.Domain verification and SPF.
NSIdentifies 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.

TCPUDP
DeliveryRetransmits lost data and provides an ordered byte stream.Does not guarantee delivery or ordering.
ControlProvides flow and congestion control.Minimal transport; the application adds features if needed.
Common usesHTTP/1.1, HTTP/2, SSH, many database connections.DNS queries, real-time media, QUIC.

How TCP starts a connection p. 3

Figure 3. TCP three-way handshake: SYN, SYN-ACK, ACK. · PDF 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.

Figure 4. Simplified setup for a new TCP connection with HTTPS. · PDF p. 3

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.

Figure 5. Example: the browser asks for a product list and receives a response. · PDF p. 4

HTTP versions p. 4

VersionWhat improvesImportant limitation
HTTP/1.1Persistent connections; commonly uses multiple connections for concurrency.Requests can be delayed behind other requests on a connection.
HTTP/2Multiple streams over one TCP connection; compressed headers.TCP packet loss can delay all streams on that connection.
HTTP/3Uses QUIC; streams have independent loss recovery.Cannot eliminate slow networks or slow application processing.

Common HTTP methods p. 4

MethodTypical purposeExample
GETRead information.View a product.
POSTSubmit data or trigger an action.Place an order.
PUTCreate or replace a resource at a known URI.Replace an address.
PATCHUpdate part of a resource.Change a phone number.
DELETEDelete 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 rangeMeaningExamples
2xxSuccess200 OK, 201 Created, 202 Accepted
3xxRedirect or cache-related response301, 304 Not Modified
4xxClient request or access problem400, 401, 403, 404, 429
5xxServer or upstream failure500, 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.

Figure 6. Simplified cache flow for an image or other reusable resource. · PDF p. 5

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.

Figure 7. Request/response and queued background work are different interaction patterns. · PDF p. 6

Common options p. 6

PatternSimple explanationCommon use
RESTHTTP requests and responses, often using JSON.Public APIs and CRUD operations.
GraphQLClient requests specific data fields.Clients with varied data needs.
gRPCTyped service communication, often using Protobuf.Internal service calls and streaming.
Queue / pub-subMessages 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.

Figure 8. Choose a live-update pattern based on direction, responsiveness and infrastructure. · PDF p. 7

Compare the options p. 7

PatternHow it worksTypical use
Short pollingClient asks for updates at intervals.Rarely changing data.
Long pollingServer waits until an update or timeout before replying.Updates when streaming is not needed or available.
SSEServer streams events to the client over HTTP.Dashboards, notifications, LLM token streaming.
WebSocketsClient 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 Componentrequest path. Real deployments may combine or reorder these responsibilities. What it does
Forward proxyActs on behalf of clients, for example for corporate internet access.
Reverse proxyReceives requests before application servers; can route traffic or terminate TLS.
Load balancerDistributes requests across multiple servers.
API gatewayAdds API controls such as authentication, rate limits, routing and versioning.
CDNServes 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.

CheckQuestion to ask
DNS and connectionWas there a lookup or new connection handshake?
CDN / proxy / networkWas content cached? Were requests delayed on the route?
ApplicationWas the service busy or waiting for another service?
DatabaseWas 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. 1. Roughly how many round trips does a new TCP + TLS 1.3 connection need before the first HTTP request byte?

  2. 2. Which transport is used by QUIC (HTTP/3)?

  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.