Currently, Phabricator opens a new connection per logical database. We could open fewer; T11044 is the pathway forward for that.
These connections survive for only a single request -- we don't use the "persistent connection" options available to us. Normally this is fine, but in high load cases this can result in high connection turnover and exhaustion of outbound ports since they're consumed for 60 seconds after closing (see previous discussion in T11458).
Fixing this may be as simple as using persistent connections. However, we first need to make sure that the semantics on persistent connections don't deviate from the semantics we expect. In particular, the same request should never get the same connection twice. Although it's likely that these are already the semantics, we should verify that things actually work like this.