Question

I've set up a server in elastic beanstalk. When required, it is supposed to increase the number of instances from 1 to up to 4. I have a sneaking suspicion, however, that when it starts a new instance that instance won't be properly configured, because I was unable to install the mySQL module for Python without ssh'ing into the instance and setting it up manually, as per this question.

So my first question is what is the best way to test that Elastic Beanstalk is scaling correctly? If new instances are started up, how can I be sure that I'm seeing one of the new ones rather than the original, manually configured one?

My second question is that if this is a problem like I suspect, how can I fix it? Can I "clone" my working instance and start successfully duplicate them when required? How would I do that?

Thanks a lot, Alex

Update: After the very helpful advice from joker, I added this to the myapp.config file:

container_commands:
    install_MySQL-python:
        command: /opt/python/run/venv/bin/easy_install MySQL-Python==1.2.3

As you can see, the problem I was having was that MySQL-Python wouldn't install correctly with pip, I had to use easy_install. This means it couldn't be installed through the requirements.txt file that is used for all the other python dependencies. With the added commands above put into the config file in my .ebextensions folder, this is done when the instance is initiated and I don't have to ssh into each individual instance.

As a side note, you don't have to include "sudo" in the command above, even though you do when achieving the same through ssh. In fact I had it in there at first and it didn't work.

Thanks a lot joker.

Was it helpful?

Solution

Alex,

I think your suspicion is correct. Any configuration changes you make to your running EC2 instance will not automatically appear on new instances.

On to your first question:

The easiest way to test how your system works in a multi-server environment, is probably to change the parameter Minimum instance count in the Autoscaling part of the Configuration section of the Elastic Beanstalk AWS Console. Set this parameter to, for instance, 2.

(Another way to see how new servers are started, is simply to kill your current EC2 instance. Just select the action Stop on your running instance. The load balancer should detect this, and automatically deploy a new instance for you once the health has transitioned from GREEN to RED.)

And the second question:

Your best bet around the problem is to customize your AWS EB environment. Create a .config file to set up required libraries and perform configuration changes to your new instances.

Good luck!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top