После развертывания в Kubernetes p95 запросов к PostgreSQL вырос с 40 до 900 мс, хотя CPU базы не перегружен. Откат релиза затронет важные исправленные сценарии: что проверишь первым и почему?
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.
Also asked at ylab
- Could you tell me about your overall role in this project? Were you fully responsible for it, or were you responsible for a specific part?
- Could you tell about a situation where you made a mistake at work?
- How can you find and analyze slow queries in PostgreSQL?
- 20. Valid Parentheses Given a string s containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid. An input string is valid if: 1. Open brackets must be closed by the same type of brackets. 2. Open brackets must be closed in the correct order. 3. Every close bracket has a corresponding open bracket of the same type. Example 1: Input: s = "()" Output: true Example 2: Input: s = "()[]{}" Output: true Example 3: Input: s = "(]" Output: false
Similar questions
- You’ve deployed a release. The service hasn’t gone down, but its response time has risen sharply (from 200 ms to 2 s). What would you do, and where would you look first?
- How would you organize load testing for the designed service: what baseline scenarios, signs of degradation, and Kubernetes container metrics should be monitored?
- A web service endpoint has started responding slowly. What steps would you take to identify and resolve the problem?
- Из чего состоит Pod в Kubernetes?
- Why might PostgreSQL be a poor choice for this task? And if you had to implement it in Postgres with billions of records, how would you organize the tables and partition the data?