What is a CDN [Content Delivery Network]?
CDN stands for Content Delivery Network, Its a network of distributed servers which is used for delivering content in the most optimal way and improves end user’s performance. It can be as simple as a simple Caching server and as complex as a caching server with web application firewall and streaming software integrated into it and running ESI engine.
Why CDN is required?
The internet we use today is not optimized for data transfer across it and there are many players involved for the transfer of data packet from one part to another. The routing protocol used is BGP and it is not the best protocol for performance. It does ensures that Inter works but does not guarantees the optimal performance. Also, the hardware involved in delivery is not elastic in nature and thus it is one of the bottlenecks in the entire cycle of request and response across globe. Lets discuss the problems one by one in detail:
- Problems on the Path
Since the Internet is made up of network of networks, and these networks talk to each other using BGP protocol, they do not work in the most optimal way, but rather on their business needs. Thus the path taken by the packet to reach from one point to the another might not be the most optimal path and thus, the round trip time taken by that packet might be more than the optimal value.
Internet is made up of network of networks and The Optical Fiber which connects the different networks across the globe can break and does it may result in Internet outages. There may be some device at some place the can be malfunctioning and cause packet losses. This can negatively impact the end users performance
- Resource Constraints
There is a limitation to the server resources, like the bandwidth of the connecting pipe, the RAM, the computing power of the server etc. Hence it can handle only limited number of concurrent connections. Imagine a situation when there is a flash traffic caused due to certain campaign, or certain event, starts hitting the server at the same time. This may result in server failure, or the actual user not able to get the services from the server, causing denial of service.
How CDN helps?
CDN tries to find its own best part to route packets from one location to the other, resulting in the better reliability. It also detects the packet loss happening at one place and re-route the packets using other alternate routes available to ensure that the packet is not lost while transmission, or it is not routed through the part which is congested right now. In case of outages, it routes the packets using alternate paths available.
In the event of any special campaign or sudden traffic flow, the customer do not needs to increase the server resources multiple times, but it will use the CDN servers to deliver the content to the excessive amount of end users.
Static and Dynamic Content
A website is made up of Static and dynamic objects. Any object which does not change based on the user, or its location, or time, is considered to be static in nature and they are called static objects. Dynamic objects are those objects which are unique for different users and does not remain static or change is very frequently every now and then considering the dynamic nature of the object these objects are called dynamic objects.
Accelerating Static Objects
CDN servers are located at the edge of the Internet, or near to the end users. So when the user connect to a CDN server to fetch the content, the CDN server check the presence of that object in its cache. If the object is found in the cache, it will deliver to the end user’s request. If not, then it will go to the origin to fetch the object from the origin and then cash a copy of it, and then deliver to the end user. Subsequently, in future is another user requests for the same object, the object is readily present in the CDN cache, and it and will cater the request from the CDN cache itself. The request will not end up going all the way to the origin server, which results in very less round trip time. Also, the server resources are saved, thus overall improves end users performance.
Accelerating dynamic contents
For dynamic content, it is sure that the object will always be fetched from the origin server, and that the end users’ requests will always go from the end user computing device to the origin server. There are many intelligent CDNs in market which very smartly identifies the best part to be chosen for packet transfers to accelerate the dynamic content delivery.
Other features of CDNs
There are many others smart features of CDNs, like competition and security. When the end user is trying to fetch the content from origin server, the request first lands upon CDN server. So its up to CDN server to decide whether it wants to serve a compressed object, for example a GZIP compressed object. If needed CDN can smartly detect the screen size or the network connectivity speed of the end user, and deliver the optimized image for that request. In case of Cyber attacks like DDos attack or SQL injection attack, or any other web application attack, it can stop these attacks hitting the actual origin server and block these malicious requests at the edge itself, and protect the website.
I hope this post explains the basics of What How and Why for CDN [Content Delivery Network]. In case you want to watch the video on it, you may see the following