As a newbie to AWS concepts, I am trying to understand ASG concept.
a) Does it work per region or per Availability Zones?
b) Do I need to have an ASG for each Availability zone, or it can scale up and down the instances from different AZs on a shared region?
You can have an autoscale group work across availability zones, but not across regions.
Though it is possible to have an ASG in a single AZ, you would certainly want the ASG to be in multiple AZ's, otherwise you have no real fault tolerance in the case where an AZ has problems.
Related
Is it possible to have ASG as a DR between two AZ? For example, I have 5 instance in AZ1 servicing requests. During the AZ outage, I wanted to spin-up the 5 Instances in AZ2 and serve the request. Is it possible to control the isntance spinning up in AZ2 if only AZ1 Fails ?
You can use AWS AutoScaling across multiple AZ, but only in a specific Region.
"Auto Scaling can work across multiple Availability Zones in an AWS
Region, making it easier to automate increasing and decreasing of
capacity."
If you are trying to have high availability you can use aws global services like AWS CloudFront or AWS Global Accelerator. Example Scenario:
The definition of the vpc_zone_identifier parameter is a list of subnet IDs to launch resources in. Subnets automatically determine which availability zones the group will reside.
So suppose I list eu-west-1a and eu-west-1c for that parameter and a desired capacity of 3.
Is my ASG going to deploy my desired capacity randomly across the AZs (e.g. 2 + 1) or it will deploy 3 per AZ?
There will be only 3 instances distributed across the two AZs if the selected AZs have enough capacity. AWS tries to prioritize high-availability, so it will try to place the instances evenly across the AZs (2+1 in your case). Exact details are:
Amazon EC2 Auto Scaling attempts to distribute instances evenly between the Availability Zones that are enabled for your Auto Scaling group. Amazon EC2 Auto Scaling does this by attempting to launch new instances in the Availability Zone with the fewest instances. If the attempt fails, however, Amazon EC2 Auto Scaling attempts to launch the instances in another Availability Zone until it succeeds. For Auto Scaling groups in a VPC, if there are multiple subnets in an Availability Zone, Amazon EC2 Auto Scaling selects a subnet from the Availability Zone at random.
I am about to take my AWS Architect Associate Certification Exam and I have some things on ELB and ASG that I still don't get (or maybe I just did not study enough) and I liked to ask your help to clear things out.
Multi-AZ Autoscaling Group
what difference does it make when I say I have one ASG that will handle
autoscaling for 3 AZs rather than have one ASG for each AZ? If fault tolerance
is the answer then the latter should be the standard setup, why have one ASG
for three or two AZs?
Multi-AZ ELB
same kind of question as I had for #1.
3.
Multi-AZ ASG and one ELB for each AZ
Multi-Az ASG and one ELB that serves multiple AZs
One ASG and One ELB for each AZ
What are the use cases for each?
The answer becomes more obvious when you think about the implications and understand what may be some missing details.
If an ASG crosses multiple availability zones, then it can increase capacity in the healthy zones when the instances in a catastrophically failed AZ become unavailable. With one in each, there would be no coordination like this.
The same thing is true for ELB. In both Classic and Application load balancers, when you deploy a single ELB in multiple AZs, you actually get balancer hardware allocated from the beginning in each AZ -- yet the price is the same. If an AZ fails, it fails, and you still have working hardware in the remaining zones.
ELBs and ASGs in a single AZ would not be fault tolerant, and there's no reason to provision separate ones for each AZ, when you can provision just one, and have it handle the failure of an entire availability zone (unlikely, but not impossible) by scaling out (deploying more hardware) capacity in the healthy zones that remain.
Consider the case when an Auto Scaling group is configured to span multiple availability zones (such as in this scenario). When a new Amazon EC2 instance should be added to the scaling group (scale out) based on demand, how does Auto Scaling decide in which availability zone the instance will be placed? The one that has the smaller number of instances?
Thanks for your help.
As you expected, Auto Scaling would indeed select a zone that has the smaller number of instances, section Instance Distribution and Balance Across Multiple Zones within Availability Zones and Regions explains the general algorithm employed by Auto Scaling:
Auto Scaling attempts to distribute instances evenly between the
Availability Zones that are enabled for your Auto Scaling group. Auto
Scaling does this by attempting to launch new instances in the
Availability Zone with the fewest instances. If the attempt fails,
however, Auto Scaling will attempt to launch in other zones until it
succeeds. [emphasis mine]
An Auto Scaling group can also become unbalanced between the zones by various conditions (e.g. active termination of an instance), which can trigger an Auto Scaling rebalancing activity - please check the documentation linked above for more details on this and how edge cases are handled.
Generally its best to scale in such a way that the distribution of instances across zones is even (If you have 3 zones, scaling up would mean adding 3 instances, 1 to each zone). Adding more capacity does not mean traffic will split based on capacity. It will still continue to be round robin.
I hope you can provide a quick response to my question.
Is it possible to create auto scaling group which spans across regions ? Consider this scenario - Lets say all the availability zones in west are unavailabe. Can we configure auto scaling so that if the instance in US.West are down, create an instance in east zone ?
I dont think it is possible, because we need to specify the region for AWS_AUTO_SCALING_URL while using Command line scripts, which restricts the creation of launch configs, auto scaling group within that region only.
So we can only hope all the AZ's in that region are not down or move to VPC is that right ?
Elastic load balancing and Elastic IP are both region specific, I would assume that auto scaling is region specific and only between the availability zones in that region. The white paper on building fault tolerant applications doesn't explicitly state that you could auto-scale across regions but it does say that you can across zones.
"Auto Scaling can work across multiple Availability Zones in an AWS Region, making it easier to automate increasing and
decreasing of capacity."
I would believe if they supported multi-region, they would explicitly say so.
Thinking about this further, I'm not so sure it's even a good idea to auto-scale across regions. Auto-scale is more geared for a specific tier of your application.
For example, if a region was to go down, you would not want some of your web servers to use services across a slow link to another region (potentially) across the country.
Instead you would want route 53 to route the traffic to an autonomous stack running it's own auto-scaled layers in a separate region.
see this hosting chart everything from ELB down is region specific.
An Auto Scaling group can contain EC2 instances from multiple Availability Zones within the same region. However, an Auto Scaling group can't contain EC2 instances from multiple regions.
Read Note in this AWS Document
EC2 Auto Scaling groups are regional constructs. They can span Availability Zones, but not AWS regions.
PS. AWS Documentation
https://aws.amazon.com/ec2/autoscaling/faqs/