Is there a common strategy for setting up scripts on autoscaling to update the code in a capistrano deploy hierarchy to pull from your repository when the AMI is launched on an autoscaling event to ensure the commit running on the autoscaling machine matches the commit on non-autoscaling instances?
Amazon EC2 Auto Scaling helps you maintain application availability and allows you to automatically add or remove EC2 instances according to conditions you define. You can use the fleet management features of EC2 Auto Scaling to maintain the health and availability of your fleet.
Pricing for Amazon EC2 Auto ScalingThere are no additional fees with Amazon EC2 Auto Scaling, so it's easy to try it out and see how it can benefit your AWS architecture. You only pay for the AWS resources (for example, EC2 instances, EBS volumes, and CloudWatch alarms) that you use.
Yes, you can use Auto Scaling without Elastic Load Balancing. However, it means that you don't have a common entry point, so it isn't ideal if you will be, say, hosting a website.
I run a setup a bit like this. I chose not to set instances to interact with git when they're booted because:
What I do is that the app I deploy is at /var/www/myapp. This is actually a separate EBS volume, mounted at that location. The filesystem is xfs because you can use xfs_freeze to safely take ebs snapshots of a mounted volume
When the deploy is done, in a capistrano after hook I snapshot the /var/www/myapp volume. I then update the block device mapping of the autoscaling launch configuration to say "when you start an instance, create a new volume from the snapshot and attach it to /dev/sdf.
All the instance has to do on startup is mount that device at /var/www/myapp, either by editing /etc/fstab or by running a super simple boot time script. Bundler is set to save its gems in /var/www/myapp/shared so the gems are taken care of too
Just in case anyone falls here, I've just discovered this gem:
https://github.com/lserman/capistrano-elbas
which will (as stated in the Readme):
- Deploy your code to each running instance connected to a given AutoScale group
- After deployment, create an AMI from one of the running instances
- Attach the AMI with the new code to a new AWS Launch Configuration
- Update your AutoScale group to use the new launch configuration
- Delete any old AMIs created by ELBAS
- Delete any old launch configurations created by ELBAS
So it ensures all instances of the autoscaling group (those running and those future) will run the same code.
Hope this helps
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With