GithubHelp home page GithubHelp logo

isabella232 / marathon-autoscale Goto Github PK

View Code? Open in Web Editor NEW

This project forked from softwaremill/marathon-autoscale

0.0 0.0 0.0 97 KB

Simple Concept for Scaling Application running on Marathon based on Utilization

Shell 20.58% Python 79.42%

marathon-autoscale's Introduction

marathon-autoscale

Dockerized container autoscaler that can be run under Marathon management to dynamically scale a service running on DC/OS.

Running on OSS version of DCOS with OAuth enabled

When running on free version of DCOS thi script uses marathon and mesos api directly (in oposite to DCOS api endpoint). Marathon and Mesos endpoints are not secured by default, so it's possible to use it without token even if OAuth is enabled. To use it add --endpoint-type marathon switch or use AS_ENDPOINT_TYPE env variable. You also have to set dcos master to http://marathon.mesos:8080. If running on DCOS with OAuth disabled or the commercial version of DCOS use dcos as endpoint type.

Prerequisites

A running DCOS cluster.

If running on a DC/OS cluster in Permissive or Strict mode, an user or service account with the appropriate permissions to modify Marathon jobs. An example script for setting up a service account can be found in create-service-account.sh

Building the Docker container

How to build the container:

docker build .
docker tag <tag-id> <docker-hub-name>:marathon-autoscale:latest
docker push <docker-hub-name>:marathon-autoscale:latest

Creating a service account

The create_service_account.sh script takes two parameters:

Service-Account-Name #the name of the service account you want to create
Namespace-Path #the path to launch this service under marathon management.  e.g. / or /dev

$ ./create-service-account.sh [service-account-name] [namespace-path]

Program Execution

The python program runs on marathon and can be executed using the following command:

$ dcos marathon app add marathon.json

Where the marathon.json has been built from one of the samples:

sample-autoscale-noauth-marathon.json #security disabled or OSS DC/OS
sample-autoscale-username-marathon.json #security permissive or strict on Enterprise DC/OS, using username and password (password stored as a secret)
sample-autoscale-svcacct-marathon.json #security permissive or strict on Enterprise DC/OS, using service account and private key (private key stored as a secret)

Input paramters user will be prompted for:

AS_MARATHON_APP: # app to autoscale
AS_TRIGGER_MODE: and | or | cpu | mem #which scaling mode you want
AS_MIN_INSTANCES: #min number of instances, don’t make less than 2
AS_MAX_INSTANCES: #max number of instances, must be greater than AS_MIN_INSTANCES
AS_DCOS_MASTER: #don’t change unless running marathon-on-marathon
AS_MAX_CPU_TIME #max average cpu time as float, e.g. 80 or 80.5
AS_MIN_CPU_TIME #min average cpu time as float, e.g. 55 or 55.5
AS_MAX_MEM_PERCENT #max avg mem utilization percent as float, e.g. 75 or 75.0
AS_MIN_MEM_PERCENT #min avg men utilization percent as float, e.g. 55 or 55.0
AS_COOL_DOWN_FACTOR # how many times should we poll before scaling down
AS_TRIGGER_NUMBER # how many times should we pole before scaling up
AS_INTERVAL #how often should we poll in seconds

Notes

For MIN_CPU_TIME and MAX_CPU_TIME on multicore containers, the calculation for determining the value is # of CPU * desired CPU utilization percentage = CPU time (e.g. 80 cpu time * 2 cpu = 160 cpu time) For MIN_MEM_PERCENT and MAX_MEM_PERCENT on very small containers, remember that Mesos adds 32MB to the container spec for container overhead (namespace and cgroup), so your target percentages should take that into account. Alternatively, consider using the CPU only scaling mode for containers with very small memory footprints.

If you are using an authentication:

AS_USERID #username of the user or service account with access to scale the service
--and either--
AS_PASSWORD: secret0 #password of the userid above ideally from the secret store
AS_SECRET: secret0 #private key of the userid above ideally from the secret store

Scaling Modes

AND

In this mode, the system will only scale the service up or down when both CPU and Memory have been out of range for the number of cycles defined in AS_TRIGGER_NUMBER (for up) or AS_COOL_DOWN_FACTOR (for down). Rarely used.

OR

In this mode, the system will scale the service up or down when either the CPU or Memory have been out of range for the number of cycles defined in AS_TRIGGER_NUMBER (for up) or AS_COOL_DOWN_FACTOR (for down).

CPU

In this mode, the system will scale the service up or down when the CPU has been out of range for the number of cycles defined in AS_TRIGGER_NUMBER (for up) or AS_COOL_DOWN_FACTOR (for down).

MEM

In this mode, the system will scale the service up or down when the Memory has been out of range for the number of cycles defined in AS_TRIGGER_NUMBER (for up) or AS_COOL_DOWN_FACTOR (for down).

marathon-autoscale's People

Contributors

dobriak avatar gkocur avatar gpetrousov avatar jgarcia-mesosphere avatar keith-mcclellan avatar tkrausjr avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.