Actually I am still a bit confused with aws auto scale up
and load balancer
I am wondering if someone can help me clarify if my logic of understand is right and if so, would it be possible to combine the usage of auto-scale up
and load balancer
?
As for auto-scale up
let's say I can setup a cloudalarm
that if my main instance
reaches to cpu > 90%
for a minute
then a new instance
will spin up and the new instance
will share the burden with the main instance
to lower the cpu usage. (after spin up, aws will do the rest for us)this is as if I set the setting to spin up 1 instance up to 5 max
If this is correct for my understanding, does the new instance
need to have the exactly the same settings of the server? If so, that means I need to create an image of the main instance
and each time if I update the main instance
I will have to create a new image
then change the cloudalarm
/ auto-scale up
to launch the new image
right?
- If the above is right, is there a better way of doing this?
or else, it seems like I have to keep on creating image and change settings if the
main instance
get changes everyday.
As for load balancer
, I read through the documentation and played around. Spin up three instances
, registered them all to load balancer
. All 3 are healthy, and if I reload the page, it keeps on changing between the three instances
. If one instance is down, the other two will be running.
If this is also correct for my understanding, does this mean I need to have 2+ the same instances running and each time when I do deployment I need to do it to all the instances? Wouldn't this be a lot of work if I have lots of servers and want all of them to use load balancer
in case the server suddenly becomes unhealthy?
If both of my understanding are correct, is it possible to somehow use auto-scale up
with cloudalarm
that if somehow main instance
is unhealthy create image of the instance then register to the load-balancer
?
Sorry for the trouble for the readings, but I do wondering if I am understanding them wrong or I am over thinking and getting myself confused.
Thanks for any advice and help.
When you are using Auto Scaling and Load Balancing, you want all your EC2 instances to be identical. So they are all (a) rooted on the same AMI image, and (b) proceed through the same initialization steps to end up with the same code and assets on them. This way, they will all respond the same with the same input from your HTTP client.
To accomplish this, do not attempt to update your EC2 instances manually. When you're scaling up and down, your work will be lost.
When you need to deploy a new version of your code, you should do one (or more) of the following patterns.
Pattern 1:
Pattern 2:
Pattern 3:
There are other patterns, but these are some common ones that work.
If you're new to Auto Scaling and Load Balancing, I highly recommend you take a serious look at Elastic Beanstalk. It will manage all of the above for you, making deployments and updates much easier.
Some additional notes: