Mobile system design, from a packet to an app · check

Know The network under your app already?

One question for each of the 11 puzzles in this module. A right answer marks that puzzle as passed, so you can jump ahead. A wrong one tells you which puzzle to start with. Nothing is sent anywhere: it's saved in this browser.

Puzzle 0: What actually travels

A packet of your request is lost between two routers. Who notices and fixes it?

Right. Numbering, acknowledging, resending: TCP.

Not quite. Your code sees a clean stream; TCP handles losses underneath. Learn it in puzzle 0 →

Not quite. IP only does its best; recovering lost packets is TCP's job. Learn it in puzzle 0 →

Puzzle 1: Finding the server

Your app's first-ever request to api.example.com is slower than the next ones. Which part of that is DNS?

Right. Name to address, once.

Not quite. Routers deliver by address; the name is resolved by DNS first. Learn it in puzzle 1 →

Not quite. The data is the same size; the extra wait is the lookup before sending. Learn it in puzzle 1 →

Puzzle 2: Anatomy of an HTTP call

Your app gets a 404 from GET /users/42. Should it retry the same request?

Right. 4xx won't fix itself.

Not quite. Changing the method changes the meaning; it doesn't fix a missing user. Learn it in puzzle 2 →

Not quite. Only server failures (5xx) might pass; a 4xx is about your request. Learn it in puzzle 2 →

Puzzle 3: Round trips, not bandwidth

Your screen's four requests each wait for the one before, on a 250 ms mobile network. Bandwidth doubles. Roughly how long does loading take now?

Not quite. Sharing bandwidth doesn't shorten a trip. Learn it in puzzle 3 →

Not quite. For a few kilobytes the data takes almost no time; the trips do. Learn it in puzzle 3 →

Right. Small requests wait for round trips.

Puzzle 4: What HTTPS adds

A router on the café Wi-Fi changes one byte of your HTTPS response. What happens?

Not quite. Integrity means a change is detected, not passed on. Learn it in puzzle 4 →

Right. Integrity: changes are caught.

Not quite. They can tamper; TLS makes tampering detectable. Learn it in puzzle 4 →

Puzzle 5: One connection, many requests

On a 250 ms network, the first HTTPS request on a new connection takes about 750 ms. Why?

Not quite. Size barely matters here; the cost is round trips. Learn it in puzzle 5 →

Not quite. The extra time is two round trips of handshakes, not the server. Learn it in puzzle 5 →

Right. Three round trips: TCP, TLS, then the request.

Puzzle 6: The radio is the battery

Your app sends a 300-byte event every 20 seconds. Why does it drain the battery?

Right. Size barely matters; wake-ups do.

Not quite. The radio, not the encryption, is the expensive part. Learn it in puzzle 6 →

Not quite. It's a few hundred kilobytes an hour; the cost is the wake-ups and tails. Learn it in puzzle 6 →

Puzzle 7: Ask before you download

The feed came with Cache-Control: max-age=60. The user reopens it 30 seconds later. What happens on the network?

Not quite. That's after 60 seconds, when the copy is stale. Learn it in puzzle 7 →

Right. Fresh means no network.

Not quite. The stored response survives the screen closing. Learn it in puzzle 7 →

Puzzle 8: The database is the truth

In an offline-first app, the network returns a fresh list of notes. Where does it go?

Right. Network → database → screens.

Not quite. A second store is a second source of truth: the thing this design removes. Learn it in puzzle 8 →

Not quite. Then other screens could disagree; results always go through the database. Learn it in puzzle 8 →

Puzzle 9: When the connection breaks

A read timeout fires on POST /orders. What do you know?

Not quite. The server may have answered; only the answer went missing. Learn it in puzzle 9 →

Right. A read timeout can't say if it happened.

Not quite. TCP resends packets inside one request; it doesn't send the request twice. Learn it in puzzle 9 →

Puzzle 10: Retry without charging twice

POST /payments timed out. You retry with a new idempotency key. What can happen?

Not quite. Servers don't match by amount; only the key marks a retry. Learn it in puzzle 10 →

Not quite. The server recognises retries by the key; a new key looks like a new payment. Learn it in puzzle 10 →

Right. Same action, same key.

Back to the overview →