Knowledge Base


« Content Delivery Network (CDN)

How does a CDN work

A CDN (Content Delivery Network) is a global cluster of caches that can serve as local caches for static files (objects).

If a visitor of a website or a user of an application request certain files (e.g. images, pdfs, javascript, CSS files, etc), instead of the hosting server responding with these objects, the CDN takes care of serving them. Because a CDN takes the geo-location of the user in account, the file will be served from the caching-node closest to the visitor. This means data can become available to the user with lightning speed, independent of the location of the website or application.

If the caching-node that is assigned with serving the data to the visitor, doesn't have the requested object available, it will ask other nodes in the CDN first. If the object is not in the CDN, then the object will be requested from the Origin Server (the server or object store container where the source files reside).

How to activate the CDN?

In order for a CDN to know which objects belong to which request, a Supername / Origin Server combination needs to be registered with the CDN. A Supername is a subdomain of a domain controlled by the customer, like images.mydomain.com for instance. The Origin Server reflects the internet path to the objects that are to be served from the CDN. After registering both pieces of information with the CDN, it knows which objects belong to what subdomain.

Some DNS magic follows:
At the end of the registration process for the Supername / Origin Server combination, a CNAME is sent back by the CDN. This will normally happen within 4 hours and certainly within 24 hours. A CNAME links one subdomain (the Supername) to an other subdomain (an entry point into the CDN) at the DNS level. To actually make the connection, the acquired CNAME must be implemented in the DNS record for the domain (mydomain.com).

If the CNAME returned by the CDN is 5cdN1Nme1F9bp7a6vzSzj2J.a.b.cdn.com and the Supername is images.mydomain.com, than the CNAME record in mydomain.com should be similar to:

images.mydomain.com. IN CNAME 5cdN1Nme1F9bp7a6vzSzj2J.a.b.cdn.com.

Only after the DNS is updated and the nameservers have incorporated the change, the link with the CDN is ready. A request for http://images.mydomain.com/logo.png will subsequently be served by the CDN.

Integrating the CDN.

The only thing that is required to integrate the CDN is to update local references to files in the source code for a website or application, to the full URL of the object. If we continue the example for http://images.mydomain.com/logo.png, the first time the CDN receives a request for logo.png, it will collect it from the Origin Server and put it in it's cache. Every subsequent request for logo.png will be significantly faster.

Be aware that, in order to gain the maximum benefit of the CloudVPS CDN, some changes to your site could be needed. Static files that can be used in the CDN might be combined and dynamic elements might have to be separated and loaded at a later stage.

Example of a Request Flow with a CDN

1. Client requests logo.png on images.mydomain.com
2. The DNS system finds the CNAME and redirects the request to the CDN
3. If logo.png is not found or expired in the CDN, it is requested from the Origin Server and put in the CDN
4. The CDN responds to the Client request with the file logo.png

During the time the file logo.png is in the CDN, step 3 is skipped from the request flow and the response will be significantly faster.

Video Streaming and CDN

There are 3 ways to serve video over HTTP via the CDN:

  1. Progressive Download and Play
    This is nothing else than serving the the entire video file to the customer. When the video file is large, the player can already start playing while the file is being downloaded in the background. This is a method that does not allow the time indicator in the player to be moved beyond they already downloaded material.
  2. HTTP Pseudostreaming
    This is a method that tries to mimic Video on Demand (VOD) The video file is broken into small segments and entered as a list in an index file (a .m3u8 file for example). Because the video file is segmented the video player can fast forward when this is supported. Segments that are skipped are not downloaded. Be aware that the segmentation of the video file has to be done before it is placed in the CDN.
  3. Live Streaming
    These is live material that is broadcasted via the internet. Often HTTP Pseudostreaming is meant when live streaming is discussed. Real live streaming via the CDN is customised work, get in touch with us if you want to live stream via the CDN.
     

Next Steps

When it is time to deploy a CDN, it is important to form a strategy regarding the maximum lifespan of an object beforehand.
Read more on how to control the lifespan of objects in the CDN.


API documentation can be found on our downloads page.

VPS Bestellen
VPS Bestellen