The click: store it, then redirect
The user waits for exactly one thing: the click being stored somewhere durable. The click server appends it to a replicated, partitioned log (Kafka here), waits for the acknowledgement with a short timeout, and returns the redirect. No database row is written per click, and nothing downstream is waited for.
- The browser follows the click link to a click server.
- The click server checks the token and appends the click to the log, waiting briefly for its replicas to acknowledge.
- If the log is slow, it writes the click to a standby log instead, and a relay copies it over later.
- It returns the 302, and the browser loads the advertiser’s page.
Diagram as text
Components: Browser (Client); Click server (Service); Click log (Kafka) (Queue); Advertiser’s page (External API); Standby log (Queue). Connections: Browser → Click server (GET /c/{token}); Click server → Click log (Kafka) (append, wait for ack); Click server → Standby log (log slow), asynchronous; Standby log → Click log (Kafka) (relay later), asynchronous; Browser → Advertiser’s page (after the 302).
Read:Learn: Write-heavyLearn: Apache Kafka
Keep reading+1 min
When the log itself is slow
The acknowledgement comes once the click is on more than one replica, so losing a single log machine loses nothing. If the log doesn’t answer within a short budget, set well inside the brief’s redirect target (for example, 20 ms of an illustrative 50 ms), the click server writes the click to a standby log cluster and redirects; a relay copies those clicks into the main log later, carrying their ids so nothing is counted twice. A spool on the click server’s own disk is cheaper, but a click server that dies takes the unsent clicks with it, which the brief rules out.
If both logs are down, the honest choice is to name the trade-off: fail the click, or redirect and record the loss.
Check yourself