...

/

Copy Design

Copy Design

Let's understand CDN design within the design of a system.

CDN design

Content caching strategies in CDN

Which content has to cache is an important matter for an organization to deliver up-to-date web content. There are two classifications of CDN used to get the content from the origin servers.

Push CDN

Content sends automatically to the CDN proxy servers from the origin server in the pull CDN, and then requested content is delivered to the user. The content delivery to the CDN proxy servers is the content provider’s responsibility. The content is pushed to proxy servers located in various locations according to the content’s popularity. The one problem with the push approach is that if content updates frequently and the origin server serves other heavy traffic, this frequent sync will create more trouble.

Pull CDN

A CDN pulls the data when requested, keeps the files for a specific time, and then removes them from the cache if no longer requested to balance capacity and cost. When users request web content in the pull CDN, the CDN itself is responsible for pulling the requested content from the origin server and serving it to the users. The user will not see much speed the first time, but when the user requests the content next time, it will access it quickly as CDN has already cached that content. The cached data remain on the edge server until its expiration time reaches.

The primary advantage of a push CDN compared to a pull CDN is that push CDN contains a secondary copy of the static web content. When the origin server goes offline for any reason, users can still access the static content from the CDN, which eventually improves the performance. When users visit the web, they do not face delay because requested content is already available so, CDN does not need to copy it from the origin server. On the other hand, pull CDN is used when the content changes more frequently and there is a high traffic load. Low storage consumption is one of the main benefits of pull CDN. The administrative effort will also be minimized using pull CDN because there is no need to automate and schedule the tasks. Let’s see the pull and push CDN comparison in the table below.

Most content providers use both Pull/Push CDN caching approaches to get the benefits of both.

Dynamic content caching optimization

For dynamic content, most of the CDN runs the script that changes the content in the CDN cache instead of running it in the origin server. Different parameters are used to generate the dynamic content, such as user location, time of day, third-party APIs data, etc. There exist other techniques as well to deliver dynamic content. For example, Cloudflare uses Railgun to compress dynamic content.

Railgun consists of listener installed on the origin server and sender installed on the Cloudflare data centers. When an HTTP request comes to Cloudflare, it checks whether the request is for the Railgun-enabled website. If yes, the HTTP request is routed to the sender; otherwise, standard HTTP is used. The sender transforms the request into a compressed binary chunk and transmits it to the respective listener. The listener services the request and performs an HTTP request to the origin server. Railgun uses the cache techniques based on the page version comparison to determine the changed data from the previous one and achieve around 99.6% compression.

Another most popular approach is ESI (Edge Side Includes) markup language. Usually, a small portion of the web pages changes in a certain time. It means each dynamic copy of the web page contains many duplicate data. To resolve this, ESI specifies where content has been changed so that the rest of the webpage content can be cached. It assembles dynamic content at the CDN edge server or client browser.

ESI is not standardized yet by the W3C, but many CDN providers use it.

Multi-tier CDN architecture

The content provider sends the content to an enormous number of clients ...

Create a free account to access the full course.

By signing up, you agree to Educative's Terms of Service and Privacy Policy