What is CDN?
CDN is short for Content Delivery Network. A CDN in simple terms is a collection of servers that are spread across the globe. In other words, a CDN is a network of servers in which each request will go to the closest server.
Why Do We Need CDN?
For any web application, data can be categorized into either static or dynamic content. Dynamic content is the one which generally comes from a database. Static content is the one like CSS, images, JavaScript, flash files, video files, etc.Now one may ask, how are requests served when a user enters an URL in the browser? Interesting… let’s take a look at it. Before knowing a CDN and its usage, it is very important to understand this process.
How is a Web Page Served?
When a client requests any URL, let’s say www.google.com in the browser, there is a server configured to listen to any request that comes in for www.google.com. A server in turn performs some computations and sends raw HTML back to the client.Raw HTML contains lots of links like CSS, JavaScript, etc. Now for each and every link (CSS, JavaScript, etc.), the client will make more requests to other servers, which means for each and every static resource, the client will make a request to the server. Now one can easily imagine the number of requests sent for a single web page. You can view this by using any of the debugging tools.
In case of a small website, all these requests are served from a single server. So, a single client is having many connections with the same server.
For a server to be serving millions and millions of requests, it may run out of resources. Can’t we optimize something here?
If you will look at the figure shown above, the points marked in red are the intermediate nodes which serve free of cost and nodes at both ends fall in the paid category. We may have very good bandwidth at the first and last node but those intermediate nodes hardly guarantee for any performance or throughput. In essence, the further the user is from our infrastructure, the more he will notice these performance issues.
A CDN has been designed to solve all these shortcomings. There are many CDN providers available in the market today (i.e. Akamai, Interwoven). One of the CDNs that I worked with is KeyCDN.
KeyCDN
KeyCDN has points of presence (POPs) all around the world. So, whenever a request for a webpage is submitted by a client, it will go to the closest server available. In this manner, your request doesn’t need to go a long distance plus there won’t be many number of requests between the actual server and the client. KeyCDN also provides various ways to control your settings including delivery status and reporting. It also has a very intuitive dashboard and the most impressive thing is, it is affordable!A CDN will deliver all the static content. So, actual dynamic content is kept on company’s server and the static content is redirected to CDN provider. So, there are multiple advantages of doing this.
Advantages of using CDN
- Client request will go to the closest POP to get the static content rather than going all the way to the web server.
- The actual web server will have more bandwidth available as the CDN takes a lot of load.
- Failover: In case a server goes down, the CDN will automatically reroute the traffic to the next available server
- The biggest advantage is caching. Whenever a request comes in for the first time, the content will be cached on an edge server. When the next request comes in, it will read the data directly from its cache.
Comments
Post a Comment