What is a CDN and when to use a CDN for a website?

The term CDN you will probably come across a lot of articles on thachpham.com, or when you need an experienced person to advise on solutions to save server bandwidth and increase website speed, you will be advised to use it. use CDNs. So what exactly is a CDN, how many types of CDN are there, and if your website is suitable for using a CDN, this article will provide you with the necessary information.

What is CDN?

CDN stands for Content Delivery Network and it's best not to try to translate it into Vietnamese, but to understand it in English to avoid distortion, or if you understand, you should translate it to mean " content delivery network " will be ok. than. That is, it is a system of servers around the world (the number depends on the service provider) that saves a copy of the static content inside the website, then distributes it to many other servers ( called PoP - Points of Presence ) and from those PoPs it will be sent to users when they visit the website.

First, we take a look at the different model between a website that doesn't use a CDN and a website that uses a CDN.

Do not use CDN
When a user views a file without a CDN, they have sent a request straight to the web server to access that file. For example, this link of thachpham.com is direct access to the server of thachpham.com.

Before using CDN

Using CDN
When a file is distributed by a CDN, and the user accesses it, the PoP distributed closest to the user will return the content to the user. For example, you access this link to view a content of thachpham.com on the CDN, for example, if you are in Vietnam, the PoP CDN in Vietnam will distribute the content to you.

After using CDN

Some forms of CDN
When you use some CDN services (not counting CloudFlare or similar CDN proxy services) you will find that they support several types of CDN usage including:

Pull HTTP/Static
This type means that you declare the domain name of the website to use the CDN or the server's IP. Then the PoP CDN will automatically access the website under that domain and save a copy of the entire static content inside the website (images, CSS files, Javascript files, Flash, Videos, ..) . And then you can access a certain file on the website with the CDN link they provide or use a separate domain name for the CDN. Eg:

Original file: https://thachpham.com/wp-content/uploads/2015/11/with-cdn.png
CDN file: http://static.thach.io/wp-content/uploads/2015/11/with-cdn.png
This can be called by many different names. But it has one thing in common that instead of PoP CDNs that will automatically collect the content on the website, you will directly upload the content that needs to be delivered via the CDN to their servers via popular protocols such as FTP or HTTP. Usually now they support FTP the most.

And with this delivery method, you will be able to save storage space on the server because nothing is stored there.

Streaming CDN
Although the above CDN types all support video files, it does not support live video streaming (streaming). So this method will help the CDN to deliver the streaming content from the server and then it will redistribute it to the users to save bandwidth from the original streaming server. Or you can choose to upload streaming content directly to the CDN server like Push CDN.

Advantages of using CDN
So after you understand how CDN works, you will find that it has the following advantages:

Save bandwidth for the origin server
The bandwidth from the origin server's network only takes one processing, which is to accept requests from PoP CDNs, then visits from users will only access the content on the CDN, so the origin server will not cost more. . Only when you proceed to delete the archives on the CDN will the PoP CDNs proceed to retrieve the content again, which will cost more.

Speed ​​up visits
Due to the nature of PoP CDNs spread across continents, it will help your website access faster for users who are far from the website's server. For example, thachpham.com is located in the US, which if accessing directly to view a 300KB image in Vietnam will take about 0.5 seconds (500ms). However, if thachpham.com uses CDN for such static content that supports PoP in Vietnam, it only takes users 0.01 seconds (10ms) to view a file, even faster.

Similar to users in other countries, the more PoPs your CDN has in many different countries, the more beneficial it is in accelerating the global website.

Save space
If you use the Push CDN method, it will save storage space for the server because everything is uploaded directly to the CDN server. However, to be safe, you should save the content somewhere in case the CDN service has problems.

Cost savings
The cost savings here is the cost of bandwidth. Assuming your server or host package only supports a certain amount of bandwidth per month, when it runs out you will need to buy more or upgrade bandwidth. The price of bandwidth is not cheap, the average bandwidth price currently on some host providers is about 20,000 VND per GB, equivalent to $0.88 already. But most CDN services today will cost about $0.05 or less, in some Asian PoPs, if they are more expensive, it will be as high as $0.1 per GB of bandwidth. So instead of buying more bandwidth at the host, using a CDN will save a lot.

