What is a CDN? (Content Delivery Network)
If your server is in New York, a user in Tokyo has to wait for data to travel halfway across the world. Speed of light limits mean this will always have latency (lag).
The Solution: CDN
A Content Delivery Network is a network of servers distributed globally.
- Origin Server: This is your main server (in New York).
- Edge Servers: These are CDN servers in Tokyo, London, Sydney, etc.
How it works
- The first time a user in Tokyo requests
image.jpg, the CDN in Tokyo fetches it from New York. This is slow. - The CDN caches (saves)
image.jpgin Tokyo. - The next user in Tokyo requests
image.jpg. The CDN serves it immediately from the Tokyo server.
Benefits
- Speed: Lower latency for users.
- Reliability: If your main server crashes, the CDN can often still serve cached pages (like a "Site Offline" version).
- Security: CDNs often block DDoS attacks (floods of fake traffic) before they reach your server.
Common CDNs include Cloudflare, AWS CloudFront, and Akamai.