CDN (Design)
Main benefit of using CDN is
- low latency
2. Reducted load at your main servers (Origin Servers)
3. scalable service and fault tolerance
Listen the following video for a very general overview.
How netflix switched to their own CDN infrastructure
What CDN is good for.
Every CDN server is called a edge server. It can pull the resouce on demand or you can actively push it.
Hosting media (pics/videos/js files) in CDN a good idea
You can never have dynamic content served from the CDN. Hence you can’t do any authentication or autorization for the CDN resources. The whole CDN system is build for delivering the static content (straigth from HDD/SDD). (media/pictures/large software packages)
CDN usage anycast to route user to the nearest available (geo) datacenter.
Security
The website just generate a large token for each resource and if you anyone knows the token they can access the resource from the CDN. Video content can be make in properitry format so no one can access it unless your player plays it (which will check for the license). Same with the software distribution through CDN. You allow the download free but people who do not have the license cant use it.
CDN and TSL/SSL (Adding security to the content: FB usage this)
https://www.cloudflare.com/learning/cdn/cdn-ssl-tls-security/
Methods
CDN push or pull
Mechanism
Your website specify resource (links/images) of cdn server eg here is a link in FB site for its private CDN.
https://scontent-lax3-2.xx.fbcdn.net/v/t1.0-9/<resource_id>
When The CDN sees this it and dont have the content it will cache is first time (pull) and serve it. (pull CDN, most widely used)
read the folllowing stack overflow