top of page
Writer's pictureRohit Modi

System Design : Content Distributed/Delivery Network aka CDN

Hi, a warm welcome to tech-maze, in todays article we will see how Content Distributed/Delivery Network also known as CDN help us to manage our application globally and improve performance by separating out the concerns.


So what is the need of CDN, without CDN too an application can run properly, the answer will be, an application can run properly but there will be time lag in the loading of pages, slowness in navigation which has taken up quite seriously now a days and user may give up using application.


The reason behind the slowness of application is, suppose a company launched an application such as a commercial site for shopping and it has spread its business in multiple countries.

If company host their server (all request processed here regardless of the location) only at one place lets say in USA and a person trying to access this from India, then this request will start traversing on network from India, it will pass many network hops provided by multiple ISP's and then it reaches to US server, same process gets repeated for sending back the response, it easily takes min 3 seconds to 5 seconds to load a page but in USA same page loads in milliseconds.

If wait time increases to load the application, user's interest drastically go down and user start looking for alternatives, which is not good for the business.


CDN is used to solve these issues, lets check following diagram to understand how it solves these issues.



CDN host static data such as JavaScript, CSS, images, html pages, video, audio etc.

it is provided by Internet Service provider, ISP provides a server where static content stores locally based on location.


server which host the CDN has Cache memory, which contains the static data, all CDN is connected to actual server which is also known as source of truth or main server.

Actual server which is in USA, contains all the dynamic contents along with static content, so this server is configured to run a cron job every 24 hours, whenever there is a change in static content it pushes all these changes to CDN servers, so that CDN servers must be up to date with the main server, this is one of the technique used in this setup, lets checkout how many ways we have, to keep Cache server connected to CDN in sync with main server.


there are two technique which actually used to do sync up between CDN cache server and main server


Push CDN :


main server pushes the changes into CDN cache server via cron job which runs every day or time to run can be configured based on the frequency of changes.



Pull CDN :


CDN pull the information from main server and pushes those changes in cache server via some notification mechanism.



The information which CDN stores in cache memory, tagged with TTL (time to live), so for a particular time period these information will be valid after that CDN pulls the information from main server and update the data in cache server or main server push the changes into cache server via CDN.

Generally TTL defined for 24 hours but based on the number of request, users, frequency of change, this can be altered.


So now we understood that the main purpose of CDN to improve the customer experience and application performance, but suppose in a particular geographic location CDN gets overwhelmed by lot of request, how can we handle this scenario.

The answer is, we can have multiple cache server connected with load balancer, load balancer can manage load judicially so that no server will be flooded by lot of request, in this way we can solve this issue.

For more details related to load balancer, please visit earlier articles published on the same platform, below are the links



Companies which is in cloud they use their own CDN, but rest of the companies who wants to use CDN service, they need to contact cloud service provider such as Google, Amazon, Microsoft, Oracle etc.

Following are the most popular CDN used by the companies


Azure CDN

AWS Cloudfront

Cloudflare CDN

Oracle CDN

GCP Cloud CDN


There is one down side with CDN, i would say limitation instead of down side that CDN can only host static data, but since most of the application or upcoming application which has potential to grow globally tends to use CDN, there was/is a demand to load dynamic content too via CDN.

Few cloud provider has come up with a solution where CDN runs a script (JavaScript, typescript etc) which fire a request to API, fetches the data and populate on clients browser.

This is one of the way to get the dynamic content, approach is good for less amount of data, accommodating large data will create lot of problem hence organization who has implemented this approach, populates less amount of dynamic data at client side via CDN.

Research is still on for better way to load dynamic content through CDN, hopefully in future we will see multiple ways to do this based on the volume of data.


That's all folks in this article, keep visiting. Feel free to share this article and share your suggestion/thoughts in comment section.


A Big thank you for checking out my article, this really encourage me to come up with more topics.

85 views0 comments

Comments


Spring Boot
bottom of page