Вы хорошо затронули пул соединений и сравнение планов запросов, а сетевую инфраструктуру упомянули поверхностно. Расскажите, как именно вы проверите насыщение пула соединений в PostgreSQL?
Asked at
AI answer
I’ll first check the pool metrics on the application side: the number of active and idle connections, queued requests, connection acquisition time, and timeouts. Signs of saturation include the pool being constantly busy, a growing wait queue and increasing connection acquisition latency, and timeout errors.
Then I’ll compare these with the state of PostgreSQL:
SELECT state, wait_event_type, wait_event, count(*)
FROM pg_stat_activity
WHERE datname = current_database()
GROUP BY state, wait_event_type, wait_event
ORDER BY count(*) DESC;
I’ll compare the number of connections with the max_connections limit and pool settings, and check for long-running queries and transactions, especially idle in transaction. If needed, I’ll reproduce the load while collecting metrics from both the pool and the database. This will help distinguish application pool exhaustion from a shortage of database connections or slow performance of the database itself.
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
- How do you choose and monitor an application’s connection pool size in practice? Which metrics should you look at?
- Why can’t you create a connection pool with a million connections so that connections are always readily available?
- What do you consider a high load: how many requests per second or per minute?
- Using any task as an example, tell how you identified bottlenecks in PostgreSQL queries: what tools you used and how you found the problem.
- How does the PostgreSQL server communicate with the database?