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
12 lines
286 B
Ruby
12 lines
286 B
Ruby
require 'rails_helper'
|
|
|
|
RSpec.describe 'Health Check', type: :request do
|
|
describe 'GET /health' do
|
|
it 'returns success status' do
|
|
get '/health'
|
|
expect(response).to have_http_status(:success)
|
|
expect(response.parsed_body['status']).to eq('woot')
|
|
end
|
|
end
|
|
end
|