A content delivery network (CDN) is a bunch of servers distributed across the world which work together to provide fast delivery of internet content.
Why use a CDN?
- Research from fastly shows 20% of visitors leave the website if the page load time is slower than 5 seconds.
- CDNs help you combat the laws of physics. Even if you combat all latency, the max theoretical speed you can serve data is the speed of light. At the speed of light, it takes 200ms to serve content from London to Sydney. How can we serve content faster? Reduce the distance by having a local cache i.e. a CDN.
- CDN is only good for static content right? Mostly yes but CDNs can be used to speed up serving of dynamic content. How? Let’s imagine out customers are 200ms away from origin. SYN + SYNACK + TLS HS + TLS HS + Request + Response will take 200 * 6 = 1.2s. Use a CDN and all those times can be cut down to 20ms (20*6=120ms) and then the CDN would need to forward the request to origin for the dynamic content (200+120=320ms). Public API calls can be cached!
- Layer 3/4 DDOS protection
- Layer 7 DDOS protection
- Inspect HTTP traffic
- Instant visibility in edge traffic
- Edge firewall rules
- Unplanned spikes in traffic due to due to a social or political event, say a x10 increase in traffic. This can knockout a system as the system probably wasn’t designed to handle that kind of sudden spike. Even if you have auto-scaling enabled it would not be able to respond in the short time frame needed. Consider a CDN.
- If your origin goes offline the CDN can keep serving whatever they had cached and the end user wouldn’t notice the outage.
- CDN infrastructure is build more resilient. For example CDNs have may ISPs this enables them to route around problems on the internet. They can also choose the best path between the customer and the CDN and the CDN and the origin.
Most CDNs charge for their services, but the savings on monthly data transfers will typically outweigh the cost of using the CDN.