CDN Load Balancing by Cedexis OpenmixPosted: June 17, 2013
Different CDNs have different network footprints. A CDN performs differently at different times due to different traffic patterns and loadings. One CDN may perform better than others for a specific geo region at a specific point of time.
Say your website is using two CDNs: provider A and E. Sometime A performs better than E. Sometime E performs better than A. Your website performs the best if your website is always using the best of them at any given time. Doing so you need two things
-a measurement system monitoring performances of both A and E
-an intelligent DNS which can change of content URL to CDN URL of either A or E based on their performances
EdgeCast and another CDN
I use EdgeCast and another CDN to show the Cedexix Openmix CDN load balancing feature. There are some CDNs provide free services – Incapsula, CloudFlare, CDN.NET – at the end I create a 14-day free account at CDN77 because they are easy to use, do not require me to migrate my domain to their name servers and do not ask my credit card information.
I set up both EdgeCast and CDN77 to cache the contents from image.cheungwaikin.com, the hostname of the four images on the original webpage, and the CDN URL hostnames are wpc.6af4.edgecastcdn.net and 354796261.r.cdn77.net respectively. I add two CNAMEs in my domain – cdn-i.cheungwaikin.com and cdn77.cheungwaikin.com – to hide the CDN URLs.
To use a single CDN is simple: to change the image origin URLs to either one of the aforementioned CNAME URLs.
Using EdgeCast: http://demo.cheungwaikin.com/cdn-load-balancing-ec.html
Using CDN77: http://demo.cheungwaikin.com/cdn-load-balancing-cdn77.html
In order to dynamically load balance among these two CDNs by Cedexis Openmix, there are a few steps:
1.under Platforms: to add both EdgeCast and CDN77 to Platforms. Cedexis Openmix will load balance based on the performance of the Platforms entries.
2.under Openmix: to add a new DNS Application. I select Optimal Round Trip Time in the Application Type. I put image.cheungwaikin.com in Fallback CNAME. Time to Live (of the Cedexis CNAME assigned later) is 20 seconds. In destination platform, I add both platforms defined in step (1): EdgeCast with CNAME cdn-i.cheungwaikin.com and CDN77 with CNAME of cdn77.cheungwaikin.com. Cedexis then assigns a Cedexis CNAME for this DNS application: 2-01-2afb-0003.cdx.cedexis.net
3.under Openmix: once I publish this DNS application, every 20 seconds Cedexis will change the CNAME of 2-01-2afb-0003.cdx.cedexis.net to either cdn-i.cheungwaikin.com or cdn77.cheungwaikin.com if at that moment the best performing CDN is EdgeCast or CDN77 respectively.
4.EdgeCast and CDN77: to add 2-01-2afb-0003.cdx.cedexis.net as a CDN CNAME. Doing so when a HTTP request with Host header 2-01-2afb-0003.cdx.cedexis.net is received, EdgeCast will point it to the CDN URL wpc.6af4.edgecastcdn.net/806AF4/cdn-i/. CDN77 will point to the CDN URL 354796261.r.cdn77.net/
5.the final step: in the original webpage, to change image.cheungwaikin.com to 2-01-2afb-0003.cdx.cedexis.net. The result webpage is http://demo.cheungwaikin.com/cdn-load-balancing-ortt-cdn77.html
To summarise: Cedexis update its DNS record so that 2-01-2afb-0003.cdx.cedexis.net is
cdn-i.cheungwaikin.com (CNAME to wpc.6af4.edgecastcdn.net) if EdgeCast performs better, OR
cdn77.cheungwaikin.com (CNAME to 354796261.r.cdn77.net) if CDN77 performs better
The actual result? Between 12:00pm and 1:00pm 2013-06-17 Hong Kong Time, there were 847 DNS queries of 2-01-2afb-0003.cdx.cedexis.net, Cedexis Openmix resolved 62% queries to EdgeCast.
I used Catchpoint to do synthetic HTTP GET test to measure webpage response time from Asia, North America and Europe. Here are the test results between 7pm 2013-06-17 and 7pm 2013-06-18 Hong Kong Time:
Using EdgeCast only: 2466ms, 24768 tests
Using CDN77 only: 2528ms, 24768 tests
Load balance between EdgeCast and CDN77: 2493ms, 24768 tests. Cedexis Openmix routed 68% of traffic to EdgeCast.
With similar idea, I can use Openmix to load balance CDN and the original server. I need to add a custom Platform in Cedexis to measure the origin server. Here is a example of a 50-50 Round Robin load balancing between EdgeCast and the original server, the one listed on my demo site.