Auto Scaling EC2 instances without using Elastic Load Balancer AWS


Auto Scaling helps you maintain application availability and allows you to scale your Amazon EC2 capacity up or down automatically according to conditions you define.

It is easy to setup a Auto Scaling group if you have a ELB configured in front of your webservers, but in some scenarios if a customer wants to do auto scaling without using EBL it becomes difficult.


The reason for that is : 

  • If you don’t have ELB you cannot locate auto scaled EC2 instances once the auto scaling group is triggered. Auto Scaling Group does not automatically add or locate EC2 instance which was launched via trigger.


Lets take a Usecase scenario to understand it in depth :

Lets say, I would like to have auto-scaling feature enabled for few of my AWS instances. I’m not inclind to use ELB as my instances as I’ve setup Nginx reverse proxy which is configured to communicate to the web instances using their private IP addresses. How can I do autoscaling in such scenario ?

In case of auto-scaling, I need know the new IP address assigned to the auto-scaled instance so using some script I can add that new IP address to my Nginx server configuration so the Nginx server can start communicating to the new instance until it is live. In this case I need know following point :

  • How can I have reserved private IP which can be assigned to auto-scaling group ?
  • How to find the auto-scaled instance IP ?
  • How can I get trigger to my Nginx to search for new instance IP ?


Solution :

By default, the ip addresses assigned to auto scaled instances are dynamic, therefore you don’t have any workaround for launching instances with static private ip addresses.

The only workaround in this case is to create a script e.g. Lambda functions or cron jobs to poll Auto Scaling Groups for the Ips and update Nginx config.

What I would recommend is instead of using Nginx reverse proxy one should use ELB for there reverse proxy requirements this way it becomes easy to Auto Scaling instances.


I hope that helps


Blogger & Assc Cloud Architect

Site Footer

%d bloggers like this: