DEV Community

Cover image for Content Delivery Networks and You
arindavis
arindavis

Posted on

Content Delivery Networks and You

Imagine for a moment that you are your favorite piece of media. You might be a song, a tv show or even Irving Kershner's 1980 all time classic, Star Wars Episode V: The Empire Strikes Back. As a popular piece of media existing in the golden age of streaming, you most likely exist on a server somewhere in the midwest United States (Don't @ me, Disney. I don't actually know where you keep your secrets).

So, what happens when someone wants to watch you in Tokyo, Japan? Do you travel the roughly 5,000 miles through the Pacific via seafloor cables, accumulating increasing amounts of latency along the way? In today's day and age, most likely not. Instead, your content provider probably has implemented a CDN to get you there a lot faster.

CDN is short for Content Delivery Network. It's a term used to refer to a global system of redundant servers designed with the purpose of cutting down on the latency between a domestic host and a client on the other side of the world by utilizing a unique form of caching.

Notice that I used the term redundant, which might set off more than a few negative alarm bells in your primal, efficiency obsessed programmer brain. But in this use case, redundancy is actually the primary advantage. It ensures that if one point of the network goes down, there is immediately another edge server to take its place.

image

By increasing redundancy, we are also decreasing the maximum possible load on the original server by avoiding network bottlenecks before they even happen. This will also present an obvious security benefit when configured correctly, as attackers from across the world would only have immediate access to their nearest edge server, and not the root server.

Another big advantage here is speed.

image

Content will load significantly faster if it's coming from a CDN within your own country, opposed to being laboriously beamed from halfway across the world. This makes a huge difference in combatting streaming latency and will always result in more responsive media, whether it's audio, video, or even just loading elements into a simple html site.

So how might you, the budding software dev, utilize a service like this? Well, it's actually a lot simpler than you might think.

For the sake of providing a practical example, I'll walk you through some of the basic steps of setting up your site with cloudflare, a CDN service with a pretty robust free option. First, you'll want to sign up for an account, then add your site when prompted.

image

Then, it'll take you through a series of steps including choosing your membership level, giving you a list of associated DNS records, then prompting you to link your account from wherever you registered your domain. It may take a day or so for this step to complete, so just be patient.

Finally, you'll want to dynamically link cloudflare to your site in the src script tag of your HTML file, which will probably end up looking something like this:

image

And voila! Your site will now be more secure, faster and more accessible to the world at large, all at no or little cost to you.

Before we part ways, here are a few videos that may help you understand CDN's in a broader context, as it is hard to explain everything in one short blog post. Simply put, CDN's are fast, secure and increasingly needed in modern web design.

Top comments (2)

Collapse
 
lola_tray profile image
Lola Tray Rosendo

CDN is coolest thing
I set up a CDN for a WP site without plugins. G-core has an absolutely cool theme, you can connect a CDN through DNS integration in literally three easy steps. If interested, I can tell you more, or you can look at the guide on their website. Cloudflare will have to tinker a lot with plugins and settings.

Collapse
 
dasanasak profile image
Dosa Nasyak

G-Core is nice for working with the European market since they have a lot of CDN locations there. We work from the US and all the cache is on our servers here, but most of our visitors are European. So when looking for CDN in Europe we didn’t think twice. They have nice prices - we pay 100 EUR per month for a 5 GB traffic plan.