What is CDN ?

Ananay Ojha
5 min readNov 19, 2021

Table of Contents

  • What is CDN
  • Need of CDN
  • Benefits of CDN
  • How CDN works
  • Use Cases of CDN
  • Personal experience with CDN

• Conclusion

Now everything is fast moving. ‘Time Is Money !’ The proverb hold greater importance these days. Now People need things faster, a study shows 'A two second delay can cause 4.2% loss in revenue.’

A Content Delivery Network (CDN) helps in many different ways. But, It is best known for delivering users a large content (website, video etc) at a fast speed. Therefore, many companies uses CDN.

What is CDN ?

CDN is a network of servers linked together with the goal of delivering content as quickly, cheaply, reliably, and securely as possible.

CDN Servers are Globally located. The globally distributed nature of a CDN means reduce distance between users and website resources. Instead of having to connect to wherever a website’s origin server may live, a CDN lets users connect to a geographically closer data center.

CDN caches (saves) the content near the user. For example, you hosted your website at India. Your business goes viral (Congratulations !!) and now your customers at USA are complaining for huge website load time. To serve them fast,You don’t want setup a server at USA (huge cost + management tentions). So, CDN is your saviour in this situation. It caches the content near US Users. Hence serving faster.

Need Of CDN

We know Internet is a network of networks. Millions of networks are connected to each other via a router.

here the blue elements represents routers
A simple representation of Internet. Here blue boxes inside yellow area represent Routers

So,The request from client to server -

  • Serve them faster - seconds delay can make a company lose their customers.
  • May or may not take optimal path
  • No assurance packet isn’t lost
  • Server constraints - Server may not handle huge concurrent request from the world.
  • Give Customize content for users according to country

Benefits of CDN

There are many benefits of CDN, Which when get hardware support (like use of SSD instead of HDD); doubles the efficiency of CDN.

Improving Website Load time :

By distributing content closer to website visitors by using a nearby CDN server (among other optimizations), visitors experience faster page loading times. Improving Customer Experience and Reducing Bounce Rate.

Reducing Bandwidth Cost

Cloud Provides charge for the outbound flow of traffic from server(VM etc). Through caching and other optimizations, CDNs are able to reduce the amount of data an origin server must provide, thus reducing hosting costs for website owners.

Minification

Via this technique, CDN compresses the file size to serve the request faster. Like removing comments and blank lines from the code.

Other benefits

According to Cloudflare, CDN can also
 - saves roundtrip time
- it sometimes compresss file to save bandwidth
- provides protection against web attacks (like DDOS, Malicious end user )

How CDN Works ?

Generally, A CDN server is located at Network’s Edge (where the user connects to the internet.) Some CDN performs NAT (Network Address Translation) . Later,We’ll see how.

Now when a user requests a content :-

  1. CDN receives the request (from the client) and checks it’s cache.
  2. If available serves it. If doesn’t, then it asks for it from the original server.
  3. After getting response from the server. It caches it with a TTL(Time To Live `meaning when to ask again the server to get fresh content.`)
  4. Serves the content to the client.
  5. For the another same request, CDN will serve it faster. As the content will now be in it’s cache.

Use Cases of CDN

  • Static Content - However, CDN can serve both Static & dynamic content, but I personally tested it’s static content (website, photos, videos etc) serving capacity only.
  • Video streaming - It does really well in serving video content to the customer. By reducing video load time.
  • IoT device - The huge numbers of devices and appliances involved in an IoT solution could easily overwhelm an application’s server. So having a server at Network’s Edge will surely help.

My Practical Experience with CDN

I hosted a my Portfolio website on Amazon S3. It was a Static Site ( having html+CSS+JavaScript + images). I hosted it in North California region (far away from my location, to test CDN). Then I tested the page load time in dot-com monitor.

Now I made it serve via Cloudfront, the CDN service from AWS.

The Cloudfront Served the website faster and compressed it’s size also.

The S3 bucket hosted at a far away location to experience latency
The screenshot of website load time before CDN
Screenshot of website load time after CDN

Conclusion

As we know, there are both positive and negative of everything. CDN is no different. Microsoft Docs beautifully discusses about the challenges of CDN here. Personally, I feel real time testing of CDN is difficult when you are in development stage.

But all the benefits of CDN surpasses it’s challenges. Hence, if CDN fits in your use case, then you must give it a try.

Hope You Like It !!

Let’s connect

--

--

Ananay Ojha

Hey 👋 With this blog I will be sharing my knowledge and experience with Cloud & related fields. Summarised from my own experiences. In a beginner friendly way.