The Underlying Issue
Popular sites generally have a lot of content and many visitors simultaneously. During peak hours this can place heavy stress on an under-powered server environment, leading to slow performance or potentially downtime. Since the rise of widespread residential and commercial broadband adoption internationally, numerous solutions had been found to mitigate or prevent this issue entirely.
On one end of the spectrum is the website Craigslist.org which is hugely popular in terms of US-based traffic, but the website itself is extremely lightweight to minimize memory and bandwidth usage. In contrast, top 50 websites like Reddit and Imgur regularly go offline as a result of their massive popularity. Whether the downtime is a result of a specific traffic spike, malicious attack or website configuration issues, the result is almost universally negative. Everyone knows it is imperative that the website’s performance is guaranteed. To make sure that a website continues to perform well under load we can distribute static website content to multiple servers across the globe. With the use of a reliable content delivery network (CDN) many traditional hosting concerns are eliminated. In this post I will address the less technical aspects of CDNs and provide some basic use case examples.
What is a Content Delivery Network?
A CDN is a large networked system of multiple synchronized servers, usually constructed in different locations worldwide. It is primarily used to deliver content in a quick and efficient manner to each unique website visitor. A few major commercial suppliers of CDNs are Akamai, MaxCDN, Fastly, Limelight and Amazon CloudFront. There are also free or low cost CDN providers like CloudFlare and CDNify. The NationBuilder platform is deeply integrated with CDN technology from the start, and WordPress offers the functionality through extensions.
How it Actually Works
A CDN encompasses multiple server locations all over the world to save files from your web site and make virtual copies. In principal the smaller the distance between the visitor and the server, the faster the content will be transferred to the user. Specifically, the lower the latency between the web server and the user the better. A CDN gives us the ability to intelligently shift traffic in a more efficient manner. Since we cannot control a users location or internet connection speed, its the responsibility of the admin to do everything possible from the server side. So, we try to connect them to the closest possible server without the user ever noticing the network shift.
A reason why I encourage the use of a CDN is the guarantee of nearly constant up time. If your primary server is offline for a technical issue with your hosting provider, the static content will remain temporarily visible on the CDN infrastructure. Depending on the website configuration it’s possible that small downtime on your master server may actually go completely unnoticed to the outside world. This is perfect for religious, political and social organizations which may become subject to a distributed denial-of-service (DDoS) attack. Since you do not have a single server or IP address than can be easily overwhelmed, the likelihood of a low level attack taking down your site is virtually eliminated.
Why Should You Use a CDN?
- Location aware: By using a CDN, visitors can automatically fetch content such as images, heavy scripts, and video from a nearby server. You can imagine that it takes longer for a visitor from Europe to load an image off a server based in the United States than it takes for a local. By keeping a cached copy of the static content on a site closer to the visitor, the page will be more quickly displayed.
- Faster routing: Usually the network connections between a visitor and the web server go through the path of least resistance. However, this is not necessarily be the fastest possible route. CDN providers often choose slightly more expensive but faster routes over the internet. Compare it with a toll road. You pay for it, but it is generally the superior option.
- Constant availability: The design of a CDN with multiple servers in different locations is much more resilient than a traditional website which is subject to downtime due to a single piece of equipment failure.
- Less (primary) load: Since copies of the content are stored on other servers, your primary web server does not always have a large number of clients to host. This means that you can technically continue to run a shared or virtual private server (VPS) as a low cost master, and have the bulk of the work performed by a separate CDN service. More RAM, processing power, and faster drives will certainly help, but you can get by without them to test the advantages before migrating.
What Are The Possible Downsides?
There are a few drawbacks to using a CDN. Until recently, implementation of a basic CDN still required extensive planning and time spent on integration. Today you can be running in a couple hours, so the main concern becomes the additional ongoing running cost. After all, it takes massive infrastructure for all those dispersed servers and a lot of power to keep the hardware running 24/7.
I often see a hybrid solution, where the CDN is mainly used for clunky assets and the actual HTML content is directly pushed by the master web server. In the source code you will see a different domains for the specific assets, such as d1abcdef8.cloudfront.net. This works well as an intermediate step for small or growing websites that don’t expect to see massive traffic bumps. This combination leaves you more susceptible to downtime when something on your website goes viral. Still, the CDN can present vast improvement for website load time and availability across the board.
Why Bother Deploying a CDN for Your Website?
Scenario 1: Receiving traffic from different continents.
Take a look at your recent traffic and see where your viewers are actually located. If your website receives views from abroad then a caching or CDN solution will definitely help expand those markets. An Amazon S3 storage solution or purpose built WordPress host like WPengine will be worth considering.
Scenario 2: Getting media attention and unexpected social network traffic.
If your web server cannot keep up with a sudden rush of simultaneous sessions it may go temporarily offline at the worst possible time. A caching and CDN solution will definitely help out.
Scenario 3: Your issue attracts unwarranted negative attention.
No matter what issues you cover, it’s possible to become subject to a variety of online attacks. Spam and trolling are common and can be defeated easily. However it takes more planning to prevent a sophisticated attacker from taking down your single web server. A scalable CDN offering will negate a disruptive attack and the pricing adjusts based on need.
Scenario 4: Planning for future website growth.
If you’re seeing rapid viewer growth it makes sense to take a proactive approach for serving those people. WordPress sites can be converted to a rudimentary CDN in minutes with plugins so now is the time to try it out if you haven’t before.