I want to know about the possible options for auto-scaling my web app architecture. What I have in architect is web-app (Tomcat), middleware (RabbitMQ), database(MongoDB), worker(standalone Java app). Right now I am attempting scaling based on the CPU Utilization. I can auto scale my web-app and worker as expected, but I am facing problems scaling rabbitmq because I do not know how to pass load to the newly instantinated rabbtimq server.

For instance, I have 2 Tomcat servers running. Whenever the CPU utilization of my RabbitMQ instance is greater than 80%, AWS will add a new RabbitMQ server. But my Tomcat server(s) do not know that a new instance of RabbitMQ is added, so they keep referring to the original RabbitMQ server only and not the newly created one.

What could I do? Should I auto-scale whole architecture when Rabbit CPU utilization goes up? Or should I give up the idea of auto-scaling RabbitMQ entirely and create the required instances at the initial stage of deployment? Are there other options?


The problem is that your Tomcat servers (and most likely your workers) don't know about the RabbitMQ server. You need to do 1 of 2 things in this scenario: (a) Tell them about the new server, or (b) Make it so that they don't care

For (a) above, you could notify each Tomcat server and worker when your new RabbitMQ server start, or put the info in some list that your other components references.

However, in this scenario, assuming you have a queue on RabbitMQ #1, what happens to that queue if you start RabbitMQ #2? You'll actually have 2 queues in this case, not a single queue spanning 2 servers. Does your application handle this?

For (b) above, you can take a look at RabbitMQ Clustering . My understanding is that with RabbitMQ clustering, you can have nodes come and go, and the clients shouldn't care.


RMQ has come up with new backend for AWS which can be used to cluster the nodes in autoscaling. Tyr using the backend by just defining it in the Rabbitmq config and on service restart it will pick all nodes under same auto scaling group using tags and cluster them.We need to make sure we bring up the instances using the following role which enable them to describe ec2 instances and autoscaling groups.

{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "autoscaling:DescribeAutoScalingInstances", "ec2:DescribeInstances" ], "Resource": [ "*" ] } ] } Now we will login into once instance and configure two repository one for Erlang installation and second for Rabbitmq installation.

cd /etc/yum.repos.d/ vi rabbit_erlang.repo [rabbitmq_erlang]

name=Repo to install erlang for centos7

gpgkey=https://packagecloud.io/rabbitmq/erlang/gpgkey metadata_expire=300


sslverify=1 vi rabbitmq.repo [rabbitmq_erlang]

name=Repo to install rabbitmq for centos7 baseurl=https://dl.bintray.com/rabbitmq/rpm/rabbitmq-server/v3.8.x/el/7/ enabled=1 gpgcheck=0

Now repo has been configured but we generally observed that package install may conflict with existing epel repositories in Centos. So its best practice to disable existent repositories and enable new one.

yum -q makecache -y --disablerepo='epel*' --enablerepo='rabbitmq*' Once it is completed now we will go ahead and install rabbitmq-server , perl-JSON and erlang packages using yum command. Make sure latest version is installed

yum install erlang perl-JSON rabbitmq-server -y rpm -qa | grep rabbitmq Now we have latest package of rabbitmq server installed on AWS instances. We will move ahead with maintaining hosts file for each node. To make sure every new node in existing auto scaling group join cluster successfully we need to find the way of automatic detection on AWS nodes within the autoscaling group

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.