Use with load balancers and containers
Most health checkers decide on the HTTP status: 200 is healthy, anything else is not. The health
endpoint returns 503 for DOWN and OUT_OF_SERVICE, so every checker below works without parsing
the JSON.
Pick the path by what the checker does when it fails:
| The checker… | Use |
|---|---|
| stops sending traffic to the instance | /actuator/health/readiness |
| restarts or replaces the instance | /actuator/health/liveness |
| alerts a human | /actuator/health |
AWS Application Load Balancer
Section titled “AWS Application Load Balancer”Set the target group health check:
| Setting | Value |
|---|---|
| Protocol | HTTP |
| Path | /actuator/health/readiness |
| Success codes | 200 |
| Interval | 10 seconds |
| Timeout | 5 seconds |
| Unhealthy threshold | 2 |
With Terraform:
resource "aws_lb_target_group" "app" { # ... health_check { path = "/actuator/health/readiness" matcher = "200" interval = 10 timeout = 5 unhealthy_threshold = 2 }}The same settings apply to Google Cloud load balancers, Azure Application Gateway and most other load balancers.
Docker HEALTHCHECK
Section titled “Docker HEALTHCHECK”HEALTHCHECK --interval=30s --timeout=3s --start-period=10s --retries=3 \ CMD curl --fail --silent http://localhost:8080/actuator/health/liveness || exit 1curl --fail exits with an error on HTTP 503. If the image has no curl, use PHP:
HEALTHCHECK CMD php -r 'exit(@file_get_contents("http://localhost:8080/actuator/health/liveness") === false ? 1 : 0);'Docker Compose
Section titled “Docker Compose”Start a service only when the application is ready:
services: app: build: . healthcheck: test: ["CMD", "curl", "--fail", "--silent", "http://localhost:8080/actuator/health/readiness"] interval: 10s timeout: 3s retries: 5
worker: build: . command: php artisan queue:work depends_on: app: condition: service_healthyUptime monitors
Section titled “Uptime monitors”Point external monitors, such as Oh Dear, UptimeRobot or Pingdom, at /actuator/health. Configure
them to alert on any status other than 200. To alert on one dependency only, give it a
group and monitor the group path.
Laravel’s /up route
Section titled “Laravel’s /up route”Laravel applications have a built-in /up health route. It returns 200 when the application boots
and, by default, checks no dependency. You can keep both:
/upfor the simplest liveness checks./actuator/health/readinessand/actuator/healthwhen the check must see maintenance mode or dependencies.