HAProxy Health Check

The default load balancer for Engine Yard Cloud is HAProxy. This runs on all Application instances, but is utilised only on the Application Master instance, as DNS should be configured to resolve the application domain(s) to the Elastic IP address attached to that instance. Therefore all application traffic hits HAProxy on the Application Master instance is then load balanced out to Nginx across all Application instances in the Environment. The Chef configuration runs made when instances are provisioned, terminated and restarted ensure that the HAProxy configuration file is kept up to date with the required instances.

HAProxy uses a health check system to decide when instances are in a healthy state to accept traffic. By default this check is a simple TCP connection on the Nginx port, meaning that if Nginx is running the instance will be seen as healthy.

In certain cases, such as an instance restart or problem with the functionality, configuration or application code of a specific instance it may be the situation that Nginx is running but the application not responding. In such cases requests directed to the instance by HAProxy will fail to load successfully, timing out or returning an error response/message.

To prevent such cases we allow for the setting of a HAProxy Health Check Path. When configured, the HAProxy health check will instead utilise a HTTP request to the requested path. Any 2XX, 3XX or 503 (returned when the maintenance page is in place) response is considered healthy, whilst all other responses (including no response) are considered unhealthy and the instance pulled from the load balancing pool.

The HAProxy Health Check Path is configured at the Application level and can be set either when creating a new Application or by editing an existing Application. If editing an existing Application then an Apply will be required afterwards to update the HAProxy configuration file on the instances.

HAProxy_Health_Check.png

In order to do a holistic test of your application and database, it is recommended that the path should connect to your application and not be set to a static or cached page, though you should avoid any paths that are complex or slow to load, in order to avoid any unnecessary resource consumption. It is also recommended that if you use analytics that you exclude this path from analytics collections.

Comments

  • Avatar
    Giang Nguyen

    What happens if the Path is blank? Would the healthcheck still perform on the root domain?

    0
    Comment actions Permalink
  • Avatar
    Pasan Chamikara

    Hello Giang,

    If the health check path is left blank then HAProxy continues to use the default TCP check, rather than a HTTP check. This check only cares that Nginx is running, not what response code it gives, so the check can still pass and route traffic to instances where the application itself is returning errors

    Pasan

    Edited by Pasan Chamikara
    0
    Comment actions Permalink

Please sign in to leave a comment.

Powered by Zendesk