Skip to content
Dashboard

Scaling redirects to infinity on Vercel

Copy link to headingWhat we optimized for

Copy link to headingJSON and Bloom filters versus napkin math

Copy link to headingSharding and Bloom filters keep memory low and lookups fast

Copy 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

Copy 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 check
Request flow from hash to shard to Bloom filter check

Copy 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 resources
High-CPU periods caused latency spikes when JSON parsing competed for resources

Copy 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

Copy link to headingLatency dropped and the spikes disappeared

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

Copy link to headingDesigning for the common case

Copy link to headingGet started with bulk redirects

Ready to deploy?