There has been a lot of noise around MicroProfile for quite a while now, and one of the specs provided by MicroProfile are Health Checks. The aim of this spec is to allow you to write a number of health checks that will run when you hit a specific endpoint, the intention being that this endpoint can be periodically poked by a container orchestrator to determine if an instance is responsive and healthy.
Obviously however, not all container environments will have a health checker feature, and while you can poke the /health endpoint yourself manually, this isn’t really practical or convenient for use as a proper health check. What this new feature we’ve introduced does is allow you to configure an automated check within Payara Server itself that will periodically poke the /health endpoint of all instances in a cluster, just as how the container manager would.
As with most things in Payara Server, this service can be configured using either the Administration Console or by using asadmin commands. For Payara Micro, you will have to put the asadmin command in a post-boot command file.
The command to configure the checker is set-healthcheck-microprofile-health-checker-configuration (yes we’re already looking at changing the name!). It takes the following options:
- --enabled – Whether the checker should run or not
- --time – How frequently the checker should run if enabled – used in combination with –unit
- --unit – The unit of time for how frequently the checker should run if enabled – used in combination with --time
- --checkername – The name of the checker that you’ll see printed out in the log files
- --timeout – How long the checker should wait to connect to a /health endpoint before timing out as a failure
The command also accepts the --dynamic option to allow you to have any changes you make take effect immediately.
As the service only currently runs from the DAS (in a Payara Server environment), the configuration page for the service can be found under server (Admin Server) > MicroProfile Healthcheck Checker. The options remain the same between the asadmin command and the admin console:
In the future we look to build upon this feature by allowing Payara Server to manage the lifecycle of other Payara Server and Payara Micro instances – starting and stopping them to help guarantee a specified level of service to bring some of the advantages of containerised environments to non-containerised ones (as well as allowing some fancy hybrid solutions I’m sure!) We’re also looking at integrating our pre-existing health check system with this feature (and MicroProfile Health!) for a more cohesive and fully featured health check system of both your applications and the Payara Server & Payara Micro instances running them.
Want to Try it Out?