How we made global routing faster with Bloom filters
Blog post from Vercel
A recent optimization to a global routing service has significantly enhanced performance by implementing a Bloom filter to replace a slow JSON parsing operation, resulting in a 15% reduction in memory usage, a 10% improvement in time-to-first-byte (TTFB) for requests above the 75th percentile, and faster routing speeds for websites with numerous static paths. The previous method, which involved generating and parsing a large JSON file to check if a requested path existed, particularly affected websites with massive path lists, such as e-commerce platforms and documentation sites, causing delays of up to 250 milliseconds. The introduction of Bloom filters, a probabilistic data structure, has reduced path lookup times to nearly zero, as Bloom filters are smaller and faster than storing the entire path list, and they guarantee no false negatives, only occasionally triggering extra storage requests due to false positives. This transition required implementing matching Bloom filter algorithms across different services and resulted in a 200x to 100x speed improvement over the previous approach, reducing heap size and memory usage by 15%, and consequently improving performance across the entire routing service.