Content Delivery Network (CDN) is a globally distributed network of servers that serve content from locations closest to the users.
Traditionally CDNs served static content files and pre-generated files such as HTML, CSS, JS, image and images. CDNs have evolved since to now serve dynamic content as well, including rich media.
Content served from CDN significantly improves the performance by reducing latency, since the content is served from servers closest to the users. In addition the load on the servers is also reduced since they do not have to serve content that is served from CDN.
Content Delivery Network (CDN) stores cached version of content in multiple geographical locations, known as Points of Presence (PoP). Each PoP contains a cluster of cache servers that deliver content to users closest to that geographical region. If the traffic at a particular PoP is high then you can setup more cache servers for that PoP, and if the traffic is low at another PoP then you can setup just one cache server for that PoP.
example, let's consider that a user from London accesses a website hosted in US. Without CDN, the website will take more time to load for the user because of high latency, i.e the request and response has to travel more distance over the network, very likely making multiple hops.
Whereas, with CDN, the same website will take less time to load for the user because of low latency, i.e the request and response has to travel less distance over the network, since the content will be served from a local PoP cache server.
There are two kinds of CDNs based on how the content is cached and refreshed - Push CDNs and Pull CDNs
Push CDNs - In Push CDN model, content is pushed to the CDN cache servers whenever content is modified, or new content is added, on the origin server. Origin server is responsible for pushing the content to the CDN cache servers
Pull CDNs - In Pull CDN model, content is pulled by the CDN from the origin server when that content is first requested by a client. This content is then stored in the cache servers for a certain period of time, usually 1-30 days based on the TTL, so that subsequent requests for that content is served from the CDN cache server.
Some common CDN providers are Akamai, StackPath, Cloudflare, CDNetwork, Rackspace, Amazon Cloudfront, and Google Cloud CDN
Following non-functional requirements are expected of a CDN
High Performance
CDNs are expected to improve performance by minimizing latency. This is the core responsibility of a CDN. CDNs achieve high performance by -
Availability
CDNs are expected to be highly available. CDNs achieve high availability by -
Scalability - CDNs are expected to scale horizontally as the number of users increase. CDNs achieve high scalibility by -
Reliability - CDNs are expected to respond to massive traffic loads reliably and not have single points of failure. CDNs achieve reliability by -
Security - CDNs are expected to provide a layer of protection to hosted content. CDNs achieve security by -