feat: DB pool saturation as autoscale signal (#712) - #798
Open
jaymoneymanxl wants to merge 1 commit into
Open
Conversation
Export db.pool.waiters and db.pool.utilization gauges on every auth-gated /metrics scrape so HPA can scale on pool contention rather than CPU alone. Gauges stay defined when the pool is idle. Includes HPA guidance and Prometheus alert examples.
|
@jaymoneymanxl Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
Author
|
@thlpkee20-wq done closes #712 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
This PR exports DB pool saturation gauges (
db.pool.waiters,db.pool.utilization) on every auth-gated/metricsscrape so horizontal autoscaling can react to connection-pool contention — not just CPU.Related Issue
Closes #712
Changes
📈 Pool saturation autoscale signal
src/lib/metrics.tsupdatePoolSaturationMetrics()which always publishes both gauges (including when the pool is idle →0).src/middleware/metricsMiddleware.tscreatePrometheusHandler(metrics, pool)refreshes pool gauges on every scrape before export.src/app.ts— wires the primary pool into/metrics(still behind scrape auth).src/db/pool.ts— documents the autoscale metrics contract.docs/autoscale-db-pool-signal.md— HPA guidance, suggested thresholds, Prometheus alert examples.Verification Results
db.pool.waitersdb.pool.utilization0/metricsbehindMETRICS_TOKENmiddlewareTimeline