Search code examples
mesosmarathon

how marathon determine a service instance is ready to service


buddies

I am wondering how marathon get to know a serice instance is ready to service?

Is there any interface to customize the health check during the starting up of a instance?

thanks


Solution

  • Have a look at the docs at

    You can implement a variety of checks, not only on http endpoints, but also tcp... For example, if you're starting a dockerized MySQL service, you could perform a health check on tcp port 3306 to verify that MySQL is actually started and reachable:

    "healthChecks": [
        {
            "portIndex": 0,
            "protocol": "TCP",
            "intervalSeconds": 1,
            "timeoutSeconds": 2,
            "maxConsecutiveFailures": 5
        }
    ]
    

    To be dynamic, the portIndex is important. So for example, you used bridged networking with Docker, and Marathon chooses the port automatically (and you only exposed on port), then the portIndex needs to be set to one.

    Also, if you want immediate health check upon startup (i.e. the task should not be considered as RUNNING until everything's up), you'll need to omit the gracePeriodSeconds parameter.