Optimistic updates
An optimistic update shows the result before the server confirms it. It cut the feedback p99 from 202 ms to 2 ms in the mini board. The price is a promise: keep each action in a durable outbox, retry it, and undo it if the server refuses.
See it on the board
The same traffic runs on two boards. The simulator measured both when this page was built.
| Measure | Goal | Tap waits for the server | Tap shows the result, outbox sends it |
|---|---|---|---|
| p99 latency | under 100 ms | 202 ms Fail | 2.2 ms Pass |
| Lost writes | none | 0 Pass | 0 Pass |
| Error rate | under 0.1% | 16.7% Fail | 0% Pass |
| Monthly cost | 8 USD/mo | 12 USD/mo |
Key numbers
| Number | Value |
|---|---|
| Mobile 4G round trip, fast end | 40 ms |
| Mobile 4G round trip, slow end | 90 ms |
| Default delivery tries | 5 tries |
W 3 + R 3 of 5 · every read sees the last write
How it works
A like button feels slow if it waits for the server. On a 4G link with a 65 ms round trip, the user waits 65 ms plus the server time, and the p99 passes 100 ms. An optimistic update does not wait. The app shows the heart at once and sends the request in the background.
This changes what the app promises. The screen now shows a state that the server has not confirmed. If the request fails, the screen is wrong. So the app needs three things.
First, a durable outbox. The app saves each action on the phone before it sends it. If the app closes, the action is still there. Second, retries. If the API is down, the outbox sends the action again later, with backoff. Third, an undo path. If the server refuses the action, the app must remove the heart and tell the user.
In the mini board the API is down for 15 s at 0:20 while 120 likes/s arrive. Without retries, 1,800 likes are lost. With the outbox, none are lost, and no tap fails.
Make each action safe to repeat, because a retry can send it twice. Use optimistic updates for actions that rarely fail. Do not use them for payments.
In the levels you choose how the app sends an action and check feedback time and lost actions.