Staging / AB Testing CDN Hosting Javascript
Asked Answered
L

1

6

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.

Lightness answered 9/11, 2011 at 0:23 Comment(1)
I think your best bet is the bootstrapper Javascript, since it allows you to maintain control from your end.Speedy
G
1

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.
Gaza answered 20/11, 2011 at 22:43 Comment(1)
Could definitely be a possibility, but the TTL on our DNS cache is fairly large, so it would take a long time to get the staging setup ready. Furthermore, relying on DNS propagation would be a headache. Finally, getting the 99%/1% split using round-robin would require 100 entries in the DNS file, which could get unwieldy :)Lightness

© 2022 - 2024 — McMap. All rights reserved.