API
The Gcore Customer Portal is being updated. Screenshots may not show the current version.
CDN
CDN
BillingCDN resources overviewOrigin groupPurgePrefetchReports
API
Chosen image
Home/CDN/CDN resource options/Cache/Cache Sharding

Сache Sharding: share cache between CDN servers

What is the Cache Sharding feature?

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.

How does the Cache Sharding feature work?

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.

How does the Cache Sharding feature work

What are the benefits of using Cache Sharding?

Cache Sharding optimizes content storage and distribution. Here are some of its benefits in more detail:

  • More efficient cache use. Only one copy of a file is needed for all the data center’s servers. This means that each CDN server is used efficiently, rather than being occupied with repeats.
  • Origin is protected from redundant requests. CDN servers use the hash key to determine if there is content in the group's cache. The origin is only requested if there is no content cached by the group. This reduces the costs that are incurred when paying for traffic from the CDN servers to the origin. It also lowers the load on the origin server.
  • Improved content delivery speed. Checking the caches of nearby servers in a group for a file is quicker than routing a request to the origin. This process enhances the “time to first byte” (TTFB,) indicating a more efficient system.

How to enable the Cache Sharding feature

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 Platform CDN resources.

Was this article helpful?

Not a Gcore user yet?

Learn more about our next-gen CDN

Go to the product page