noobaa / noobaa-core

High-performance S3 application gateway to any backend - file / s3-compatible / multi-clouds / caching / replication ...
https://www.noobaa.io
Apache License 2.0
273 stars 80 forks source link

Add a separate clients pool for md_store queries #8508

Open dannyzaken opened 2 weeks ago

dannyzaken commented 2 weeks ago

Explain the changes

This PR aims to prevent the unavailability of Postgres clients in the client pool for system queries when there is a high load of md_store queries.

The Problem

  1. In postgres_client.js, we access the DB through a single client pool. By default, this pool's max size is 10, and the endpoints' max size is 80.
  2. In systems with a high load and many objects, the number of md_store queries and the time it takes to perform them cause the pool to reach its maximum. As a result, non-md queries are also stuck in the waiting queue, and the entire system may become unresponsive.

The Solution

  1. Maintain two separate pools in postgres_client.js, a default pool and a dedicated md_store pool
  2. If the md_store pool is overused, the default pool is left to handle all other, typically short queries, so the default pool should remain relatively available.