All of us have at some point deployed our applications to cloud providers, we may have come across the term “health checks”.
Load Balancers determine whether to route traffic to the application based on the health check. Also, it can decide to restart the application if it is not responding or errors out. For that, it needs an endpoint that returns a 200 status code.
Before
Previously, we would have to develop a controller and a route in order to give a health check end point.
After
With the latest changes, we can use the default health check controller provided by Rails in version 7.1.
This default health check controller is available at /up
.
We can now visit /up
to check whether the app is running.
If the application is healthy, it will return a 200 status code.
Else, it will return a 503 status code.
This helps us eliminate the need to create a custom health check endpoint and let Rails handle it.