{"id":2730,"date":"2018-02-26T20:40:53","date_gmt":"2018-02-26T20:40:53","guid":{"rendered":"http:\/\/blog.paranoidprofessor.com\/?p=2730"},"modified":"2018-06-13T18:23:46","modified_gmt":"2018-06-13T18:23:46","slug":"aws-autoscaling","status":"publish","type":"post","link":"https:\/\/blog.paranoidprofessor.com\/index.php\/2018\/02\/26\/aws-autoscaling\/","title":{"rendered":"AWS &#8211; Autoscaling"},"content":{"rendered":"<p>The cloud isn&#8217;t really the cloud without some additional functionality beyond the ability of creating a virtual machine to run your software.<\/p>\n<p>The cloud isn&#8217;t just somebody else&#8217;s data center either.\u00a0 A short definition might be.<\/p>\n<blockquote><p>A Cloud solution is one where the software solution or service available over the internet and the user has the ability to allocate or deallocate this on own their own without the involvement of IT.\u00a0 Usually the cloud solution can expand or contract as required.<\/p><\/blockquote>\n<p>The National Institute of Standards and Technology has a slightly bigger, and much more elegant definition of what Cloud computing is &#8211; <a href=\"https:\/\/www.nist.gov\/news-events\/news\/2011\/10\/final-version-nist-cloud-computing-definition-published\" target=\"_blank\" rel=\"noopener\">Cloud computing<\/a>.<\/p>\n<p>The part of this definition that I will be focusing on today is the ability of a cloud solution to expand or contact as necessary.\u00a0 Amazon refers to this as elasticity and make it possible by allowing you to setup Autoscaling.<\/p>\n<blockquote><p><strong>Autoscaling<\/strong><\/p>\n<p>The ability to launch or shutdown an EC2 instance by uising system statistics such as CPU load to determine if more or fewer instances are required.<\/p><\/blockquote>\n<p>If it were only that easy in practice.\u00a0 In order to take advantage of autoscaling the programs need to be written in so that it is possible to have multiple programs or processes running independent of each other.\u00a0 This doesn&#8217;t have to be a difficult task however, this may be an undertaking for monolithic legacy systems that have certain expectations.<\/p>\n<h2>Autoscaling<\/h2>\n<p>Setting up Autoscaling is a two part process.\u00a0 The first part is to define a launch configuration (ie a template) <a href=\"https:\/\/blog.paranoidprofessor.com\/index.php\/2018\/02\/03\/aws-setting-up-ec2\/\" target=\"_blank\" rel=\"noopener\">describing how each machine should be configured<\/a>.\u00a0 This would probably to use one of <a href=\"https:\/\/blog.paranoidprofessor.com\/index.php\/2018\/02\/09\/aws-your-own-machine-image\/\" target=\"_blank\" rel=\"noopener\">your previously created AMI&#8217;s<\/a> which would probably have your most if not all of your software configuration.<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-2849\" src=\"https:\/\/blog.paranoidprofessor.com\/wp-content\/uploads\/2018\/02\/aws-auto-step01.png\" alt=\"\" width=\"797\" height=\"735\" srcset=\"https:\/\/blog.paranoidprofessor.com\/wp-content\/uploads\/2018\/02\/aws-auto-step01.png 797w, https:\/\/blog.paranoidprofessor.com\/wp-content\/uploads\/2018\/02\/aws-auto-step01-300x277.png 300w, https:\/\/blog.paranoidprofessor.com\/wp-content\/uploads\/2018\/02\/aws-auto-step01-768x708.png 768w\" sizes=\"(max-width: 797px) 100vw, 797px\" \/><\/p>\n<p>For brevity sake, I will skip a few of the screens for creating the launch creation.\u00a0 The reason is that these steps should be familiar as they are the same as setting up a EC2 instance.<\/p>\n<p>First we give our launch configuration a name.<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-2850\" src=\"https:\/\/blog.paranoidprofessor.com\/wp-content\/uploads\/2018\/02\/aws-auto-step02.png\" alt=\"\" width=\"1020\" height=\"717\" srcset=\"https:\/\/blog.paranoidprofessor.com\/wp-content\/uploads\/2018\/02\/aws-auto-step02.png 1020w, https:\/\/blog.paranoidprofessor.com\/wp-content\/uploads\/2018\/02\/aws-auto-step02-300x211.png 300w, https:\/\/blog.paranoidprofessor.com\/wp-content\/uploads\/2018\/02\/aws-auto-step02-768x540.png 768w\" sizes=\"(max-width: 1020px) 100vw, 1020px\" \/><\/p>\n<p>Once everything has been selected, we do a quick verify that all tags, storage and such are correctly defined.<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-2851\" src=\"https:\/\/blog.paranoidprofessor.com\/wp-content\/uploads\/2018\/02\/aws-auto-step03.png\" alt=\"\" width=\"1103\" height=\"917\" srcset=\"https:\/\/blog.paranoidprofessor.com\/wp-content\/uploads\/2018\/02\/aws-auto-step03.png 1103w, https:\/\/blog.paranoidprofessor.com\/wp-content\/uploads\/2018\/02\/aws-auto-step03-300x249.png 300w, https:\/\/blog.paranoidprofessor.com\/wp-content\/uploads\/2018\/02\/aws-auto-step03-768x638.png 768w, https:\/\/blog.paranoidprofessor.com\/wp-content\/uploads\/2018\/02\/aws-auto-step03-1024x851.png 1024w\" sizes=\"(max-width: 1103px) 100vw, 1103px\" \/><\/p>\n<h2>Auto Scaling Group<\/h2>\n<p>I cannot say if it is good &#8220;style&#8221; that AWS automatically launches in the creation of a scaling group once your launch configuration has been setup, however, it certainly is convenient.<\/p>\n<p>First you give your auto scaling group a name, decide how many instances should be in the group, pick a network and decide which availability zones will be used when autoscaling.\u00a0 The Amazon literature is pretty specific that for a high availability solution you would want your solutions to span availability zones when possible to counter the unlikely chance that a AZ goes down or becomes unreachable.<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-2852\" src=\"https:\/\/blog.paranoidprofessor.com\/wp-content\/uploads\/2018\/02\/aws-auto-step04.png\" alt=\"\" width=\"886\" height=\"700\" srcset=\"https:\/\/blog.paranoidprofessor.com\/wp-content\/uploads\/2018\/02\/aws-auto-step04.png 886w, https:\/\/blog.paranoidprofessor.com\/wp-content\/uploads\/2018\/02\/aws-auto-step04-300x237.png 300w, https:\/\/blog.paranoidprofessor.com\/wp-content\/uploads\/2018\/02\/aws-auto-step04-768x607.png 768w\" sizes=\"(max-width: 886px) 100vw, 886px\" \/><\/p>\n<p>The scaling policies is the location where you get to decide on how big your solution should scale.\u00a0 You do have the opportunity to keep your group size the same as previously defined.<\/p>\n<p>Doing so would be the equivalent of a high availability solution.\u00a0 This guarantees that AWS will launch a new instance if for any reason your existing instance(s) go down.<\/p>\n<p>You also decide what metrics will be used when deciding to increase or decrease the number of instances you have.<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-2853\" src=\"https:\/\/blog.paranoidprofessor.com\/wp-content\/uploads\/2018\/02\/aws-auto-step05.png\" alt=\"\" width=\"1101\" height=\"915\" srcset=\"https:\/\/blog.paranoidprofessor.com\/wp-content\/uploads\/2018\/02\/aws-auto-step05.png 1101w, https:\/\/blog.paranoidprofessor.com\/wp-content\/uploads\/2018\/02\/aws-auto-step05-300x249.png 300w, https:\/\/blog.paranoidprofessor.com\/wp-content\/uploads\/2018\/02\/aws-auto-step05-768x638.png 768w, https:\/\/blog.paranoidprofessor.com\/wp-content\/uploads\/2018\/02\/aws-auto-step05-1024x851.png 1024w\" sizes=\"(max-width: 1101px) 100vw, 1101px\" \/><\/p>\n<p>You can see that I have decided that 45% cpu utilization should be the signal to create another EC2 instance.<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-2854\" src=\"https:\/\/blog.paranoidprofessor.com\/wp-content\/uploads\/2018\/02\/aws-auto-step05-create-alrm1.png\" alt=\"\" width=\"935\" height=\"446\" srcset=\"https:\/\/blog.paranoidprofessor.com\/wp-content\/uploads\/2018\/02\/aws-auto-step05-create-alrm1.png 935w, https:\/\/blog.paranoidprofessor.com\/wp-content\/uploads\/2018\/02\/aws-auto-step05-create-alrm1-300x143.png 300w, https:\/\/blog.paranoidprofessor.com\/wp-content\/uploads\/2018\/02\/aws-auto-step05-create-alrm1-768x366.png 768w\" sizes=\"(max-width: 935px) 100vw, 935px\" \/><\/p>\n<p>You can also see that if the overall CPU utilization goes below 25% then AWS will decrease the number of EC2 instances that are running.<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-2855\" src=\"https:\/\/blog.paranoidprofessor.com\/wp-content\/uploads\/2018\/02\/aws-auto-step05-create-alrm2.png\" alt=\"\" width=\"935\" height=\"444\" srcset=\"https:\/\/blog.paranoidprofessor.com\/wp-content\/uploads\/2018\/02\/aws-auto-step05-create-alrm2.png 935w, https:\/\/blog.paranoidprofessor.com\/wp-content\/uploads\/2018\/02\/aws-auto-step05-create-alrm2-300x142.png 300w, https:\/\/blog.paranoidprofessor.com\/wp-content\/uploads\/2018\/02\/aws-auto-step05-create-alrm2-768x365.png 768w\" sizes=\"(max-width: 935px) 100vw, 935px\" \/><\/p>\n<p>Once you have setup everything for your group (notification and tags not displayed here), then you get a chance to verify that you are satisfied with the setup.<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-2856\" src=\"https:\/\/blog.paranoidprofessor.com\/wp-content\/uploads\/2018\/02\/aws-auto-step06-review.png\" alt=\"\" width=\"1123\" height=\"613\" srcset=\"https:\/\/blog.paranoidprofessor.com\/wp-content\/uploads\/2018\/02\/aws-auto-step06-review.png 1123w, https:\/\/blog.paranoidprofessor.com\/wp-content\/uploads\/2018\/02\/aws-auto-step06-review-300x164.png 300w, https:\/\/blog.paranoidprofessor.com\/wp-content\/uploads\/2018\/02\/aws-auto-step06-review-768x419.png 768w, https:\/\/blog.paranoidprofessor.com\/wp-content\/uploads\/2018\/02\/aws-auto-step06-review-1024x559.png 1024w\" sizes=\"(max-width: 1123px) 100vw, 1123px\" \/><\/p>\n<p>The non-obvious step here is that once you actually create this group then AWS will proceed to create everything for you.\u00a0 This is in one sense exactly what you want, however, it does make it impossible to create the group setup and then trigger once you are ready.<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The cloud isn&#8217;t really the cloud without some additional functionality beyond the ability of creating a virtual machine to run your software. The cloud isn&#8217;t just somebody else&#8217;s data center either.\u00a0 A short definition might be. A Cloud solution is &hellip; <a href=\"https:\/\/blog.paranoidprofessor.com\/index.php\/2018\/02\/26\/aws-autoscaling\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[3],"tags":[95,90,85],"_links":{"self":[{"href":"https:\/\/blog.paranoidprofessor.com\/index.php\/wp-json\/wp\/v2\/posts\/2730"}],"collection":[{"href":"https:\/\/blog.paranoidprofessor.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.paranoidprofessor.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.paranoidprofessor.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.paranoidprofessor.com\/index.php\/wp-json\/wp\/v2\/comments?post=2730"}],"version-history":[{"count":6,"href":"https:\/\/blog.paranoidprofessor.com\/index.php\/wp-json\/wp\/v2\/posts\/2730\/revisions"}],"predecessor-version":[{"id":2893,"href":"https:\/\/blog.paranoidprofessor.com\/index.php\/wp-json\/wp\/v2\/posts\/2730\/revisions\/2893"}],"wp:attachment":[{"href":"https:\/\/blog.paranoidprofessor.com\/index.php\/wp-json\/wp\/v2\/media?parent=2730"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.paranoidprofessor.com\/index.php\/wp-json\/wp\/v2\/categories?post=2730"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.paranoidprofessor.com\/index.php\/wp-json\/wp\/v2\/tags?post=2730"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}