Skip to main content

How we made global routing faster with Bloom filters

By Steven Van ·

A Bloom filter swap cut path lookup latency by up to 200x and improved TTFB 10% for sites hosted on Vercel.

Vercel replaced a JSON parsing step in its global routing service with a Bloom filter, cutting path lookup latency to near zero. Previously, checking whether a requested path exists before serving it meant parsing a JSON file of every path in a project's build output. For most sites that took under a millisecond, but sites with very large path lists, such as e-commerce catalogs or documentation sites with hundreds of thousands of static paths, could see this parsing take up to 250 milliseconds at the 99.9th percentile, blocking the routing service's single-threaded event loop.

The new approach uses a Bloom filter, a probabilistic data structure that can rule out a path with certainty or flag it as possibly existing, falling back to a storage check only on a possible match. The build service now uploads a compact JSONL file containing the Bloom filter parameters and a Base64-encoded bit array, which is 70-80% smaller than the previous JSON file and is read directly as bytes rather than parsed as a string.

The change brought 99th percentile path lookup duration down to about 0.5 milliseconds, roughly 200 times faster than before, and the 99.9th percentile down to 2.4 milliseconds. Because the heaviest sites were previously hogging memory and CPU across the whole routing service, the fix also reduced the service's overall heap size and memory usage by 15% and improved time-to-first-byte from the 75th to 99th percentile by 10% across all sites served by Vercel. Full details are in the announcement.

Vercel
Vercel
The platform for frontend developers — deploy, preview, and scale web apps and AI agents with zero config.
View Vercel →

Original source

Read How we made global routing faster with Bloom filters on Creators Toolbox