I have to use Javalite for my project based on Microservice architecture, so wanted to check whether tracking support (something similar to /actuator/health & /actuator/prometheus in Spring Boot) is available through some existing plugin or any suggestions regarding custom changes to support the same?
1 Answers
ActiveWeb does not have a direct support for this, but we routinely build similar services. The "health" means many different things for different apps. We have built numerous enterprise projects using JavaLite and so far worked out the following approach. Normally we have a project made up of multiple apps:
- Customer facing web app (Web)
- Back office app for controlling accounts, reporting, etc. (Admin)
- Web Services API (API)
- Backend processing app (Worker)
Every app is clustered, so we would have a number of instances, and we need to know the health of each instance. The health of each instance is determined by:
- Current free heap space
- Access to databases (usually multiple)
- Access to caches
- Access to local services (web to api, to worker, etc. )
- Access to NFS
- Whatever else makes sense for this app
So... we implement a so-called StatusController
for each type of an app. Such status controller will call all services, one after another necessary for the livelihood of this app when its index()
method is called and will generate a JSON document with results. If everything is good, the JSON doc is simple {"status":"OK", "service1": "OK", "service2": "OK"}
or something similar. If one of the services is inaccessible, it generates an exception and responds with a JSON file that contains the exact exception: {"status":"ERROR", "service1": "OK", "service2": "Exception: exception stack trace"}
.
The Admin Web app also contains a single Health Page that will aggregate calls to all apps in the cluster and will display a complete report that is also color coded (green - OK, red -Error). So, by glancing on this page, we know exactly what is wrong in the cluster if there is a problem.
However, the Admin Health page also carries a second purpose. It is a web service that is called by Pingdom. If the cluster is healthy, this page returns HTTP code 200, and if there is at least one problem, it will return 500. We use the URL to Health Page in Pingdom, which is tracking this page once per minute. Whenever there is a problem with any of the service in the cluster, the StatusController
returns 500 to Pingdom and it will send a notification to whomever is on call. When we get notified, we look at the Health Page for the information what is wrong with the cluster.
We worked out this approach years ago, and it has been faithfully serving us ever since.

- 5,432
- 2
- 31
- 46
-
Thanks for the suggestion @ipolevoy. Will explore it – Ajay Singh Apr 24 '19 at 09:19