Mesos in AWS: Deploying a North-South Application

This article describes how to deploy and verify load-balanced application in a Mesos / Marathon cloud hosted by Amazon Web Services (AWS).

Applications must be created through Marathon, for example with a curl command through the CLI or using the “avi_proxy” label in a CloudFormation template. This article includes steps for creating a simple test application using the Marathon CLI. To create an application using labels, see here.

To deploy a service in this environment:

  1. Create the application through Marathon.

  2. Set the health check and application port numbers in the AWS EC2 instance to the port number assigned to the application by Marathon.

  3. Use a browser to navigate to the application.

Detailed steps are provided below.


The article assumes that Avi Vantage is already installed in the Mesos / Marathon cloud.

The steps in this article require access to the following resources:

  • Marathon account with privileges to create an application through Marathon
  • AWS account through which Avi Vantage was installed
  • User account on Avi Controller
  • Docker application (if creating a new application using the CLI)

Create an Application Through Marathon

The following commands are entered in an SSH session with Marathon to create a test application:

  1. Download Docker.json ( and save it in the /Downloads directory.

  2. Create a Docker image file such as the following for the application:

      "id": "webapp-ew1",
      "cpus": 0.5,
      "mem": 64.0,
      "instances": 2,
      "container": {
        "type": "DOCKER",
        "docker": {
          "image": "avinetworks/server",
          "network": "BRIDGE",
          "portMappings": [
            { "containerPort": 80, "hostPort": 0, "servicePort": 0, "protocol": "tcp" }
      "labels": {}"
      "healthChecks": [
          "protocol": "HTTP",
          "portIndex": 0,
          "path": "/",
          "gracePeriodSeconds": 5,
          "intervalSeconds": 20,
          "maxConsecutiveFailures": 3
  3. Start the application to create a virtual service for it:
    curl -H "Content­Type: application/json" -X POST -d@Downloads/Docker.json http://marathon-ip-or-hostname:8080/v2/apps

    The H and X options are required. The H option inserts a Content­Type header for the Avi SE application. The X option changes the HTML method of the request from GET (the default) to POST. Replace marathon-ip-or-hostname with the IP address or hostname of Marathon.

Set the Health-check and Application Port Numbers

  1. Locate the port number assigned to the application by Marathon:

    a. Log into the Avi Controller web interface.

    b. Navigate to Applications > Dashboard, and click on the icon for the virtual service.

    c. Hover over the virtual service name, to the left of the Edit button. Copy or write down the port number. aws-mesos-vscreate0

  2. Log into your AWS account, and browse to EC2 Load Balancing instance.

  3. Click on edit-icon to go to the AWS home page.

  4. Select EC2 and click on Load Balancing in the left pane.

  5. Click on stack-name-public instance in the Load Balancer field as shown in this example: aws-mesos-vscreate

  6. Click on the Listeners tab and edit the application port number to the application port number assigned by Marathon. aws-mesos-vscreate2

  7. Click on the Health Check tab and edit the ELB health check port number to the application port number assigned by Marathon. aws-mesos-vscreate3

Browse to the Application

  1. In AWS, click on the Description tab for the ELB instance. aws-mesos-vscreate4

  2. Copy-and-paste the DNS name (URL) into a new browser window. aws-mesos-vscreate5