- Published on
3 Popular CDN Deployment Methods
- Authors
- Name
- Alex Lee
- @alexjoelee
What is a CDN?
This has been covered plenty of times in this blog and many others. A Content Delivery Network, or CDN, is a network of computers around the world designed to serve traffic. This could be a website, application, file, or media content. CDNs cache data that is frequently requested by clients and serve it to them. The idea is to serve more data from a CDN and less from your application server, usually speeding traffic up and increasing scalability.
In other words, a CDN serves data for you, instead of you serving it yourself via a web server (or service like Vercel, etc.) Hosting platforms can have high costs and there are few (if any) benefits to serving static content from your own web server.
Deployment Methods
Most CDN deployments involve changing DNS records to reroute your clients through the CDN infrastructure. There are several different ways in which a particular CDN service might be deployed:
Full-site Proxy
Some CDNs work best when deployed for an entire domain. In this scenario, the CDN provider also serves DNS for your domain.
PROS:
- One less vendor to worry about
- Blends DNS features and CDN features for a more seamless experience
CONS:
- You must use the CDN provider for DNS. This could suck if they suck.
You'll need to log in to your CDN provider's control panel and import or recreate all of your existing DNS records. After that, you'll log into your domain registrar's website and change your nameservers from their existing destination to the CDN provider's nameservers. For example, Skip2's nameservers are below:
ns1.skip2.net
ns2.skip2.net
ns3.skip2.net
ns4.skip2.net
ns5.skip2.net
ns6.skip2.net
Partial or Sub-domain Proxy
In this scenario, you are only creating DNS records and rerouting specific subdomains of your domain. You don't need to change any request URLs on your webpage.
PROS:
- More customizability
- Easier to implement multi-CDN deployments
CONS:
- More configuration and complication
You'll need to decide how you'd like your domain laid out, but for example, you might want your users to go straight to your server for website traffic while keeping image traffic to a subdomain served by a CDN:
www.coconut.com CNAME ec2-54-176-13-0.us-west-1.compute.amazonaws.com
img-cdn.coconut.com CNAME cdn.skip2.net
From the DNS records created above, www.coconut.com will resolve directly to an Amazon EC2 instance, while img-cdn.coconut.com will resolve to the nearest CDN server. The last step is to change your website to start loading assets from the new subdomain. Skip2 can do this replacement on-the-fly, automatically, with our code injection feature.
Separate subdomain
The final method for deploying a CDN is selecting a provider that allows you to use their own domain. This wouldn't require and DNS changes on your end.
PROS:
- Easy to get started
CONS:
- More complicated security implications
All you need to do for this one is set up a new CDN site (for example, coconut.skip2usercontent.com) and then start making requests to that URL. You'll have to change your website to start loading assets from the new subdomain. Skip2 can do this replacement on-the-fly, automatically, with our code injection feature.
Not all CDNs are made equal
Not all CDNs are going to be capable of all deployment methods. Some only offer one type or another, with many providers not offering a DNS service. Keep this in mind when you're shopping around for infrastructure providers and remember that some networks may have newer and better features than the last one.