NewWork mode: your Claude Code or Codex on work calls, answering from your project's codeSkip to content
Senior79 views

После развертывания в Kubernetes p95 запросов к PostgreSQL вырос с 40 до 900 мс, хотя CPU базы не перегружен. Откат релиза затронет важные исправленные сценарии: что проверишь первым и почему?

Practice

Asked at

AI answer

First, I’ll determine exactly where the additional 860 ms is occurring: while waiting for a connection in the application pool or during PostgreSQL’s processing. I’ll compare traces and metrics from before and after the release, then check waits and the number of connections in pg_stat_activity, as well as pool metrics: connections in use, the wait queue, and connection acquisition time.

In Kubernetes, the number of connections often grows unexpectedly: the pool limit is set per pod, so the overall maximum is the limit multiplied by the number of pods. When connections are saturated, this can cause waits in the application, locks, or database degradation even without high CPU utilization. Next, I’ll compare queries in pg_stat_statements and check the plans for the queries that slowed down the most, along with locks and long-running transactions. If the release is confirmed as the cause, I’ll first apply a safe, targeted mitigation—for example, disable the changed path with a feature flag or adjust the pool while preserving the necessary fixes; rollback will not be the first step before the cause is isolated.