3. Client and Server
The picture to keep in your head
Every question below is answered twice: first in the restaurant, so you can picture it, then in the system, so you know exactly how it works. Each answer ends with a memory code to lock it in.
The picture to keep in your head
You sit down in a restaurant. You read the menu, write your order on a slip, and hand it to the waiter. The waiter carries it to the kitchen, the kitchen cooks, and the waiter brings back a plate. You never walk into the kitchen. The kitchen never comes to your table unasked.
That's every web request you've ever made. Your browser or app is the customer. The server is the kitchen. The network is the waiter. The order slip is the request and the plate is the response.
Our running example: an online bookstore. You open the page for book number 42, then add it to your cart.
| In the restaurant | In the system |
|---|---|
| Customer | Client (browser, mobile app, another service) |
| Menu | The API: everything you're allowed to ask for |
| Order slip | HTTP request |
| Waiter | The network (TCP or QUIC, protected by TLS) |
| Kitchen | Server |
| Plate | HTTP response |
| Restaurant's address | Domain name and IP address (Chapter 4) |
Figure: the restaurant, mapped piece by piece. The menu is the API: the customer can only order what's on it.