Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Staging / AB Testing CDN Hosting Javascript

Let's assume that i have a single javascript file that I have handed out to a lot of my clients, similar to GA's *ga.js, and this file is getting loaded high enough number of times that I have to host it on a CDN.

The problem I have with this setup is that it makes it really hard to 'stage' a new version of javascript. Ideally, when I have a new version of the JS, I would like to split the incoming traffic to the CDN, and send 1% of the entire traffic to the new JS (randomly chosen), or possibly send the new JS only to specific URLs.

I have come across this issue multiple times and have not come up with a good solution. One possible solution is working with the CDN, though it is a long process. Alternative solution is having the customers always load a bootstrapper javascript, which knows where the actual JS or the staged JS lives and splits traffic accordingly.

I am curious if there is alternative solutions people have come up with. This is common enough problem for any company that distributes their JS like, Google, Twitter, Facebook, Linkedin, etc.

like image 369
daniyalzade Avatar asked Nov 09 '11 00:11

daniyalzade


1 Answers

Since most of CDN services rely on you adding a new CNAME record to your domain to point to CDN hostname. You can use DNS to split a traffic between different CDN services.

  1. Round-robin_DNS - splits trafffic more or less evenly
  2. geo-load-balancing - allows to set a mapping to specific host based on user location.
like image 187
Maksym Kozlenko Avatar answered Sep 28 '22 10:09

Maksym Kozlenko