Domanda

I can't find much documentation on the leader_only attribute of Amazon's EC2 instances.

What happens to the leader when an autoscaling group scales down? The default autoscaling template terminates the oldest instance (which presumably would be the leader in most cases). After terminating the oldest instance does EC2 automatically elect a new leader? Or does the application only terminate non-leader instances?

Also, what if the leader fails. Does it create a new instance and name it the leader, or does it switch the leader attribute to a different existing instance?

Thanks!

È stato utile?

Soluzione

The idea of a leader only exists during the execution of a deployment in an environment update. After deployment has executed, there isn't a concept of a leader anymore

From: https://forums.aws.amazon.com/thread.jspa?messageID=411720&#411720

The link also has some code for a roll-your-own leader implementation, although depending on your needs it may be easier to figure something else out.

Altri suggerimenti

It is not a feature of AWS EC2 Auto Scaling Groups.

The leader_only attribute is an optional parameter when running container commands on AWS Elastic Beanstalk.

Optional. Sets an instance in the Auto Scaling group to be the leader. If the leader_only value is set to true, the command runs only on the instance that is marked as the leader. The leader runs first.

In theory you have two types of leaders:

  1. Deploy-time leader
  2. Run-time leader

To establish Deploy-time leader, use leader_only.

To establish Run-time leader, you are sort of on your own.
Because the instance that was a leader during deploy time,
might not be around for variety of reasons, like scaling down.
There are no good solutions, although there are some attempts scattered around.

For my own needs I created a solution which lists all instance ID-s, sorts alphabetically and picks first as a leader.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top