A CDN stands for Content Delivery Network. It has one job. To get your website as close as possible to your users.
It can make all the difference to your page speed by storing a copy of your web pages in the cloud.
We are going to look at what is a CDN, how they work and some of the providers on the market.
Let's get started
What is a CDN and How do they Work
Let's start with an example. Say you have a WordPress site that you have been running for years. It is a single web server with all your blog posts on it.
Over the years the site has been gaining in popularity. One day you have trouble with the server and your website goes down. It turns out you got a link from the New York Times and the webserver could not handle the traffic.
Working with your hosting provider you manage to get the server back up again and the site is working. Your hosting provider offers you a larger webserver. At the back of your mind you know there must be a better way.
You have also had reports from users that the site is slow to load. A friend recommends that you look into a CDN.
But, how will a CDN help?
CDN's work by making a copy of your website (caching) and storing it on many servers around the world. When a user visits your website they will see the version at their nearest CDN. No need to send a request to the webserver.
It looks a bit like this:
Every time a web page gets updated the CDN sends the new file around the world.
If you don't have a CDN then when your users visit your webserver they may have to travel a long way. The performance will be slower like this:
By adding the CDN you will move your web pages closer to the user making for a better experience:
Let's look at some of the benefits of using a CDN.
What are the benefits of a CDN
CDNs have evolved over the last 10 years to become very sophisticated and offer a lot of features. Yet, they all share the same benefits, such as:
A CDN will keep your site working even when your webserver is down. This is because there are copies of your web pages on many servers all over the world.
This means that your website it available more of the time. This is uptime. It is often measured in percentage so you will see figures like 100% uptime. 100% means that your site never goes down.
One of the main metrics for page speed is TTFB (Time to First Byte). This measures the time it takes for your server to respond to a users’ request. If your server is in California and the user is in London it will take time to download the page. The TTFB will be greater.
If you use a CDN then a London server will have a copy of the web page. Now the users’ request only has to travel a short distance. Reducing the TTFB and making the web page load faster.
CDNs also have features to optimize images and compress files. This makes them smaller as they travel over the internet. The smaller the file, the faster to download and display.
Scale as Users Grow
When you have a single web server it can only handle a certain number of requests each second. For example, on our WordPress site above we were struggling to handle the traffic.
When your site gets lots of traffic it may get to a point where your server cannot handle it.
Chances are the server will fail and not respond to the requests because the CPU and memory run out of space.
A CDN can solve this and does so in two ways:
There is a copy on many servers spreading the load
A CDN does not have to work as hard to process the request so can handle many more users than your webserver
If your web site is growing and there is a chance that you will get a sudden traffic increase then you must have a CDN.
It is more important than ever to have a secure site. With security attacks on the rise, you must protect your website. Security is difficult and if you can you want to give the task to the experts.
All CDNs have security built-in. You will get an SSL certificate for your website with the latest security protocols. There is nothing for you to manage as the CDN takes care of it.
Assets on your website are media files such as images, video and audio files. These files are larger to download and can take more time. The faster these files are the better the user experience.
For this reason, many CDNs have features that will optimize your media files making them fast.
For example, some CDNs will reduce the size of your images to make them quicker. They also can show different versions of a video each optimized for the user's download speed. The faster the download speed the better quality video.
These advanced features are very useful if you have a media-heavy website.
Now we know why we should have a CDN. Let's look at some CDN Providers.
A CDN Provider is a company that provides a content delivery network for your website. To set them up you will need to tell them where your webserver is.
You will also need to set up your DNS so that it points to the CDN instead of the webserver. This is what the site architecture will look like:
Changing DNS records is not instant so you will need to have a window of a few hours to make the change.
The amount of bandwidth you use will determine the price. That is the amount of traffic your website gets each month. The more popular your website the more expensive per month.
Let's look at some of the most popular providers and their key features:
BunnyCDN is the cheapest CDN in this list yet it has many of the features of the others.
The performance of BunnyCDN is better than KeyCDN. Yet it is slower than both Cloudflare and Fastly.
If you are on a tight budget and need a CDN, this is a good place to start.
KeyCDN is a great first CDN for new websites especially WordPress blogs. KeyCDN has many features such as HTTP/2, Brotli compression and image optimization.
Their base tier starts at around $40 per month for 1TB of data. So it is more expensive than BunnyCDN but you should compare these two when choosing.
This is the slowest CDN on the list but not by much.
KeyCDN is a good all-rounder it is more established than BunnyCDN.
Cloudflare has a free option to get started. Although the free option does not include some of the image optimizing tools.
They are one of the main players in the market with one of the easiest setups. They have features like edge computing which allows you to run code within the CDN, yet this is a paid for feature. The paid plan starts at $20 per month but you will pay extra for bandwidth.
1TB of data will cost around $80 per month. Twice of KeyCDN.
They are not the fastest CDN here. They are a good choice if your website is growing and you have developers working on your site.
Fastly, is fast. The clue is in the name I suppose, according to CDNPerf it comes in as the fastest CDN.
Yet, this comes at a price. 1TB of bandwidth will set you back around $120 per month.
It also is one of the most difficult to set up. Yet, if you have the tech skills Fastly is also the most flexible. You can do almost anything with this CDN.
Wrapping Up, What is a CDN?
They offer many benefits including:
Scale as Users Grow
Control of Assets
There are many CDN providers available each with their pros and cons. Here are some that we recommend:
BunnyCDN - The cheapest option with the most features
KeyCDN - Compare with BunnyCDN as they are very similar but KeyCDN has been around longer
Cloudflare - Very flexible and good for a growing website