feat: add lightweight /health endpoint (#13386)

The existing /api health check endpoint creates a new Redis connection
on every request and checks both Redis and Postgres availability. During
peak traffic, this creates unnecessary load and can cause cascading
failures when either service is slow - instances get marked unhealthy,
traffic shifts to remaining instances, which then also fail health
checks.

The new /health endpoint:
  - Returns immediately with 200 {"status":"woot"}
  - Skips all middleware and authentication
  - No Redis or Postgres dependency
- Suitable for health checks that only need to verify the web server is
responding
This commit is contained in:
Vishnu Narayanan
2026-01-29 00:24:01 +05:30
committed by GitHub
parent 6cd1b37981
commit 0ca98bc84f
4 changed files with 25 additions and 0 deletions

View File

@@ -47,6 +47,12 @@ class Rack::Attack
Rack::Attack.safelist('trusted IPs', &:allowed_ip?)
# Safelist health check endpoint so it never touches Redis for throttle tracking.
# This keeps /health fully dependency-free for ALB liveness checks.
Rack::Attack.safelist('health check') do |req|
req.path == '/health'
end
### Throttle Spammy Clients ###
# If any single client IP is making tons of requests, then they're

View File

@@ -35,6 +35,7 @@ Rails.application.routes.draw do
resource :slack_uploads, only: [:show]
end
get '/health', to: 'health#show'
get '/api', to: 'api#index'
namespace :api, defaults: { format: 'json' } do
namespace :v1 do