Skip to content

Instantly share code, notes, and snippets.

@Natim
Created August 25, 2014 21:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Natim/3b3d41af04665d1027b1 to your computer and use it in GitHub Desktop.
Save Natim/3b3d41af04665d1027b1 to your computer and use it in GitHub Desktop.
Use a DNS TXT entry to configure a ramp up number for a slow software activation

Ramp Up

The problem

The idea of the ramp up is to have a scalable way to activate a software feature slowly so that the scale is handled.

If you have let say 10 million users and you want to launch a most wanted feature. If you activate it the same day for this amount of user it may crash.

But if you can handle the load and have the user to arrive one after the other you can handle the load an activate the right number of servers.

How does it works?

The Ramp Up system is one way to handle that.

The idea is to give a number, that will be in between 1 and 10000 for instance, and if the feature is not activated at startup choose a random number between this too value. For instance 6423

Then you get the rampup number and you activate the feature if the random number is below the rampup value.

One scalable way to do so is to use the DNS, it is scalable and free and you can configure the update time window.

I want to get 1/20 to get the feature activated at startup. So I have configured my TXT field to be "rampup=500"

Test you DNS configuration

host -t txt trunat.fr

You can use the python script to get it programatically.

# pip install dnspython
import dns.resolver
answer = dns.resolver.query("trunat.fr", "TXT")
for data in answer:
key, value = data.to_text().strip('"').split("=")
if key == "rampup":
print int(value)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment