Highlights

Contents

BACKEND ENGINEERING / UNIT I / FIELD GUIDEHTTP, TLSand DNSHow one request finds the server, proves it, and askshttps://api.wren.example/orders/123GET /orders/123DNSTCPTLSHTTPfour layers, one requestHTTPmethods, codes, caching, versionsTLShandshake, keys, certificatesDNSrecords, TTLs, routingEnd to endevery round trip counted
Before we start

How to read this chapter

Every backend request starts as a name, becomes an address, crosses an encrypted connection and arrives as an HTTP message. This chapter follows that path slowly enough that you can redraw each step and say what breaks when it fails.

Each section opens with a situation you can picture, explains the mechanism, and works one example with real numbers. Then comes a figure. Read the paragraph first, look at the figure, and check that you could have drawn it yourself. If you could not, read the paragraph again before moving on.

The orange map at the start of each part shows where you are on the path. Four kinds of box interrupt the text. Picture this gives a physical analogy, a note adds a useful side detail, Watch out names a mistake people make in code or in interviews, and Interview lens gives a question with an answer you can say aloud. Each part ends with In one breath, a short recap worth memorising.

The goal is concrete. By the end you should be able to stand at a whiteboard and answer “walk me through what happens after I type https://api.wren.example/orders/123“ for ten minutes, naming each round trip, each header that matters and each status code the server could return.

The running system

Meet Wren

Abstract examples are easy to nod along to and hard to remember. So every unit of this series uses the same small service. Wren is an illustrative food-ordering API. Customers browse a menu, place orders and pay. Its numbers are assumptions chosen to make the arithmetic readable, not benchmarks.

Setting Value What it controls
API host api.wren.example, 203.0.113.10 The name we resolve and connect to
Daily requests 43,200,000 500 requests per second on average
Peak multiplier 4 2,000 requests per second at peak
Mean latency at peak 50 ms 100 requests in flight
App instances 4 500 requests per second each at peak
Response size 2,000 bytes 4,000,000 bytes per second at peak
Client round-trip time 40 ms Cost of every handshake
Server time for GET /orders/123 30 ms The useful work
DNS TTL 300 s How long a stale address can live
Certificate lifetime 90 days Renewal schedule

In this chapter the sample request is GET /orders/123, sent by user 42 from a phone. By Part IX we will have counted every round trip it takes, from a cold start at 175 ms down to 70 ms on a reused connection.

The map

What is inside

Follow one HTTPS request from a name to a JSON response and count every round trip on the way.

CHAPTER ATLAS / FOLLOW THE READING PATHCHAPTER ATLAS / FOLLOW THE READING PATH1HTTP messages2HTTP methods andidempotency3HTTP status codes4HTTP caching headers5HTTP/1.1, HTTP/2 andHTTP/36TLS and the handshake7Certificates and trust8DNS for backend engineers9The HTTPS request end toend
  1. 01HTTP messagesSections 1 to 4. We take apart one HTTP request and one response, line by line.
  2. 02HTTP methods and idempotencySections 5 to 8. We learn what each HTTP method promises and which promises let a client retry safely.
  3. 03HTTP status codesSections 9 to 12. We learn the status codes a backend actually returns and the one question each code answers.
  4. 04HTTP caching headersSections 13 to 15. We learn the headers that let a client or proxy skip a request, or skip the body, without serving wrong data.
  5. 05HTTP/1.1, HTTP/2 and HTTP/3Sections 16 to 19. We follow how the same request travels in each HTTP version and why each version was needed.
  6. 06TLS and the handshakeSections 20 to 24. We build TLS from the problem it solves to the exact messages of a TLS 1.3 handshake.
  7. 07Certificates and trustSections 25 to 28. We learn why a client believes that the server holding a key really is api.wren.example.
  8. 08DNS for backend engineersSections 29 to 32. We look at DNS from the side of the people who run services behind it.
  9. 09The HTTPS request end to endSections 33 to 35. We assemble everything into one complete answer to the classic question of what happens after you type a URL.
  10. +Interview prepInterview question bank, graded exercises and worked solutions.