When should a CDN be used?
CDN has many benefits to use and it is one of the requirements that many websites must use. But not every website is necessary to use, but CDN is only really useful when:

The website's server is located far away from the user.
Large hits consume a lot of bandwidth.
There are many visits across many different countries.
When using the Load Balancing FailOver technique.
When is it not necessary to use a CDN?
As I said above, in many cases you don't need to use a CDN because not only does it not make your website faster but also slower. And one of the most common reasons is that the website's server is located near the user. For example, you have a server in Vietnam and serve users in Vietnam, but you use a CDN, but if that CDN does not have PoP in Vietnam, your website will be slower because then your users will access it in Vietnam. PoPs that are further apart from the current origin server become slower.

Similar to a CDN proxy service like CloudFlare, the website is located on a server in Vietnam, but using it, users in Vietnam will enter slower than usual.

Notes when choosing a CDN . service
When you are looking for a good and suitable CDN service for long-term use, you should pay attention to their PoP system. It's best to prioritize PoP-enabled CDN services in the country where you have the most users. For example, if you choose a CDN for a Vietnamese website, you should prioritize CDN services with PoP in Vietnam such as CDNSun, CDN.Net, etc. Each provider has a Network section for you to see their PoP system. Please check carefully before use.

In addition, the second most important is the price and the form of payment. CDN services currently support two types of payment: Pay-as-You-Go or pay a fixed monthly fee for package use. If your website does not consume a lot of bandwidth, you should choose a payment method that is pay-as-you-go, it will be more economical because buying in packages may not be used up.

The last note is the speed, which you can check by testing the service and pinging the CDN address with the  CA App Synthetic Monitor service to see if it really optimizes the speed. Or you can look through CDN reviews online.

Some Free CDN Resources
This is a pretty popular free CDN-enabled proxy service. If your website is hosted in the US or Europe, this service will help you optimize website speed a lot for visitors in Vietnam.

It's not like the simple CDN service I described above, you can't use your own domain for the CDN and can't upload content to their CDN server but it will work by using a central proxy layer. domain name space. When users visit your website, they will go through a proxy layer and there it already has a CDN to deliver the content on the page, the website path does not change.

This is a special service for WordPress users who have the JetPack plugin installed . It will automatically transfer the image files on the website to Photon's CDN server and distribute them to users to save bandwidth and page load time.

This is a CDN service for Javascript libraries. For example, instead of hosting the jQuery library's jquery.js file yourself, you can use jsDelivr's CDN link. It currently supports up to 1650 different libraries, almost every popular Javascript library is there. The simple way to use it is to embed the Javascript file in their link instead of hosting it yourself.

If you are a WordPress user, you can install this plugin so that it automatically changes the Javascript libraries used in the website to the CDN link.

Google Hosted Library
Just like jsDelivr, you can use Javascript library bindings on Google's CDN server to save bandwidth.

Some popular CDN services
Amazon CloudFront
Akamai CDN
CDNSun  (with PoP support in Vietnam)
CDN.Com.Vn (PoP only in Vietnam)
WP Ready
How to use CDN
About how to use CDN is very simple, that is, after creating a CDN service, you just need to edit the original path of the static content on the website to the content path of the CDN. Eg:

[html]<img src="https://thachpham.com/images/logo.png">[/html]

Change into:

[html]<img src="http://tên-miền-cdn/images/logo.png">[/html]

And if you use WordPress, there are many plugins that support self-change such as WP Super Cache , W3 Total Cache , CDN Enabler , etc.

Except for some CDN proxy services like CloudFlare or Incapsula , there is no need to change anything because the domain name is already requested through the CDN because you have pointed the domain's DNS to their service.

In this article, I have probably presented quite a bit about CDN, so I think that's more than enough for you to understand about CDN. In fact, website makers in Vietnam rarely choose hosting services in Vietnam for many delicate reasons, so the demand for using CDN is also quite high. Hopefully, after having more knowledge about CDN, you will know whether you should use CDN or not and understand it in the right way.

Address: 107 Dong Nai - Vietnam. - Email: services@cmt8.net - Phone: 18001119
Copyright © 2012 - BlogMe. All rights reserved