You can use the marathon-lb-autoscale application to implement request rate-based autoscaling with Marathon. The marathon-lb-autoscale application works with any application that uses TCP traffic and can be routed through HAProxy.
marathon-lb-autoscale collects data from all HAProxy instances to determine the current RPS (requests per second) for your apps. The autoscale controller then attempts to maintain a defined target number of requests per second per service instance. marathon-lb-autoscale makes API calls to Marathon to scale the app.
- marathon (URL) – The URL for Marathon
- haproxy (URLs) – A comma-separated list of URLs for HAProxy. If this is a Mesos-DNS A-record, all backends will be polled.
- interval (float) – The number of seconds (N) between update intervals. The default is 60.
- samples (integer) – The number of samples to average. The default is 10.
- cooldown (integer) – The number of additional intervals to wait after making a scale change. The default is 5.
- target-rps (integer) – The target number of requests per second per app instance. The default is 1000.
- apps (APPS) – A comma-separated list of
<app>_<service port> pairs to monitor.
- threshold-percent (float) – Scaling will occur when the target RPS differs from the current RPS by at least this amount. The default is 0.5.
- threshold-instances (integer) – Scaling will occur when the target number of instances differs from the actual number by at least this amount. The default is 3.
- intervals-past-threshold (integer) – An app won’t be scaled until it’s past it’s threshold for this many intervals. The default is 3.
Common options: -h, –help – Show this message
Run marathon-lb-autoscale on Marathon
- Create a JSON file
$ nano marathon-lb-autoscale.json
- Paste this into the file. Edit the arguments to your your desired parameters:
- Add the app to Marathon
$ dcos marathon app add marathon-lb-autoscale.json
- Verify that the app has been added:
$ dcos marathon app list