Marathon is a Mesos framework for long-running services.
Given that you have Mesos running as the kernel for your datacenter,
Marathon is the init
or upstart daemon.
It was written by the team that also developed Chronos.
Marathon provides a REST API for starting, stopping, and scaling services. There is also a Ruby command line client. Marathon is written in Scala and can run in highly-available mode by running multiple Marathon instances. The state of running tasks gets stored in the Mesos state abstraction. Features are listed below.
Marathon is a meta framework: you can start other Mesos frameworks such as Chronos or Storm. It can launch anything that can be launched in a standard shell. In fact, you can even start other Marathon instances via Marathon.
If you have questions, please post on the Marathon Framework Group email list.
You can find Mesos support in the #mesos
channel on freenode (IRC).
The team at Mesosphere is also happy to answer any questions.
- Mesos 0.15+ (the current version of marathon requires Mesos 0.15+. If you are still running 0.14, you can change the version in the
pom.xml
) - Zookeeper
- JDK 1.6+
- Scala 2.10+
- Maven 3.0+
- HA -- run any number of Marathon schedulers, but only one gets elected as leader; if you access a non-leader, you get an HTTP redirect to the current leader
- Basic Auth and SSL
- REST API
- Web UI
- Metrics -- via Coda Hale's metrics library
- Service Constraints -- e.g., only one instance of a service per rack, node, etc.
- Service Discovery and Monitoring
- Event Subscription -- e.g., if you need to notify an external service about task updates or state changes, you can supply an HTTP endpoint to receive notifications
The graphic shown below depicts how Marathon runs on top of Mesos together with the Chronos framework.
In this case, Marathon is the first framework to be launched and it runs alongside Mesos.
In other words, the Marathon scheduler processes were started outside of Mesos using init
, upstart
, or a similar tool.
Marathon launches two instances of the Chronos scheduler as a Marathon task.
If either of the two Chronos tasks dies -- due to underlying slave crashes, power loss in the cluster, etc. --
Marathon will re-start an Chronos instance on another slave.
This approach ensures that two Chronos processes are always running.
Since Chronos itself is a framework and receives Mesos resource offers, it can start tasks on Mesos. In the use case shown below, Chronos is currently running two tasks. One dumps a production MySQL database to S3, while another sends an email newsletter to all customers via Rake. Meanwhile, Marathon also runs the services required for the web app, in general.
The next graphic shows a more application-centric view of Marathon running three tasks: Search, Jetty, and Rails.
As the website gains traction and the user base grows, we decide to scale-out the search and Rails-based services.
Imagine that one of the datacenter workers trips over a power cord and a server gets unplugged. No problem for Marathon, it moves the affected search service and Rails instance to a node that has spare capacity. The engineer may be temporarily embarrased, but Marathon saves him from having to explain a difficult situation!
First, install Mesos. One easy way is via your system's package manager.
- Ubuntu 12.04, AMD64
- Ubuntu 12.10, AMD64
- Debian Wheezy, AMD64
- CentOS 6.4, AMD64
- RedHat 6.4, AMD64
- OS X, 10.7 & 10.8
If building from source,see the Getting Started page,
or the Mesosphere tutorial
for details. Using make install
will install Mesos in /usr/local
in the same way as these packages do.
To create a Jar for Marathon, checkout the sources and use Maven to build it:
mvn package
The following command launches Marathon on Mesos in local mode, which is not how you would run it on your cluster.
Point your web browser to localhost:8080
and you should see the Marathon UI.
bin/start --master local
To launch Marathon in production mode, you need to have both Zookeeper and Mesos running:
bin/start --master zk://zk1.foo.bar,zk2.foo.bar/mesos
Using HTTPie:
http localhost:8080/v1/apps/start id=sleep cmd='sleep 600' instances=1 mem=128 cpus=1
http localhost:8080/v1/apps/scale id=sleep instances=2
http localhost:8080/v1/apps/stop id=sleep
Using Marathon Client, the following runs Chronos:
marathon start -i chronos -u https://s3.amazonaws.com/mesosphere-binaries-public/chronos/chronos.tgz -C "./chronos/bin/demo ./chronos/config/nomail.yml ./chronos/target/chronos-1.0-SNAPSHOT.jar" -c 1.0 -m 1024 -H http://foo.bar:8080