DEV Community

Cover image for What are Content Delivery Networks (CDNs)?
Rishabh Agarwal
Rishabh Agarwal

Posted on

What are Content Delivery Networks (CDNs)?

Imagine running an application that serve latest news in the form of 100-words articles. News in the form of such short articles allowed your application’s users to consume lot more news in a short time.

With growing popularity of your application, the load on your application server started growing exponentially. Initially you increased your server’s capability to serve more requests, but you soon realised that this was not sustainable. You dig deep to find a better solution for this problem. You found the following usage pattern for your application ~

  • Users that were geographically closer to each other almost consumed the same set of news articles
  • While the number of users were large at any point in time, the news articles that they consumed in-together wasn’t that large. In other words, people read almost the same set of articles during a given interval.

All this made you to think of caching news articles. However, this cache needs to be different for different geographical locations. You researched further and found a perfect solution called Content Delivery Networks (CDNs).

This is how Cloudflare defines CDN ~

A content delivery network (CDN) is a geographically distributed group of servers that caches content close to end users. A CDN allows for the quick transfer of assets needed for loading Internet content, including HTML pages, JavaScript files, stylesheets, images, and videos.

So how does CDN works? There are the following three crucial components to it.

Origin Server: This is the application server that contains the source of truth. Any updates are made to the contents of the origin server.

Edge Servers: These servers are located in multiple geographical locations that are called “Points-of-Presence” or “PoP”. Content from the origin server is cached here and is served to the clients. In case of missing data, origin server is used to respond to the client’s query and for simultaneously updating edge server’s cache.

DNS Servers: Domain Name Systems (DNS) servers keep track of the origin and edge server. On a DNS lookup, IPs of both the origin and the edge server.

While caching is one of the biggest advantages of CDNs, it is not the only one. There are several other advantages like decreased server loads, improved site performance, and protection against cyber-attacks. All these benefits are the reason why most of the internet today is being served up by CDNs.

Types of CDNs

Based on how the cache in edge servers is updated, two types of CDNs exists: push and pull.

Push CDNs push contents from origin server to the edge servers. Updated content is pushed periodically which is then served up by the CDNs. The cache data from edge server is not removed until the data is explicitly deleted or overridden by the updated data.

Pull CDNs is the complete opposite of push CDNs. Here, the edge servers are responsible for pulling in data from the origin server. The process works like this: as the website owner, you maintain the content on the origin server and adjust the URLs to point to the CDN. Subsequently, when a request is made for a web page, the CDN fetches the necessary elements and files from the origin server and presents them to the visitor.

Popular CDNs

Almost always you would use services of a CDN provider instead of setting up your own CDN. There are some very good options out there, some of them being ~

  • Akamai
  • Cloudfront
  • Azure CDN
  • Cloudflare

With this we reach the end of this blog. Give yourself a pat on the back if you make it this far!

Top comments (3)

miguelrodriguezp99 profile image

nice one!

mosbat profile image

Nice and clear explanation.

hayyanstudio profile image
Haider Aftab

good info

Some comments may only be visible to logged-in visitors. Sign in to view all comments.