Speed, speed, speed! We all want our sites and applications to load as fast as possible. Each moment of delay might make your visitors go away. So one of the most common approaches to increase the speed of a website is to use a Content delivery network (CDN). But how to create a CDN?
What is CDN?
The content delivery network is what the CDN abbreviation is. It is a complex solution that focuses on delivering content to visitors faster by using routing and cache methods.
There are DNS servers that server that will check the origin of the request and redirect to the closest cache server shortening the length and time of each request.
How does CDN work?
The idea is simple, there are DNS resolvers on the way that analyze the DNS request, and based on the origin of the request, they will provide the IP address of the closest cache server (called delivery nodes by some service providers).
Those DNS servers are strategically located. Depending on your DNS provider, you can have many and put more in your most important region.
Instead of having Anycast DNS, where all of the DNS servers have the same IP address, here you can use a service called GeoDNS or Traffic Director (depending on your provider) and set different IP addresses for the different regions.
That way, you won’t send all of the traffic to the same origin. You can have a second or third web hosting located in those important places for you.
You will use those servers as cache servers, and you will put their IP addresses for the DNS server nearby.
That way, the DNS request will go very fast to the first DNS resolver that can provide an answer, and after that, it will redirect to the cache server and saves a ton of time.
How to create CDN?
- Choose a CDN provider or check a combination between GeoDNS and web hosting.
You can go straight to the big could like MS Azure or Amazon’s AWS and get a CDN from them. It will probably work fine, but it could be a lot more expensive.
Another option is to get a Managed DNS service and a few web hosting services at the locations that best suits you. That will save some money, and you can be less dependent on a single provider.
- Set up your web hosting servers.
No matter which option you have chosen, you will need to decide where you want to have your data. Make it closer to your users so they can load your content fast.
You will need to get the IP addresses of the servers you have chosen and later use them with your DNS settings.
In your DNS, you will need to create a DNS load balancer. You must choose points of presence, where you will have a DNS server with DNS records. You will need to add the appropriate DNS records, use the server from before, and redirect the traffic to the closest server.
- WordPress settings for the cache plugin
Now that you have set up your CDN, you need to adjust your WordPress site. Use a cache plugin. In it, you need to enable page cache, stop minifying, enable database cache, stop object cache, enable browser cache. And the last step is the most important, enable CDN and choose the CDN type.
It is not really hard to create a CDN. Based on your provider, you will have different steps, but the basic idea is the same. Create one and enjoy the benefits.