Would you like to discuss your environment with a knowledgable engineer?
Here we demonstrate how you can create your own Content Delivery Network with aiCDN running on Amazon EC2 and Amazon Route 53 DNS. Strictly speaking, aiCDN is actually an Application Delivery Network (ADN), altough the differences between ADN’s and CDN’s is rather arbitrary. This tutorial also works well for fighting off large DDoS attacks (20Gbit+), in which case it’s useful to (temporarily) distribute traffic to different data centers.
Amazon Web Services Route 53 allows you to send users to specific network resources based on their geography or latency. This means that you can route visitors to the fastest resource based on their location. For example, if you have a server in Dublin, Singapore, California Sydney. You can send visitors from Europe to the Dublin server, from Asia to Singapore, from North America to California and from Australia to Sydney. You can use this service both for Amazon EC2 servers or for your own or other third party servers.
An aiCDN instance is actually identical to an aiScaler instance. aiCDN is a network of aiScaler instances, communicating with each other, and using Route53 for geographic load balancing. Sometimes we refer to the nodes in that network as “aiCDN instances” and sometimes as “aiScaler instances”. Having aiScaler servers in different AWS regions with geo-routing creates your customized Content Delivery Network unique to your application, pretty cool huh? 🙂
The steps for this are:
I. Deploy aiCDN servers in the Amazon regions best suited to your customers.
II. Add records to Route 53 for each aiCDN server;
III. Add latency records to Route 53;
IV. Test your very own Content Delivery Network.
Now let’s take them one by one.
This part is best described in another wiki article.
Once you’ve started the aiCDN instances in the regions you want, you can proceed with the next step. For this example I’ve created one in each AWS region.
To add records to Route 53, go to Amazon AWS console and select Route 53. You should have already added your domain there to be managed by Route 53, for this example I have used geo.aiscaler.com. So select the domain you want and click on Go to Record Sets, just like in the image below:
Next you need to fill in the details, like in the following screenshot:
Now what those mean:
1. This is the name you want to give to the record, can be anything, but it is good to name it in a way that you will easily recognize it later, like here us-east-1.geo.aiscaler.com means that this is the aiScaler image from us-east-1 region.
2. This is the type of the record, it’s an A record, just to point the name us-east-1.geo.aiscaler.com to the IP address of the instance 22.214.171.124.
3. TTL (Time-To-Live) this is the time for refreshing the value, you should set this to a bigger value if you don’t plan to change it in near future, but for my example here I might change it in near future, thus I’ve used 1 minute TTL.
4. The actual value, which is the IP address of the aiScaler instance in us-east-1 region.
5. Routing policy in this case is Simple, nothing fancy here yet.
6. Click on “Create Record Set” once everything is completed correctly.
Proceed with the same entries for each region, once you have entries for each region, you should have the Record Sets similar to the image below:
Now we can proceed to the next step:
In the same Console you’ll have to add another number of records – the latency records, that automatically will route your users to the lowest latency server for them. Thus click on again and fill like in the image below:
To explain those above:
1. This is the actual URL we will use for our site, for this example I have used www.geo.aiscaler.com
2. Type of the record is CNAME, it is a kind of alias in DNS, there will be 8 aliases in my example, because I have 8 aiScaler servers in 8 different regions, all of them for www.geo.aiscaler.com and pointing to different AWS regions.
3. TTL (Time-To-Live) this is the time for refreshing the value.
4. The actual value for the record, this is the respective entry from the entries we created at “Add records to Route 53 for each aiScaler server” step, so in this case we have the CNAME for the us-west-1 server, thus the value is us-west-1.geo.aiscaler.com.
5. Routing policy is Latency, this is the fancy part, it tells AWS to check for latency of the servers and reply to users DNS requests with the least latency server available, meaning the server which replied the fastest for the particular geo region, will be provided to the user.
6. Set the region to the the server location, in this case it’s us-west-1.
7. You can set any name here, but it has to be unique and best to set this to something that can be recognized easily in future.
Once all above is done, click on “Create Record Set”. Repeat this process for all of the regions and in the end you should have something like in the following image:
and that’s it, the Geo Routing configuration is complete and you now have your very own Content Delivery Network, wow, this sounds great 🙂
Now lets test this and see how it works in real life, for this visit something like http://cloudmonitor.ca.com/en/ping.php, enter there your domain and hit “Start” in couple of moments you should see the screen populating with different IP addresses of your servers depending on the region. Here are the results from my example:
And you can clearly see the different IP addresses resolved based on region, cool stuff 😉
Now just configure your aiScaler instance to get the content from your origin server and let your users enjoy the faster site you just built in under 1 hour 🙂