Fan-out on read vs fan-out on write

Fan-out on read builds each feed when a user asks for it. Fan-out on write prepares the feed when its data changes. With 2,000 feed reads/s and six lookups per feed, building on read pushes p99 to seconds and a prepared feed keeps it near 26 ms.

Play the level

Tables join, documents copyTap or press Space to switch between tables and documents

Tables · a read touches 3 places in 0.5 ms · a shared change writes 1 place

A page waits for its slowest callDrag or use arrow keys to change the calls per page

Calls per page: 20 · 18% of pages wait 2.0 s

Case 1

Users read feeds 2,000 times/s. Each feed needs six indexed lookups, and 1 percent of requests change a feed. A change must show within 1 s.

Case 1
Measure Goal Fan-out on read Fan-out on write
p99 latency under 150 ms 6.8 s Fail 26 ms Pass
Data age under 1 s 0 ms Pass 0 ms Pass
Monthly cost 16 USD/mo 16 USD/mo
Error rate 36.5% 0%
HTTP/2SQLUsersAPI server1 vCPU · 2 GBPostgres0.5 vCPU · 2 GB
HTTP/2SQLUsersAPI server1 vCPU · 2 GBPostgres0.5 vCPU · 2 GB
Fan-out on read: misses a goal
HTTP/2SQLUsersAPI server1 vCPU · 2 GBPostgres0.5 vCPU · 2 GB
HTTP/2SQLUsersAPI server1 vCPU · 2 GBPostgres0.5 vCPU · 2 GB
Fan-out on write: meets the goals