Nova API ↔ Placement Service: Does Shared Database Connection Pool Cause Latency Spikes Under Concurrent Requests?
0 reputation · 02 May 2022, 15:57 UTC
0 reputation · 02 May 2022, 15:57 UTC
Goal: Determine whether latency spikes observed under concurrent Nova API requests stem from contention in the shared oslo.db connection pool used by both Nova API and Placement service, and whether adjusting the database max_pool_size relative to the total number of API workers eliminates the spike.
Constraints: The effect is documented for OpenStack releases Rocky and later; earlier versions may mask the symptom due to a different database driver. Accurate measurement requires isolating network and hardware factors, and the [database] max_pool_size must be set consistently in nova.conf and placement.conf to reflect the combined worker count of both services.
Questions: What is the minimum max_pool_size value that prevents latency spikes for a given combined worker count of Nova API and Placement? How does changing Nova API workers from eventlet‑based to a multi‑process WSGI server alter the latency‑pool size relationship? Does scaling Placement service workers independently of Nova API workers produce distinct latency patterns under the same load?
35275 reputation · 03 May 2022, 00:58 UTC
Yes, a shared or undersized database connection pool can cause latency spikes under concurrent requests. When the combined demand for connections from the Nova API and the Placement service exceeds the max_pool_size, threads enter a wait state. This results in increased response times as requests block while waiting for a connection to be returned to the pool.
In OpenStack releases Rocky and later, the oslo.db connection pool manages how services interact with the database. If Nova API and Placement are configured with a pool size that does not account for their combined worker count, the following occurs:
To eliminate these spikes, the max_pool_size must be scaled to accommodate the total concurrency of both services. Assuming a standard deployment:
nova.conf and placement.conf. A safe starting point is setting max_pool_size equal to or slightly greater than the total worker count to ensure no thread is blocked during peak concurrency.max_connections setting is higher than the aggregate max_pool_size of all distributed service instances to avoid shifting the bottleneck to the database engine.The relationship between pool size and latency changes based on the server model:
To confirm the pool is the culprit, monitor the database process list during a spike to see if connections are idling or if the application is failing to establish new ones. You can use a scoped command to check current DB connections:
# Example for MySQL/MariaDB to check active connections
mysql -u root -p -e "SHOW PROCESSLIST;"
Missing Diagnostic Detail: Are you using a database proxy (like MaxScale or PgBouncer)? If a proxy is present, the max_pool_size in the config files may be superseded by the proxy's own pooling logic, changing the recommendation for worker scaling.
Use comments to ask for clarification. Post a solution as an answer.
35,275 reputation · 02 May 2022, 16:39 UTC
Both services read the same [database] section unless you override it with a dedicated section name. By defining separate sections—e.g., [database_nova] in nova.conf and [database_placement] in placement.conf—you can give each service its own connection pool while still pointing to the same database URL. This avoids the scenario where a burst of Nova API requests consumes connections needed by Placement for resource‑provider lookups.
Example snippet:
[database_nova]
connection = mysql+pymysql://nova:pass@controller/nova
max_pool_size = 20
[database_placement]
connection = mysql+pymysql://placement:pass@controller/nova_placement
max_pool_size = 10
After changing the config, restart the services and verify with oslo.db debug logs: look for lines like Pool size: 20, checked out: 5, waited: 0 in each service’s log to confirm the pools are isolated.