Monday, August 3, 2015

AWS autoscaling groups for a fixed number of instances

AWS autoscaling groups are a way to scale capacity up and down when it is needed. However, autoscaling groups are a great way to just keep a fixed number of instances alive. Let's say we have an app that we always want two instances of running. If one of them dies, it would nice to automatically restart it. To do this, simply create an autoscaling group with a fixed size:
"myautoscalinggroup" : {
   "Type" : "AWS::AutoScaling::AutoScalingGroup",
   "Properties" : {
      "DesiredCapacity" : 2,
      "MinSize" : 2,
      "MaxSize" : 2,
Now Amazon does the heavy lifting for us, and we'll always have a pool of two instances.

Friday, March 27, 2015

JavaScript console object

Many of us have used the JavaScript console object for logging
console.log("some debug message");
But for a lot of us, that's the extent. Maybe we use or console.error, but there is so much more to the console. For example,
lets you nest statements in a group. The following snippet:
console.log('hello, I am outside the group');;
console.log('I am in the group');
console.log('me too');
console.log('I am also outside the group');
Produces an output of
hello, I am outside the group
    I am in the group
    me too
I am also outside the group
While the console should only be used for debugging (and there are better libraries for just printouts like debug) and is not necessarily standard across browsers, it can be a really powerful tool. Check out the console docs at for a full list of functions.