Skip to content
Dashboard

Scaling redirects to infinity on Vercel

Link to headingWhat we optimized for

Link to headingJSON and Bloom filters versus napkin math

Link to headingSharding and Bloom filters keep memory low and lookups fast

Link to headingShard structure

{"version":"bulk-redirects","bloom":{"n":3,"p":1e-7,"m":102,"k":23,"s":0}}
"Mec7FxGVcJ0fHdj8HA=="
{"/old-path":{"destination":"/new-path", ...},"/another-old-path":{"destination":"/another-new-path", ...}, ...}

Shard format with header, Bloom filter, and redirect map

Link to headingThe lookup path checks the Bloom filter before parsing JSON

Request flow from hash to shard to Bloom filter checkRequest flow from hash to shard to Bloom filter checkRequest flow from hash to shard to Bloom filter checkRequest flow from hash to shard to Bloom filter check
Request flow from hash to shard to Bloom filter check

Link to headingJSON parsing became a bottleneck on positive lookups

High-CPU periods caused latency spikes when JSON parsing competed for resourcesHigh-CPU periods caused latency spikes when JSON parsing competed for resourcesHigh-CPU periods caused latency spikes when JSON parsing competed for resourcesHigh-CPU periods caused latency spikes when JSON parsing competed for resources
High-CPU periods caused latency spikes when JSON parsing competed for resources

Link to headingBinary search over sorted keys to avoid parsing the entire shard

{"version":"bulk-redirects","bloom":{"n":3,"p":1e-7,"m":102,"k":23,"s":0}}
"Mec7FxGVcJ0fHdj8HA=="
"/old-path"
{"destination":"/new-path", ...}
"/another-old-path"
{"destination":"/another-new-path", ...}

Sorted keys enable binary search without parsing the full shard

Link to headingLatency dropped and the spikes disappeared

Redirect lookup latency before and after binary searchRedirect lookup latency before and after binary searchRedirect lookup latency before and after binary searchRedirect lookup latency before and after binary search
Redirect lookup latency before and after binary search

Link to headingDesigning for the common case

Link to headingGet started with bulk redirects