A beginner guide to Content Delivery Network (CDN).

Sivaprasad EV
CodeX
Published in
4 min readOct 20, 2022

What exactly is a CDN?

The term CDN stands for Content Delivery Network or Content Distribution Network. It is a set of servers that delivers data based on the user’s request.
Libraries like Bootstrap and jQuery make available their static assets such as style sheets and JavaScript files to their end-users through CDN. If you have used any one of these libraries, you may be familiar with adding CDN links to your projects.

Why CDN?

Before diving into the answer to this question, I wish to brief the working of request-response on the web. Generally, a user or a client makes a request via his/her web browser and it then sends to the server where it hosts. Once the requested resource is available on the server, a response is sent back to the user and accessible using the same browser.

Moreover, the geographical location of the client/server matters in the load time of a website. For instance, when a server is situated far away from the client, it increases network latency (load time) when compared to communicating with a server nearby the client. Hence, CDN servers are placed between the client and the actual server to reduce this latency.

Once the CDN is configured, the request-response flow works in a bit different way. Consider the below example.

  • user A is making a request for the first time.
  • he got the response back from the actual server.
  • while user A recieving the response, It goes through a CDN server and the copy of this response will be stored into a that server (called caching).
  • whenever, user A or any other user from the same region makes the same request again, will recieve response from a CDN server rather than a real server.

As a result, end-user will recieve faster response and it drastically improves user experience.

There are numerous other reasons why a CDN is very useful.Some of them are;

  • A CDN can help to reduce network latency efficiently.
  • Since the CDNs support caching, they can respond faster to the user request even in heavy web traffic.
  • CDN can handle heavy server loads or bulk requests resulting in reduced server load.
  • If any one of the CDN servers goes offline, It will replace with another operational server and continue the service.
  • Distributed denial-of-service (DDoS) is a cyber-attack that sends a larger amount of fake requests to the server to make the website slow down.
    This kind of activity can be prevented using a CDN. CDN servers split such heavy traffic spikes between other intermediary servers to reduce the impact on the real server.

What content CDN delivers?

Now you have a better understanding of why a CDN is needed. Let us take a look at what kind of internet content a CDN can deliver to its end-users.

  1. Static Content : As the name indicates the static contents do not change from user to user. Font styles, logos, header images, etc. are some examples of static content. These things remain the same across all the users of the website and will not be modified frequently based on business needs. Therefore, using a CDN, end-user will have easy access to these contents.
  2. Dynamic Content : Things will change here. Yes! you are right. Dynamic content varies between users. Contents are generated according to a user’s taste and their preferences. Some of the examples are as follows;
  • Weather reports
  • Social media news feeds
  • Authentication status (login/logout)
  • Chat messages

Types of CDNs

There are different types of CDN services available. Let us explore each.

  1. Peer-to-Peer CDN : Here, a mesh network protocol will be created with multiple users connected to each other to share the same resources. This CDN does not cache anything.
  2. Push CDN : Push CDN is also known as Hosted CDN which holds physical contents in their servers. It can be considered as a secondary server for the main server because all the contents are directly pushed into the CDN servers and these can be downloaded on each request without going to the main server. Amazon Cloudfront is using this technique.
  3. Origin Pull CDN : Here the physical contents reside in the main web server and get cached into CDN servers when necessary. Once it is cached, the subsequent response will send back from CDN servers close to the end user.

CDN service providers

Some of the CDN providers are listed below.

  • Amazon CloudFront
  • Akamai
  • CacheFly
  • CDN77.com
  • CloudFlare
  • Stackpath

--

--