What is a CDN and How to Use It

cdn cover photo

You may have come across the buzzword called CDN and may have probably wondered what it is. In this article, we are going to demystify this term and explain how to use it for a variety of benefits on your website.

Content Delivery Network (CDN) is a network of servers distributed across many places around the globe. Their job is to serve content to visitors. But, the website’s server does that too – “Serving Content“. So what is the difference?

A CDN stores a copy of your website at multiple places around the globe so that the nearest server to the visitor serves the content. This reduces the latency to reach a very distant server considerably improving the performance. It can be understood by a simple example: Suppose your origin web server is in Singapore and someone at Paris wants to access your website. The data packets have to go through several layers across different territories before reaching the destination. So, the visitor has to wait for a long time before the page starts to display. This can be very frustrating, and often visitors leave if the delay is more than 3 seconds. Now, in the case of a CDN, the website can be served from the server that is nearest to Paris. So, the data packets need not go through multiple networks and can be served directly.

The concept has been demonstrated above in the cover photo. On the left, we have a conventional system where one server serves to all the visitors around the world and on the right, there is a distributed approach where the host connects to the nearest CDN server.

cdn infographic

Infographic by KeyCDN

Benefits of a CDN:

Using a CDN has numerous benefits other than speed. Let’s look at some of them

  • Speed and Performance – We already discussed how a CDN could drastically increase the rendering time of a website. In short, the CDN servers store a cached copy of the site. The visitors connect to their nearest CDN server and fetch the content rather than going all the way up to the origin server. For the sites which have dynamic content, like online shopping websites, social networking or microblogging sites, caching is done using various TCP tweaks like cache control headers or edge side includes.
    Therefore, a CDN ensures a super fast web experience to the end users.
  • Security – The ever rising cyber crimes and DDoS attacks are costing organisations millions of dollars. Most of the leading CDNs provide protection against these attacks. They provide web application firewall, SSL certificates, rate limiting and more tools to secure the websites.
  • Availability – Whenever the origin server goes down or becomes unavailable for some reason, the CDN will serve cached static pages in the meantime. It will also act as a load balancer when your website’s traffic is very high which would not have been possible by only one origin server. The CDN can handle tonnes of terabytes of data per second which is also the reason they can handle massive DDoS attacks.
  • IPV6 compatible – You can make your website IPV6 compatible even if your origin server doesn’t support IPV6. It has a host of benefits like more efficient routing and better packet processing than the conventional IPV4
  • HTTP/2 enabled – Nearly all the CDNs today have enabled HTTP2 by default. It is a worthy upgrade over the previous version of the protocol which offers features like multiplexing, header compression and prioritization. The following video by  Akamai explains it all.

How to use a CDN:

Setting up a CDN is fairly simple for simple websites like blogs, product/company pages or other sites which do not have very high dynamic content. You just need to change the nameservers of your site to the one that is provided by the CDN company.
Below is a short video showing the process of signing up in CloudFlare.

 

For dynamic sites like e-commerce, the process is a bit tedious. You need to specify which resources you want to cache and which ones to serve from the origin. Also, you may want to host your images and videos on the CDN server. Do note that this can affect your SEO since the URLs will change. To solve it, you need to set up CNAME records for better-looking links.

CDN companies:

There are various CDN companies to choose from and it all depends on your requirements. These are some of the popular CDN companies:

  • Cloudflare – This is the most beginner friendly CDN and is great for all types of websites. The best thing about Cloudflare is that it offers a free plan that includes a free shared SSL certificate too. Cloudflare ranks #1 in terms of popularity among CDN companies. They have a massive network comprising of 100+ data centers spread across the world. Setting up Cloudflare is also very easy, and people with no experience can also do it. You can start off with the free plan and later upgrade to the $20/month Pro plan which offers web application firewall and other extra features.
  • Incapsula – It is also a relatively popular CDN and also includes a free plan to start with. The free plan does not include free SSL, unlike CloudFlare.
  • BunnyCDN – It is a new player in the market, and not many people know about it yet. BunnyCDN offers the lowest rate in the industry for premium services – $0.01-0.03/GB of traffic. You can literally serve a terabyte of traffic for only $10. This can be ideal for people who want premium features but are budget constraint.
  • Stackpath (Previously MaxCDN) – It offers premium services and is in the market for a lot of years. They have an ever growing network of data centers around the world with reasonable and clear pricing. Stackpath uses Anycast routing for one-to-nearest content delivery over multiple connections.
  • Akamai – It is a CDN designed for enterprise organisations. According to Wikipedia, their network is one of the world’s largest distributed computing platforms, responsible for serving between 15 and 30 percent of all web traffic. They have customised plans for each client and are not available publicly.

Some of the other popular CDNs include Amazon’s CloudFront, KeyCDN, fastly, EdgeCast, CDN77, Azure Content Delivery Network and CacheFly.

Test your CDN

After having set up your CDN, you can see how well it performs at various locations across the globe. Head over to Pingdom or webpagetest.org and enter your website’s URL. Then test it across the different locations given. You should see a notable difference in latency.

Conclusion

Having a fast site is very crucial for keeping the visitors happy. CDN plays a key role in speeding up a website and securing it. In addition to CDN, other technologies like Accelerated Mobile Pages should also be used for an array of benefits among mobile users.
Which CDN are you using and what are your experiences? Do let us know in the comments down below!

If you liked this post, please share it 🙂

You may also like...