{"id":1964,"date":"2016-10-11T10:53:46","date_gmt":"2016-10-11T09:53:46","guid":{"rendered":"http:\/\/tekhead.it\/blog\/?p=1964"},"modified":"2016-10-18T10:43:05","modified_gmt":"2016-10-18T09:43:05","slug":"amazon-aws-tips-and-gotchas-part-9-scale-up-patching","status":"publish","type":"post","link":"https:\/\/tekhead.it\/blog\/2016\/10\/amazon-aws-tips-and-gotchas-part-9-scale-up-patching\/","title":{"rendered":"Amazon AWS Tips and Gotchas &#8211; Part 9 &#8211; Scale-Up Patching"},"content":{"rendered":"<p>Continuing in this series of blog posts taking a bit of a \u201cwarts and all\u201d view of a few Amazon AWS features, below is another tip for designing and implementing solutions on Amazon AWS. In this case, Scale-Up Patching of Auto-Scaling Groups (ASGs) and a couple of wee bonuses about Dark Launch techniques.<\/p>\n<p>For the first post in this series with a bit of background on where it all originated from, see here:<br \/>\n<a href=\"http:\/\/tekhead.it\/blog\/2016\/02\/amazon-aws-tips-and-gotchas-part-1\/\" target=\"_blank\">Amazon #AWS Tips and Gotchas \u2013 Part 1<\/a><\/p>\n<p>For more posts in this series, see here:<br \/>\n<a href=\"http:\/\/tekhead.it\/blog\/2016\/07\/index-of-tekhead-it-blog-posts-on-amazon-aws\/#gotchas\" target=\"_blank\">Index of AWS Tips and Gotchas<\/a><\/p>\n<h5>19. AWS Tips and Gotchas &#8211; Part 9 &#8211; Scale-Up Patching in ASGs<\/h5>\n<p>Very quick tip on Auto Scaling Groups this week, courtesy of an awesome session I attended at the <a href=\"http:\/\/www.meetup.com\/AWSUGUK\/\" target=\"_blank\">AWS User Group UK (London)<\/a> last week on DevOps, presented by <a href=\"https:\/\/twitter.com\/ChrisTurvil\" target=\"_blank\">Chris Turvil<\/a> from The Trainline.<\/p>\n<p>Assuming you need to just do a code release to an existing farm of servers running in an ASG, and you aren&#8217;t planning anything complex such as a DB schema update, you can use a technique called &#8220;Scale-Up Patching&#8221;. I hadn&#8217;t heard the term before, but it&#8217;s actually incredibly simple, but very effective! There are a couple of methods you might use, depending on how you deliver your code, but the technique is the same; make your new code or image live, double the minimum size of your ASG, then halve it! Job done!<img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-1966 size-medium\" src=\"http:\/\/tekhead.it\/wp-uploads\/www.tekhead.org\/2016\/10\/scale-up-patching-300x300.jpg\" alt=\"AWS Scale-Up Patching with ASGs (Auto-Scaling Groups)\" width=\"300\" height=\"300\" srcset=\"https:\/\/tekhead.it\/wp-uploads\/www.tekhead.org\/2016\/10\/scale-up-patching-300x300.jpg 300w, https:\/\/tekhead.it\/wp-uploads\/www.tekhead.org\/2016\/10\/scale-up-patching-150x150.jpg 150w, https:\/\/tekhead.it\/wp-uploads\/www.tekhead.org\/2016\/10\/scale-up-patching.jpg 378w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/>So how does this work?<\/p>\n<p>If you have looked into the detail of ASGs, assuming you have roughly even instances spread over multiple AZs then when an ASG shrinks \/ scales down, the oldest EC2 instances are killed first. For more detail on the exact rules, <a href=\"http:\/\/docs.aws.amazon.com\/autoscaling\/latest\/userguide\/as-instance-termination.html\" target=\"_blank\">see here<\/a>.<\/p>\n<p>If you double the size of your current number of instances, all of the new instances will be deployed with your new code version. This leaves you with a farm of 50% vOld and 50% vNew. When you then tell the ASG to scale to the original size, it will obviously kill off all of the vOld instances, leaving your entire farm upgraded. If you found an issue and had to roll back, you simply rinse and repeat the same exercise! How brilliant is that?!<\/p>\n<p>This process will work exactly the same regardless of whether you deploy your code via updated AMIs each time, or simply post-boot using a user-data script which pulls your source from a bucket, repo, or similar. Either way, the result is the same and infinitely repeatable!<\/p>\n<p>The one counter to this which a colleague of mine brought up, is that you are explicitly depending on a specific feature of AWS always functioning in the same way and not changing in the future. An alternative might be to deploy in a blue-green setup with independent ELBs and instances. You then simply failover using Route53, either all in one go\u00a0or using weighted routing for a <a href=\"http:\/\/martinfowler.com\/bliki\/CanaryRelease.html\" target=\"_blank\">canary release<\/a> process. Funnily enough, AWS released a white paper on exactly that subject a couple of months ago:<br \/>\n<a href=\"https:\/\/d0.awsstatic.com\/whitepapers\/AWS_Blue_Green_Deployments.pdf\" target=\"_blank\">Blue\/Green Deployments on AWS Whitepaper<\/a><\/p>\n<p>They also cover the scale-up patching method in detail from page 17 of the whitepaper.<\/p>\n<h5>Brucie Bonus One &#8211; Deployment Dictionary<\/h5>\n<p>Incidentally, you can actually deploy said code, without it actually going live immediately, by using methods called &#8220;Dark Launch Techniques&#8221;. As the name suggests, this separates code deployment from feature launches. You pre-release your code into production, but you simply don&#8217;t toggle it on for anyone (or everyone) at first. You can then either toggle it on for everyone, or even better, smaller canary groups. Web-scale companies such as Netflix, Facebook and Google have been doing this for many years!<\/p>\n<p>This process then completely avoids the panic-inducing impact of deploying a large new code release whilst simultaneously\u00a0having that code go live and ramping up utilisation at the same time!<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-1984\" src=\"http:\/\/tekhead.it\/wp-uploads\/www.tekhead.org\/2016\/10\/devops-300x300.png\" alt=\"devops Dark Launch Meme\" width=\"250\" height=\"250\" srcset=\"https:\/\/tekhead.it\/wp-uploads\/www.tekhead.org\/2016\/10\/devops-300x300.png 300w, https:\/\/tekhead.it\/wp-uploads\/www.tekhead.org\/2016\/10\/devops-150x150.png 150w, https:\/\/tekhead.it\/wp-uploads\/www.tekhead.org\/2016\/10\/devops.png 405w\" sizes=\"auto, (max-width: 250px) 100vw, 250px\" \/><\/p>\n<p>Combining dark launch methods with scale-up patching or blue\/green deployments should lead to a few less grey hairs in the long run, that&#8217;s for sure!<\/p>\n<p>For more info, see the following overview:<br \/>\n<a href=\"https:\/\/www.quora.com\/What-is-a-dark-launch-in-terms-of-continuous-delivery-of-software\" target=\"_blank\">What is a dark launch in terms of continuous delivery of software?<\/a><\/p>\n<h5>Brucie Bonus Two &#8211; Environment Manager<\/h5>\n<p>Lastly, a bit of interesting news which also came from The Trainline is that they have open sourced their own internal deployment tool, they call <a href=\"https:\/\/engineering.thetrainline.com\/2016\/09\/28\/trainline-environment-manager-now-open-source\/\" target=\"_blank\">Environment Manager<\/a>.<\/p>\n<p>With an AngularJS front end, and a Node.js back end, it&#8217;s a home-grown continuous deployment tool which includes a self-service portal, REST APIs, and a number of operational governance features. The governance elements include a feature which prevents rogue developers deploying anything which hasn&#8217;t already been defined in the central service catalogue.<\/p>\n<p><a href=\"http:\/\/tekhead.it\/wp-uploads\/www.tekhead.org\/2016\/10\/em-hl-arch.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-1983\" src=\"http:\/\/tekhead.it\/wp-uploads\/www.tekhead.org\/2016\/10\/em-hl-arch.png\" alt=\"The Tramline Environment Manager Architecture\" width=\"400\" height=\"262\" srcset=\"https:\/\/tekhead.it\/wp-uploads\/www.tekhead.org\/2016\/10\/em-hl-arch.png 750w, https:\/\/tekhead.it\/wp-uploads\/www.tekhead.org\/2016\/10\/em-hl-arch-150x98.png 150w, https:\/\/tekhead.it\/wp-uploads\/www.tekhead.org\/2016\/10\/em-hl-arch-300x196.png 300w\" sizes=\"auto, (max-width: 400px) 100vw, 400px\" \/><\/a><\/p>\n<p>You can check out Environment Manager on GitHub:<br \/>\n<a href=\"https:\/\/trainline.github.io\/environment-manager\">https:\/\/trainline.github.io\/environment-manager<\/a><\/p>\n<h5>Want More AWS Tips and Gotchas?<\/h5>\n<p>Find\u00a0more posts in this series here:<br \/>\n<a href=\"http:\/\/tekhead.it\/blog\/2016\/07\/index-of-tekhead-it-blog-posts-on-amazon-aws\/#gotchas\" target=\"_blank\">Index of AWS Tips and Gotchas<\/a><\/p>\n<blockquote class=\"wp-embedded-content\" data-secret=\"hePmT7rKG4\"><p><a href=\"https:\/\/tekhead.it\/blog\/2016\/10\/amazon-aws-tips-gotchas-part-10-efs\/\">Amazon AWS Tips and Gotchas \u2013 Part 10 \u2013 EFS (Elastic File System)<\/a><\/p><\/blockquote>\n<p><iframe loading=\"lazy\" class=\"wp-embedded-content\" sandbox=\"allow-scripts\" security=\"restricted\" style=\"position: absolute; visibility: hidden;\" title=\"&#8220;Amazon AWS Tips and Gotchas \u2013 Part 10 \u2013 EFS (Elastic File System)&#8221; &#8212; Tekhead.it\" src=\"https:\/\/tekhead.it\/blog\/2016\/10\/amazon-aws-tips-gotchas-part-10-efs\/embed\/#?secret=p5nlyY7FYQ#?secret=hePmT7rKG4\" data-secret=\"hePmT7rKG4\" width=\"590\" height=\"332\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Continuing in this series of blog posts taking a bit of a \u201cwarts and all\u201d view of a few Amazon AWS features, below is another tip for designing [..]<\/p>\n","protected":false},"author":1,"featured_media":1549,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_yoast_wpseo_focuskw":"Scale-Up Patching","_yoast_wpseo_title":"","_yoast_wpseo_metadesc":"AWS is awesome, but this series covers common issues you may come across & provides tips, workarounds & fixes inc Scale-Up Patching & Dark Launch Techniques","jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":true,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"New Blog Post: Amazon AWS Tips and Gotchas - Part 9 - Scale-Up Patching #AWS","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[688,725],"tags":[270,709,715,714,931,699,706,707,894,935,934,956,702,933,380,932,710,66],"class_list":["post-1964","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-aws","category-cloud","tag-amazon","tag-architecture","tag-asg","tag-auto-scaling","tag-auto-scaling-group","tag-aws","tag-awsgotchas","tag-awstips","tag-az","tag-cd","tag-ci","tag-dark-launch-techniques","tag-ec2","tag-gotchas","tag-patching","tag-scale-up-patching","tag-solution-architect","tag-tips"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/tekhead.it\/wp-uploads\/www.tekhead.org\/2016\/02\/amazon-web-services-logo.png","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p2l3lU-vG","amp_enabled":true,"_links":{"self":[{"href":"https:\/\/tekhead.it\/blog\/wp-json\/wp\/v2\/posts\/1964","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tekhead.it\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/tekhead.it\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/tekhead.it\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/tekhead.it\/blog\/wp-json\/wp\/v2\/comments?post=1964"}],"version-history":[{"count":1,"href":"https:\/\/tekhead.it\/blog\/wp-json\/wp\/v2\/posts\/1964\/revisions"}],"predecessor-version":[{"id":1965,"href":"https:\/\/tekhead.it\/blog\/wp-json\/wp\/v2\/posts\/1964\/revisions\/1965"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/tekhead.it\/blog\/wp-json\/wp\/v2\/media\/1549"}],"wp:attachment":[{"href":"https:\/\/tekhead.it\/blog\/wp-json\/wp\/v2\/media?parent=1964"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tekhead.it\/blog\/wp-json\/wp\/v2\/categories?post=1964"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tekhead.it\/blog\/wp-json\/wp\/v2\/tags?post=1964"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}