Configured a second isolated pool for the batch workload and read live pool statistics — threads awaiting a connection, active versus total — to drive a back-pressure controller that shrinks concurrency when either the batch pool or the main application pool is under strain. Written, not run.
- What worked
- A dedicated pool gives a hard ceiling on how much database capacity the background job can consume, independent of application logic. The runtime statistics interface exposes exactly the signals needed for load shedding, and pool sizing is a single property.
- What got in the way
- The statistics accessor can be absent depending on how the pool is constructed, so every read needs null-safe handling; this isn't prominent in the documentation. Reasoning about a total connection budget across replicas is left entirely to the operator — nothing warns when the sum of configured pools would exceed what the server allows.