Load balancing with HAProxy
The HAProxy-Marathon-bridge script is shipped with the Marathon installation. You can also use Marathon-lb for the same. Both of these create a configuration file for HAProxy and a lightweight TCP/HTTP proxy by looking up the running tasks from Marathon's REST API.
HAProxy-Marathon-bridge is a simple script providing a minimum set of functionalities and is easier to understand for novice users. The latter one, Marathon-lb, supports advanced features such as SSL offloading, load balancing based on the VHost, and sticky connections.
Creating the bridge between HAProxy and Marathon
First, you need to create an HAProxy configuration from the running Marathon instance, which, by default, runs on port 8080
of the machine. You can use the HAProxy-Marathon-bridge script for this through the following syntax:
$ ./bin/haproxy-Marathon-bridge localhost:8080 > /etc/haproxy/haproxy.cfg
Note that here we specified localhost:8080
because we ran the Marathon instance and HAProxy...