A content delivery network (CDN) is a network of servers in many cities that keeps copies of a website's files near its users. It is also called an edge network. A visitor receives the pages, images and videos from a nearby server, instead of from the website's own server far away. Most CDNs also block attacks in front of the website, and many now run code and store files as well.
Why does distance matter? Data in a cable travels fast, but not instantly. A request from Guwahati to a server in Mumbai and back can take about 60 milliseconds. A millisecond is a thousandth of a second. A product page may need 40 images and other files, and each round trip adds its own delay. So the delays add up to seconds. The page on bandwidth and latency explains this delay, which is called latency.
Consider a handloom saree brand in Bhubaneswar that sells online. Its website runs on one server in Mumbai. In CDN terms, this is the origin server, the place where the original files are kept. The brand moves its DNS to the CDN. Now a shopper in Guwahati opens the site. DNS sends her phone to the CDN's nearest server, say in Kolkata. That server checks whether it already has a copy of each file. The first time, it does not. So it fetches the file from Mumbai, sends it to her and keeps a copy. The next shopper in the north-east receives the copy from Kolkata in about 15 milliseconds. Each copy is kept for a set time, such as one day, and then fetched again. When the brand changes a photo, it tells the CDN to delete the old copies everywhere.
During a Diwali sale, ten times as many shoppers visit the site. Most of their requests are answered from the copies. So the server in Mumbai receives only a small part of the load.
The CDN's servers stand between the internet and the website. So they can stop attacks before the attacks reach it. DDoS protection absorbs floods of fake traffic. A web application firewall checks each request for known attacks. Bot management turns away programs that pretend to be shoppers.
CDNs have grown into clouds of their own. Developers now run small pieces of their app's code on the CDN's servers. These are called edge functions. Developers also store files there, and some host whole applications without renting a server at all. Akamai, which built the original CDN, bought the cloud provider Linode in 2022. Running computing close to the user like this is called edge computing.
Video is the largest use of CDNs. A streaming service sends its films to millions of phones through them. A cricket final needs extra capacity for a few hours, as the page on live streaming at scale explains.