skip to Main Content

I have used AWS Auto Scaling to set up for my web server. My setting config is 1 for desired, minimum and maximum instances.

Now I want to stop my server, but i may want to restart it in future.

But if I stop directly in EC2 dashboard, it will respawn another EC2 instance, due to AWS Auto Scaling config.

So can I stop my server by setting 0 for desired, minimum and maximum instances ?

I know setting desired instance as 0 will terminate my current instance now, but in this case, if I change desired instance to 1 in future(it will initialize a new instance), can new instance will be initialized with last state when terminated, or it will be initialized with state of setting AMI ?

2

Answers


  1. Yes you can set those the min, max and desiredCount values to 0 to stop all running instances under an auto-scaling group. However, any state that you have in the EBS volumes of those severs would be lost, same for the contents of the RAM. If this is fine by you, then please go ahead.

    If there are important data/state in the RAM and in the EBS volumes that you’d like to keep, please do persists them somewhere more resilient (Like EFS, S3, Redis/Memcache or a DB server).

    If you want to resume the operation of those server, you can just restore the three configurations back to 1 or any combination you prefer to spawn instances on-demand.

    Login or Signup to reply.
  2. If your auto scaler is set up through Elastic Beanstalk, then you can scale your instances down to 0 through the configuration:

    1. Go to Configuration -> Click Edit under the "Instance traffic and scaling" section
    2. Scroll down to the "Time-based scaling" section
    3. Click "Add scheduled action"
    4. Give a name to your action, it can be anything
    5. Enter 0 for Min, Max, and Desired capacity
    6. Enter a time for the scaling down to occur. It takes a few minutes for the environment to update with the change, so I always set the time at least 10 or 15 minutes into the future if I want it applied right away.
    7. Click "Add"
    8. Scroll down and click "Apply"

    At the specified time, your instances will be scaled down to 0. Go through similar steps to scale your instances back up.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search