CDN stands for Content Delivery Network
. As the name suggests it is a network of distributed nodes (also known as Edge Location Servers) which helps deliver contents (webpages, video, image etc.) to the end-user based on the user’s location, content origin server and the Edge
server location. CDN nodes
have the cache capabilities to cache the content and can serve the content to a user from a location which is geographically close to the end-user. CDN nodes are deployed in multiple geographic locations by CDN providers and can span over multiple ISP (Internet Service Provider) networks.
How does CDN work?
When a user tries to access the webserver data(website) from a particular location, if the CDN settings are configured for the website, then the request first goes to nearby optimal CDN node. Now, if the CDN already has the requested data cached on that node, then it is served to the user from that node without the need to go back to the origin server. However, if the data is not cached on to the CDN node serving that user, then request first goes to CDN node, then from there it goes to the origin server. CDN node then fetches the data from the origin server and serves the user’s request. Moreover, CDN node caches this data to serve any future requests from this user or any other user requesting that data from this node. So, in principle, using CDN on a website, only the first user requesting specific content suffers an extra latency and all the user requesting this content in the future would have faster access to this specific content because it would be served from the CDN node. Of course, this depends on the content cache setting of the content (e.g. website cache settings) as these settings may require CDN node to fetch the content again based on the content expiration time. This is explained a bit more at the bottom of this page.
What does it mean in a real-world situation and why do you need it?
Let’s assume you own a website which is hosted on a web server (origin of the content) and serves images of inspirations quotes to the website visitors. As you started your website, you hosted it in a particular geographic location, say UK. Initially when the website started, you may see visitor from UK visiting your website to see and download content. As your website starts to get popular, more users from UK and abroad starts to access your website. This creates three challenges. First, as more users are accessing the same webserver, the load on webserver increases and it would not be able to serve all the users at the same time, in turn, causing bad user experience in accessing your website. Second, as the origin server is located in UK, users accessing it would face latency because the data is transferred over internet from a geographically distant location. Third challenge is the bandwidth cost that you need to pay to serve content from the origin server as a greater number of users require more bandwidth to serve the content.
These three challenges can be tackled by using CDN. As CDN is a network of geographically distributed servers for serving content, it acts as a middleman between the end-user and the origin server. For the first challenge, once a user accesses the website, request is sent to the most suitable node for the content delivery and then it is served from the CDN nodes in the same principle as described above. So, in this case, instead of sending all the requests from all users to origin server, it is sent to the distributed nodes and load on origin server is minimised.
For the second challenge, CDN would be able to tackle the challenge as CDN nodes are distributed across geographies and continents. This way users are served by nodes in their own geographies and hence the distance from origin server would not create the issue as long as CDN nodes are available.
For the third challenge of cost, CDN can reduce bandwidth requirement for the server as all the requests are not sent back to the server. CDN nodes are usually far cheaper in terms of bandwidth cost than origin server. Further to optimize cost, CDN node location that are least expensive in terms of bandwidth/cost can be chosen to serve the content.
Website Cache settings
Website cache setting can play an important role in CDN content caching. Based on the website cache settings, CDN can cache contents from a web server. There are different cache settings which can cause a CDN node to download the content every time or can request nodes to check the server if the content has expired or not. You can read about cache configuration
in more details by clicking the link.