A Content Delivery Network (CDN) is geographically distributed group of servers that caches content close to users.
Content Delivery Network caches the content from origin server, which means CDN server will save a copy of file from the origin website server. Multiple CDNs are located in different place such as Hong Kong or Japan. When you want a data, it will seach for the nearest CDN server for faster load time.
Today, a large portion of content are delivered through CDNs. There are lots of CDN provider, such as Akamai Technologies, CloudFlare, Amazon CloudFront and Google Cloud CDN.
1. How does a CDN Work?
A Content Delivery Network relies on three types of server:
-
Origin servers
Origin servers contain the original version of the content. Whenever content needs to be updated, changes are made on the origin server.
-
Edge servers
Edge servers are located in different place around the world. Those edge servers copy the content from the origin servers, and deliver the content to the nearby users. When user requests for a content from origin servers, they will be redirected to a cached copy of content on the edge servers. When cached content is oudated, edge servers requests updated content from the origin server.
-
DNS servers
DNS servers keep track of origin servers and edge servers. When user send a request to an origin server, DNS server will response a paired edge server from which the content can be served faster.
Users do not need to consider their data is from origin web server or a CDN server.
2. Benefits of CDN
The main benefits of CDN are:
-
Improving website load time
User access a website will ask for access the assets(text, images or videos), user will load the website faster with closer CDN server. This will reduce the page load time and improve user experience.
CDN is distributed and user do not need to ask website resources for the origin website server, a closer CDN server will transfer the data with lower latency so user will feel faster service.
CDN can reduce the amount of data that’s transfered by reducing file sizes using file compression. With smaller file sizes, the transfer time will be reduced.
-
Reducing bandwith costs
Through caching or other optimization, CDNs are able to reduce the data that origin server must provide. This will reduce the hosting cost for origin website owner.
-
Increasing content availability and redundancy
Large amounts of traffic or hardware failures will make website unable to provide normal function. However, CDN is distributed and if there is amounts of traffic or hardware failure, another CDN server is still working and the website still provide functions to users. This distributed nature will also achieve the load balance. Users are less likely to experience website failure with CDNs.
-
Improving website security
CDN can provide DDoS mitigation, improvements to security certificates and other optimizations.
3. An Example
Imagine you have some money and you have deposited it in the bank. And the bank is located in the XX street.
If you want to withdraw money from that bank, you have to go to the XX street even if it is far from your location. This means that you may have to travel a long distance even if you are going to withdraw a small amount of money. If many customers want to go to the bank at the same time, the bank may not be able to provide a fast service (customers may need to wait in line).
That would be a unsatisfied experience, so we will introduce the ATM as a type of CDN.
There are plenty of ATMs in the city. Whenever you need to withdraw money, you only need to go to the nearest one. You also reduce the possibility of having to wait in line.
If you request for a content from origin server, you only need to search for nearest “ATM” to get it. This is what we called a CDN server.