Start by calculating the number of connections that the RAM can accommodate by following these steps:
- Begin the estimate with 8 MB used per connection.
- Add four times the value of the work_mem PostgreSQL configuration setting in megabytes, for a per-client total.
- Obtain the amount of RAM in megabytes.
- Divide half of the RAM size by the per-client MB total.
Next, calculate the number of connections the CPU and disk resources can support by following these steps:
- Obtain the CPU count in cores, including virtual if present.
- Double the CPU core count.
- Add the number of disk spindles.
Use the lower of the two values as the final ideal connection count.