The process of getting started with the CDN service in general looks as following:
- Choose your CDN Provider
- Sign up for a CDN account
- Prepare a CDN Delivery Configuration
- Test the CDN configuration
- Redirect your website’s traffic to CDN network
- Perform post deployment tests
- Monitor and maintain your setup
Sign up for a CDN account
Some providers like Akamai don’t allow for self-registration and you need to contact a sales representative to start the journey.
Others like Cloudflare offer an easier and faster way to start by filling out their registration form. After the registration you can start with website onboarding.
Prepare a CDN Delivery Configuration
CDN Providers offer a variety of services and features improving performance, reliability and security of the web delivery. They also offer you analytics tools, integration API-s, network, assets optimization, application level firewalls and many more. Those features need to be configured and fully tested for your website which require some domain knowledge and can take a remarkable amount of time (depending on the scope and the complexity).
Some of the providers (e.g. Cloudflare) offer a simplified onboarding process so you could get your website on their network in just a few hours or even minutes - this will give you a very basic and limited set of benefits like a basic caching and DOS protection. But if you decide to use the CDN, certainly you want more than this - thus there is a next phase ahead of you - going through the features and configuring those manually (or perhaps working with your DevOps team to prepare some more advanced setup by utilizing CDN’s configuration API).
Although the offered features are similar for the top CDN providers, the way how you configure those is different for each of the companies.
Test your CDN configuration
From the beginning we would like to point out that testing the CDN setup is not just checking if the website is up and running. There are multiple aspects that need to be considered depending on the complexity of your CDN configuration, the features used, of your website’s architecture and flow.
Some of the general guidelines to consider when preparing your test scenarios are:
- Check if the user’s traffic flows through the CDN network
- Check if your users get connected to the geographically nearest CDN servers
- Check if the static assets (images, js, css, fonts, any static files) are cached on the CDN’s servers with the configured Time-To-Live (TTL).
- Check if the dynamic pages or API’s endpoints (if applicable) that are allowed for caching are cached
- Make sure that the pages containing a personal information (including session pages, real-time data) are NOT cached
- Make sure that login and sign-up processes work properly
- Make sure that the logged-in users have an access only to the allowed resources
- If used, check the Web Application Firewall protection by issuing test requests containing malicious payload
- If security protections like WAF are used, check if there are no False Positives occurrences
- Check the web delivery performance by monitoring/testing your website from multiple locations around the world (the delivery performance may vary depending on the geo location)
Best practice is to have a separate test environment (e.g. staging) where you can deploy a changes in your setup and test it without any risk of affecting your real users and your business.
Redirect your website’s traffic to CDN network
When your tests are successfull and you are ready to go ahead and enable your CDN for your website on the production environment, the next step is to redirect your user's traffic to the CDN cloud.
In order to get your website running on CDN, you need to have an access to your website's DNS (Domain Name System) configuration so you could point your domain to the CDN's servers.
There are two ways to direct your traffic to the CDN:
1) Name Servers (NS) change
For some CDN (like Cloudflare) you need to your your existing nameserver (NS) records to CDN provided nameservers. This critical final step should take a few minutes. Downside of this approach is that you give a full controll of your DNS configuraition to the CDN operator.
2) Use DNS CNAME
Operators like Akamai or Fastly use DNS aliasing method to point your domain to the CDN's cloud. In this method you only create or change your DNS CNAME record to have it pointed to another hostname (so called edgehostname) provided and operated by the CDN. This edgehostname plays a role of an entry point to the CDN cloud for your hostname.
Here is how this is done for akamai.com:
;; ANSWER SECTION:
www.akamai.com. 287 IN CNAME www.akamai.com.edgekey.net.
In this case, when an end user runs your website, the browser performs the IP resolution process, during which the resolution is handed over to the CDN's nameservers. CDN knows the user's locatoin (actually it is the DNS resolver's location) and are capable of returning the IP-s which belong to the nearest CDN's servers to the requestor. This allows for optimal allocation of the CDN servers to the user based on his geo location, traffic condition and also based on the actual load on the CDNs servers.