Cache Sharding is a feature that allows some CDN servers—grouped together and in the same Point of presence (PoP)—to use one another’s cache to increase the CDN performance. When users request content, a CDN server proxies a request to another server where the cache is located using a consistent hashing algorithm.
This feature is particularly important for websites and applications with a large amount of content stored in the CDN cache and for those where multiple files receive relatively similar numbers of requests, such as e-commerce, video game industry, and VoD streaming.
In a system without Cache Sharding, a CDN server only checks its own cache for a file request. This is inefficient when there are many servers in one PoP: if a server without the file gets a request, it retrieves a file from the origin instead of a neighboring server.
When Cache Sharding is enabled for a CDN resource, CDN servers within one PoP (or data center) are clustered to use each others’ cache with the consistent hashing algorithm.
Consistent hashing is a method in which data is stored in a hash table using a hash function. The key of each data item is passed through a hash function, which calculates the address in the “hash ring” and determines in which sector of this ring the hash code is. This hash code indicates on which server the data is stored.
Example: Assume three CDN servers, A, B, and C, constitute one group. Server A has file X in its cache. When users request X, their request may reach any of the group’s servers (A, B, or C), depending on workload, connectivity, and other factors. If the request hits A, X is served from its cache.
If the request hits B or C, they calculate a hash code. Based on this, server B or C knows to which server they should send the request in order to serve X from the cache rather than the origin server. Since server A’s cache has the desired file, server B or C will proxy the request, and server A will serve the user file X from its cache.
If the group has no X in its cache, the server that was initially chosen using a consistent hashing algorithm will download file X from the origin and cache it.
If a server fails, it is removed from the group, and the hash will be recalculated to reflect the failed server. Thus, all subsequent requests will be distributed among other servers of the same group.
Cache Sharding optimizes content storage and distribution. Here are some of its benefits in more detail:
Newly created CDN resources have Cache Sharding enabled automatically. If you’re a long-term user unsure whether the feature is activated, please contact our support team to request activation.
Note: The Cache Sharding option is not used for Streaming CDN resources.
Was this article helpful?
Learn more about our next-gen CDN