What Is A CDN? How Does a CDN Works?
What is a CDN? Why should we developers all take advantage of it?
Let’s take a look. CDN, or content delivery network, has been around since the late 90s.
It was originally developed to speed up the delivery of static HTML content for users all around the world.

CDN
Has evolved over the ensuing decades. Nowadays, a CDN should be used whenever HTTP traffic is served.

What can a modern CDN do for us?
Let’s take a closer look. At a fundamental level, a CDN brings content closer to the user.
This improves the performance of a web service as perceived by the user.
It is well-documented that performance is critical to user engagement and retention.
To bring service closer to the users,
CDN deploys servers
At hundreds of locations all over the world.

These server locations are called Point of Presence, or PoPs.
A server inside the PoP is now commonly called an edge server.
Edge Server
Having many PoPs all over the world ensures that every user can reach a fast-edge server close to them.

Different CDNs use different technologies to direct a user’s request to the closest PoP.

Two common ones are DNS-based routing and Anycast.

With DNS-based routing,
Each PoP has its own IP address. When the user looks up the IP address for the CDN, DNS returns the IP address of the PoP closest to them.

With Anycast,
All PoPs share the same IP address.
When a request comes into the Anycast network for that IP address, the network sends the request to the PoP that is closest to the requester.

Each edge server acts as a reverse proxy with a huge content cache.

Static contents
Are cached on the edge server in this content cache. If a piece of content is in the cache, it could be quickly returned to the user.
Since the edge server only asks for a copy of the static content from the origin server if it is not in its cache, this greatly reduces the load and bandwidth requirements of the origin server cluster.

A modern CDN
Could also transform static content into more optimized formats.
What is a CDN? Why should we developers all take advantage of it? For example, it could minify JavaScript bundles on the fly, or transform an image file from an old format to a modern one like WebP or AVIF.


The edge server also serves a very important role in the modern HTTP stack.
All TLS connections terminate at the edge server.

TLS handshakes are expensive.
The commonly used TLS versions like TLS 1.2 take several network round trips to establish.
By terminating the TLS connection at the edge, it significantly reduces the latency for the user to establish an encrypted TCP connection.

This is one reason why many modern applications send even dynamic, uncacheable HTTP content over the CDN.
Besides performance, a modern CDN brings two other major benefits.

First is security.
All modern CDNs have huge network capacity at the edge.

This is the key to providing effective DDoS protection
Against large-scale attacks – by having a network with a capacity much larger than the attackers.

This is especially effective with a CDN built on an Anycast network. It allows the CDN to diffuse the attack traffic over a huge number of servers.
Second, a modern CDN improves availability.

What Is A CDN? How Does a CDN Works? A CDN by its very nature is highly distributed.
By having copies of contents available in many PoPs, a CDN can withstand many more hardware failures than the origin servers.

A modern CDN provides many benefits. If we are serving HTTP traffic, we should be using a CDN.