We connect our REST services together using smartstack. Smartstack is mainly the combination of nerve and synapse. Nerve lets your service be discovered by other services, and synapse lets you discover services you yourself need.
In order to play well with smartstack, you need to define two special resources in your service.
Both should return Content-type: text/plain
.
The check-check endpoint should return status code 200
and body OK
.
It should only do this if the service is actually healthy.
A service is NOT healthy unless it can talk to its data stores and perform most of its API functions. Your health check should strive to be as comprehensive as possible.
A nerve process running locally on your node will periodically (usually every 1-5 seconds) hit /health
.
If the check fails (returns anything other than 200
) that service instance will be de-registered and undiscoverable until the health check recovers.
This endpoint should always just return status 200
and body PONG
.
Synapse, running throughout the infrastructure on any machine which requires your service, will hit this endpoint every 30-60 seconds.
Because the number of machines may be large, you should strive to make the /ping
check as lightweight as possible.