Skip to content

Active Health Checks #2155

Description

@moveson

Problem

When app2 was added to the load balancer today, it failed to boot due to the
database firewall not having its IP whitelisted. Puma was running and holding
port 9000 but not accepting connections, causing Caddy on app2 to return 502
for every request.

Caddy's passive health checks failed to remove app2 from rotation because:

  1. The 502 responses were being served by Caddy on app2 itself, not the
    upstream, so the load balancer saw them as successful responses
  2. The passive check required 10 failures within 10 seconds before marking
    a backend unhealthy

This caused significant downtime for opensplittime.org.

Solution

  1. Add a /up health check route to Rails using the built-in health controller:

    In config/routes.rb:

get"up"=>"rails/health#show",as: :rails_health_check

This checks the database connection and returns 503 if it is unavailable.

  1. Add active health checks to the Caddy load balancer config on elbee so it
    probes each backend every 10 seconds independently of real user traffic:
"health_checks": {
"active": {
"path": "/up",
"interval": 10000000000,
"timeout": 5000000000
},
"passive": {
"fail_duration": 10000000000,
"max_fails": 3
}
}

Note: Caddy config on elbee is managed via its API, so this would need to
be applied via the Hatchbox "Update Caddy" mechanism or persisted through
Hatchbox's config system.

Checklist

  • Add /up route to config/routes.rb
  • Verify /up returns 200 in production
  • Configure active health checks in Caddy on elbee
  • Add DigitalOcean database firewall IP whitelisting to the new server
    checklist

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions