Getting HTTP service statuses
Correct balancing of web services requires the user to constantly and accurately transmit the status of processes. IN order to achieve this, special API requests to process status handlers are implemented.
The status requests are as follows:
/${AK-SERVICE-NAME}/health
/${AK-SERVICE-NAME}/readiness
where ${AK-SERVICE-NAME} is a name of the platform service: webcontrol, webadmin, webapi, trkaction, trkwebctrl or cookiesaver.
List of requests
| Request | Name of a service | Description |
|---|---|---|
GET /webcontrol/health | webcontrol | Checks if the webcontrol service is running |
GET /webadmin/health | webadmin | Checks if the webadmin service is running |
GET /webapi/health | webapi | Checks if the webapi service is running |
GET /trkaction/health | trkaction | Checks if the trkaction service is running |
GET /trkwebctrl/health | trkwebctrl | Checks if the trkwebctrl service is running |
GET /cookiesaver/health | cookiesaver | Checks if the cookiesaver service is running |
GET /webcontrol/readiness | webcontrol | Checks if the webcontrol service is ready to accept traffic |
GET /webadmin/readiness | webadmin | Checks if the webadmin service is ready to accept traffic |
GET /webapi/readiness | webapi | Checks if the webapi service is ready to accept traffic |
GET /trkaction/readiness | trkaction | Checks the trkaction service to see if it is ready to accept traffic |
GET /trkwebctrl/readiness | trkwebctrl | Checks the trkwebctrl service to see if it is ready to accept traffic |
GET /cookiesaver/readiness | cookiesaver | Checks if the cookiesaver service is ready to accept traffic |
Response to request
Requests of type /health always return the code 200 with the text "OK" in the response.
If there are no problems, /readiness requests return the code 200 and the following response:
{
"status": "OK"
}
If there are any problems, the code 503 (Service not available) and the response will be returned:
{
"status": "FAIL",
"failed": ["<name of an error>"]
}
The following errors can be specified in the "failed" array:
- started - the service startup has not been completed yet
- mongo - the service does not have access to Mongo
- rmq-alive - the service does not have access to RabbitMQ
- rpc-procrpc - no RPC access to ProcRPC service or ProcRPC service does not have access to Mongo
- rpc-proctask - no RPC access to ProcTask service or ProcTask service does not have access to Mongo
More information about the occured errors can be found in the logs of services.
Use in a load balancer
For load balancing, use /readiness requests, not /health: /health returns code 200 as long as the process is alive and checks nothing. /readiness returns 503 until the service has finished starting or has no access to its subsystems.
- The check is performed with the
GETmethod only. - The internal check timeout is 500 ms, so set the balancer check timeout to at least 1 s.
- A node is marked unavailable as a whole: create a separate upstream for each service so that a
cookiesaverfailure does not take the web interface out of balancing. - The
/<service>/readinesspaths are served by the web domain nginx; the tracking and pixel domains do not have them. - A 5-second check interval is enough: every
/readinessrequest makes the service poll Mongo and RabbitMQ.
Ready-made nginx and HAProxy configurations are in Platform server load balancing.