Autoscaling capabilities for apps running in Marathon
50K+
Adds possibility to automatically scale applications running in Marathon that are consuming messages from RabbitMQ. If the current number of instances starts to fall behind the number of messages that is piling up in the queues, this application will take care of increasing instances to catch up the demand. It also has the capability of scale the application down when there are no more messages left.
Number of instances of configured application will be increased by 1 every time treshold of AUTOSCALE_MAXMESSAGES is reached until AUTOSCALE_MAXINSTANCES is reached. In case AUTOSCALE_MAXINSTANCES is specified, app will be also scaled down every time the number of messages is 0. To avoid app being scaled up and down all the time, there is a cooldown period that can be specified when starting up the autoscaler container. By default the cooldown period is 5 minutes.
Marathon-rabbitmq-autoscale (autoscaler) is distributed as docker image available on Docker Hub.
Since the application is dependent on Marathon, the most natural way to deploy it to run it in marathon. It is configured using environment variable JAVA_OPTS - it accept java command line arguments as a content (see java documentation).
See example configuration attached:
{
"id": "/autoscaler",
"cpus": 1,
"mem": 256,
"disk": 0,
"instances": 1,
"container": {
"type": "DOCKER",
"docker": {
"image": "alenkacz/marathon-rabbitmq-autoscale",
"network": "BRIDGE",
"forcePullImage": true
}
},
"env": {
"JAVA_OPTS": "-DrabbitMq.0.username=user -DrabbitMq.0.password=password -DrabbitMq.0.httpApiEndpoint=https://rabbitmq.yourdomain.com:15671/api -Dmarathon.url=http://marathon.yourdomain.com/"
}
}
There are two ways how to configure application to be automatically scaled:
The first choice is the preferred one.
This is the preferred choice that fits better to the environment of Marathon application. After the start, autoscaler checks all applications running in given marathon instance and configures application that contains both required labels.
After you deploy your app to Marathon, you have to add these labels:
It is possible to add label from:
Example of api call
{
"id": "/product/service/myApp",
"labels": {
"AUTOSCALE_QUEUE": "queuename"
}
}
You can also configure the application directly as an autoscaler configuration. See the section 'How to run autoscaler' and add configuration via java commandline arguments. For example -Dapps.0.name=testapp. The format of this is determined by the choice of configuration library.
Content type
Image
Digest
Size
487.3 MB
Last updated
almost 9 years ago
docker pull alenkacz/marathon-rabbitmq-autoscale