Cloudflare saves 100 TB of RAM again, this time by slashing server hashes by 90% — cutting 100,000 entries down to 10,000 eliminates massive cache bloat
(Image credit: Cloudflare)
Cloudflare has saved 100 TB of RAM again, but this time by tuning its hash-mapping algorithm. One of Cloudflare's largest business use cases is data caching, more specifically serving a URL directly from memory or disk instead of fetching it from the live site, which may take a significant amount of time. The company uses its own open-source Pingora framework for the task of mapping an arbitrary URL to one of its cadre of cache servers, using the Ketama algorithm. This task is simple in concept, but can get quite tricky in an environment where it's expected that backend servers appear and disappear — and harder still when done at Cloudflare's scale.
"Backend routing," or the mapping of a URL to one of many cached servers, requires a lot of tables held in memory. An incoming URL is hashed (like you do with files with CRC-32), and that resulting number is taken and sent out to a server. The first instinct is to do this sequentially, one URL per server, but you hit the first problem: the same URLs aren't going to the same servers. So what you do is you make a hash corresponding to the server, say with its IP address and name, and match both hashes together by numerical proximity.
Get Tom's Hardware's best news and in-depth reviews, straight to your inbox.
Bruno Ferreira is a contributing writer for Tom's Hardware. He has decades of experience with PC hardware and assorted sundries, alongside a career as a developer. He's obsessed with detail and has a tendency to ramble on the topics he loves. When not doing that, he's usually playing games, or at live music shows and festivals.
What's Your Reaction?
Like
0
Dislike
0
Love
0
Funny
0
Wow
0
Sad
0
Angry
0
Comments (0)