Skip to content
Mesos Marathon Service Discovery Agent
Go Shell
Branch: master
Clone or download
Pull request Compare This branch is 39 commits behind dawanda:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

Mesos Marathon Service Discovery Agent

mmsd links your cloud together.

Main features

  • simple
  • realtime update of runtime configuration state (haproxy, upstream-confd, ...)
  • modular handlers
    • haproxy handler to manage a load balancer service
    • upstream-confd handler to manage local upstream config files per application
  • filter apps to be exposed by load balancer (or service files) via labels from marathon app definitions.
  • first-class docker support.
  • DNS based service discovery (supports A and SRV query types).
  • TODO: provide simple rc scripts to run this agent (openrc/upstart/systemd)

Start me Up

mmsd  --marathon-host=localhost --marathon-port=8080

Docker Support

# build mmsd docker container image
docker build -t mmsd .

# run mmsd docker container in background
docker run --net=host -d --name mmsd mmsd \
           --marathon-host=$YOUR_MARATHON_IP --marathon-port=8080


mmsd - Mesos Marathon Service Discovery, version 0.9.3, licensed under MIT
Written by Christian Parpart <>

Usage: mmsd [flags ...]

  --dns-basename string
        DNS service discovery's base name (default "mmsd.")
  --dns-port uint
        DNS service discovery port (default 53)
        DNS service discovery to also push SRV on A
  --dns-ttl duration
        DNS service discovery's reply message TTL (default 5s)
        Enables DNS-based service discovery
        enables file based service discovery (default true)
        Enables gateway support
        Enable local health checks (if available) instead of relying on Marathon
        health checks alone. (default true)
        enables haproxy TCP load balancing (default true)
        enables UDP load balancing (default true)
  --filter-groups string
        Application group filter (default "*")
  --gateway-bind value
        gateway bind address (default
  --gateway-port-http uint
        gateway port for HTTP (default 80)
  --gateway-port-https uint
        gateway port for HTTPS (default 443)
  --haproxy-bin string
        path to haproxy binary (default "/usr/local/bin/haproxy")
  --haproxy-bind value
        haproxy management port (default
  --haproxy-cfgtail string
        path to haproxy tail config file (default "/etc/mmsd/haproxy-tail.cfg")
  --haproxy-port uint
        haproxy management port (default 8081)
  --managed-ip value
        IP-address to manage for mmsd (default <nil>)
  --marathon-ip value
        Marathon endpoint TCP IP address (default
  --marathon-port uint
        Marathon endpoint TCP port number (default 8080)
  --reconnect-delay duration
        Marathon reconnect delay (default 4s)
  --run-state-dir string
        Path to directory to keep run-state (default "/var/run/mmsd")
  -v, --verbose
        Set verbosity level
  -V, --version
        Shows version and exits

Upstream Config Files

An application, such as /developer/trapni/php will be written into a upstream-confd file with the name developer.trapni.php.instances with the following content

Service-Name: token
Service-Port: number
Service-Transport-Proto: tcp | udp
Service-Application-Proto: http | redis | redis-master | ...
Health-Check-Proto: tcp | http


Where hostN:portN is the actual host (Mesos Slave) your application has been spawned on.

Your application may read them upon startup and whenever this file changes (in realtime) to always have an up-to-date list of address:port pairs your other application is running on.

Marathon Label Definitions

Label proto = APP_PROTO

an app type name that identifies the given service, such as redis, smtp, ...

Label lb-accept-proxy = 1

Enables proxy-protocol on service port.

Label lb-proxy-protocol = 1 | 2

Enables proxy-protocol to the backend communication. 1 enables proxy-protocol version 1 (clear text) whereas 2 enables version 2 (binary). Any other value does not activate proxy-protocol.

Label lb-group = GROUP_NAME

Load-balancer group this app should be exposed to

Label lb-vhost = VHOST,...

list of virtual hosts to be served on gateway port 80

Label lb-vhost-default = PORT_INDEX

if set, this HTTP application (at port index) will serve as default application on port 80.

Label lb-vhost-ssl = VHOST,...

list of vhosts to be proxied via SSL, with SNI enabled, but no SSL termination performed.

Label lb-vhost-ssl-default = PORT_INDEX

if set, this HTTPS application (at port index) will serve as default application on the application gateway's SSL port (usually 443)

Label proto
  • tcp (default), TCP transport mode and simple TCP-connect health check
  • http HTTP transport mode, with HTTP health check
  • smtp SMTP protococol, enables SMTP-restrictive health check.
  • redis mode tcp and health check is using Redis text protocol
  • redis-master same as redis but only masters will be healthy
  • redis-slave same as redis but only slaves will be healthy
  • ... any other interesting text protocols we can map into haproxy?

Service Discovery HTTP endpoint

  • /v1/apps retrieves the list of all apps in Marathon, one app name by line
  • /v1/instances/NAME retrieves list of instances by hostname:port tuple in each line for given application path, for example: /v1/instances/production/sqltap1
You can’t perform that action at this time.