#1 Global Leader in Data Resilience

PostgreSQL and PgBouncer Sizing and Configuration Guide

KB ID: 4758
Product: Veeam Backup for Microsoft 365 | 8.1 | 8.2
Published: 2025-08-19
Last Modified: 2025-12-03
mailbox
Get weekly article updates
By subscribing, you are agreeing to have your personal information managed in accordance with the terms of Veeam's Privacy Notice.

Cheers for trusting us with the spot in your mailbox!

Now you’re less likely to miss what’s been brewing in our knowledge base with this weekly digest

error icon

Oops! Something went wrong.

Please, try again later.

Challenge

Jobs or tasks in Veeam Backup for Microsoft 365 fail with the error:

Error: [EFCoreLogging]: An error occurred using the connection to database 'cache_2331ace3-eff1-4ebb-b328-0cb948b2f5c5' on server 'tcp://vb365.domain.tld:6432'. 

Cause

These connection errors can occur in larger environments when many proxies and repositories attempt to communicate with their respective cache databases concurrently. The cumulative concurrent connections can overwhelm the PostgreSQL instance.

Solution

Based on extensive testing, Veeam's RND team has found that using PgBouncer in larger environments (as detailed in the table below) to pool connections can improve communication efficiency and resolve related errors.

Please follow the steps in KB4728: How to Install and Configure PgBouncer for Veeam Backup for Microsoft 365, and refer to the table below for configuration recommendations based on environment size.

Note: Each row can be expanded to reveal a SQL query that should be executed on the PostgreSQL instance to optimize its configuration.

Follow the recommendation that corresponds to the higher value between proxy count and repository count. For instance, if an environment has 15 Proxies and 260 Repositories, or 30 Proxies and 100 Repositories, select the option for "25 to 100" proxies and "greater than 250" repositories.
  Proxies per VB365 Server Repositories per VB365 Server PostgreSQL Deployment Location PostgreSQL Minimum
Resources
PgBouncer Recommendation
  1 to 10 less than 100 PostgreSQL on VB365 Server 8 vCPU | 32 GB PgBouncer should not be deployed
  Query to Set Recommended PostgreSQL Configuration Values Adjusted PgBouncer Values
 
ALTER SYSTEM SET max_connections = '1000';
ALTER SYSTEM SET checkpoint_timeout = '1200';
ALTER SYSTEM SET effective_cache_size = '12GB';
ALTER SYSTEM SET checkpoint_completion_target = '0.9';
ALTER SYSTEM SET wal_buffers = '16MB';
ALTER SYSTEM SET wal_level = 'minimal';
ALTER SYSTEM SET max_wal_senders = '0';
ALTER SYSTEM SET default_statistics_target = '100';
ALTER SYSTEM SET random_page_cost = '1.1';
ALTER SYSTEM SET max_worker_processes = '6';
ALTER SYSTEM SET max_parallel_workers_per_gather = '2';
ALTER SYSTEM SET max_parallel_workers = '4';
ALTER SYSTEM SET max_parallel_maintenance_workers = '2';
ALTER SYSTEM SET min_wal_size = '2GB';
ALTER SYSTEM SET max_wal_size = '8GB';
ALTER SYSTEM SET default_toast_compression = 'lz4';
ALTER SYSTEM SET wal_compression = 'lz4';
ALTER SYSTEM SET max_locks_per_transaction = '128';
ALTER SYSTEM SET hash_mem_multiplier = '2';
ALTER SYSTEM SET log_temp_files = '10MB';
ALTER SYSTEM SET log_lock_waits = 'on';
ALTER SYSTEM SET join_collapse_limit = '10';
ALTER SYSTEM SET geqo_threshold = '10';
ALTER SYSTEM SET log_line_prefix = '%m [%p] %q[user=%u,db=%d,app=%a] ';
ALTER SYSTEM SET jit = 'off';
ALTER SYSTEM SET log_autovacuum_min_duration = '1min';
ALTER SYSTEM SET log_min_duration_sample = '1s';
ALTER SYSTEM SET log_statement_sample_rate = '0.01';
ALTER SYSTEM SET log_filename = 'postgresql-%d-%H%M.log';
ALTER SYSTEM SET log_rotation_age = '4h';
ALTER SYSTEM SET log_rotation_size = '0';
ALTER SYSTEM SET log_truncate_on_rotation = 'on';
ALTER SYSTEM SET log_parameter_max_length = '10kB';
ALTER SYSTEM SET shared_buffers = '4GB';
ALTER SYSTEM SET maintenance_work_mem = '500MB';
ALTER SYSTEM SET work_mem = '8MB';
ALTER SYSTEM SET autovacuum_vacuum_cost_limit = '2000';
ALTER SYSTEM SET autovacuum_max_workers = '4';
ALTER SYSTEM SET huge_pages = 'off';

Not applicable as pgBouncer is not required.

  10 to 25 less than 250 Dedicated PostgreSQL Server 8 vCPU | 32 GB PgBouncer is required
  Query to Set Recommended PostgreSQL Configuration Values Adjusted PgBouncer Values
 
ALTER SYSTEM SET max_connections = '2000';
ALTER SYSTEM SET checkpoint_timeout = '1200';
ALTER SYSTEM SET effective_cache_size = '24GB';
ALTER SYSTEM SET checkpoint_completion_target = '0.9';
ALTER SYSTEM SET wal_buffers = '16MB';
ALTER SYSTEM SET wal_level = 'minimal';
ALTER SYSTEM SET max_wal_senders = '0';
ALTER SYSTEM SET default_statistics_target = '100';
ALTER SYSTEM SET random_page_cost = '1.1';
ALTER SYSTEM SET max_worker_processes = '6';
ALTER SYSTEM SET max_parallel_workers_per_gather = '2';
ALTER SYSTEM SET max_parallel_workers = '4';
ALTER SYSTEM SET max_parallel_maintenance_workers = '2';
ALTER SYSTEM SET min_wal_size = '2GB';
ALTER SYSTEM SET max_wal_size = '8GB';
ALTER SYSTEM SET default_toast_compression = 'lz4';
ALTER SYSTEM SET wal_compression = 'lz4';
ALTER SYSTEM SET max_locks_per_transaction = '128';
ALTER SYSTEM SET hash_mem_multiplier = '2';
ALTER SYSTEM SET log_temp_files = '10MB';
ALTER SYSTEM SET log_lock_waits = 'on';
ALTER SYSTEM SET join_collapse_limit = '10';
ALTER SYSTEM SET geqo_threshold = '10';
ALTER SYSTEM SET log_line_prefix = '%m [%p] %q[user=%u,db=%d,app=%a] ';
ALTER SYSTEM SET jit = 'off';
ALTER SYSTEM SET log_autovacuum_min_duration = '1min';
ALTER SYSTEM SET log_min_duration_sample = '1s';
ALTER SYSTEM SET log_statement_sample_rate = '0.01';
ALTER SYSTEM SET log_filename = 'postgresql-%d-%H%M.log';
ALTER SYSTEM SET log_rotation_age = '4h';
ALTER SYSTEM SET log_rotation_size = '0';
ALTER SYSTEM SET log_truncate_on_rotation = 'on';
ALTER SYSTEM SET log_parameter_max_length = '10kB';
ALTER SYSTEM SET shared_buffers = '8GB';
ALTER SYSTEM SET maintenance_work_mem = '500MB';
ALTER SYSTEM SET work_mem = '8MB';
ALTER SYSTEM SET autovacuum_vacuum_cost_limit = '2000';
ALTER SYSTEM SET autovacuum_max_workers = '10';
ALTER SYSTEM SET huge_pages = 'try';

When using Proxy Pools:

Set the following values in pgbouncer.ini:

default_pool_size = 100
max_user_connections = 1800
  25 to 100 greater than 250 Dedicated PostgreSQL Server 16 vCPU | 64 GB PgBouncer is required
  Query to Set Recommended PostgreSQL Configuration Values Adjusted PgBouncer Values
 
ALTER SYSTEM SET max_connections = '2200';
ALTER SYSTEM SET checkpoint_timeout = '1200';
ALTER SYSTEM SET effective_cache_size = '48GB';
ALTER SYSTEM SET checkpoint_completion_target = '0.9';
ALTER SYSTEM SET wal_buffers = '16MB';
ALTER SYSTEM SET wal_level = 'minimal';
ALTER SYSTEM SET max_wal_senders = '0';
ALTER SYSTEM SET default_statistics_target = '100';
ALTER SYSTEM SET random_page_cost = '1.1';
ALTER SYSTEM SET max_worker_processes = '16';
ALTER SYSTEM SET max_parallel_workers_per_gather = '2';
ALTER SYSTEM SET max_parallel_workers = '12';
ALTER SYSTEM SET max_parallel_maintenance_workers = '2';
ALTER SYSTEM SET min_wal_size = '2GB';
ALTER SYSTEM SET max_wal_size = '8GB';
ALTER SYSTEM SET default_toast_compression = 'lz4';
ALTER SYSTEM SET wal_compression = 'lz4';
ALTER SYSTEM SET max_locks_per_transaction = '128';
ALTER SYSTEM SET hash_mem_multiplier = '2';
ALTER SYSTEM SET log_temp_files = '10MB';
ALTER SYSTEM SET log_lock_waits = 'on';
ALTER SYSTEM SET join_collapse_limit = '10';
ALTER SYSTEM SET geqo_threshold = '10';
ALTER SYSTEM SET log_line_prefix = '%m [%p] %q[user=%u,db=%d,app=%a] ';
ALTER SYSTEM SET jit = 'off';
ALTER SYSTEM SET log_autovacuum_min_duration = '1min';
ALTER SYSTEM SET log_min_duration_sample = '1s';
ALTER SYSTEM SET log_statement_sample_rate = '0.01';
ALTER SYSTEM SET log_filename = 'postgresql-%d-%H%M.log';
ALTER SYSTEM SET log_rotation_age = '4h';
ALTER SYSTEM SET log_rotation_size = '0';
ALTER SYSTEM SET log_truncate_on_rotation = 'on';
ALTER SYSTEM SET log_parameter_max_length = '10kB';
ALTER SYSTEM SET shared_buffers = '16GB';
ALTER SYSTEM SET maintenance_work_mem = '500MB';
ALTER SYSTEM SET work_mem = '16MB';
ALTER SYSTEM SET autovacuum_vacuum_cost_limit = '2000';
ALTER SYSTEM SET autovacuum_max_workers = '20';
ALTER SYSTEM SET huge_pages = 'try';

When using Proxy Pools:

Set the following values in pgbouncer.ini:

default_pool_size = 100
max_user_connections = 1800
Swipe to show more of the table

If this KB article did not resolve your issue or you need further assistance with Veeam software, please create a Veeam Support Case.

To submit feedback regarding this article, please click this link: Send Article Feedback
To report a typo on this page, highlight the typo with your mouse and press CTRL + Enter.

Spelling error in text

Thank you!

Thank you!

Your feedback has been received and will be reviewed.

Oops! Something went wrong.

Please, try again later.

You have selected too large block!

Please try select less.

KB Feedback/Suggestion

This form is only for KB Feedback/Suggestions, if you need help with the software open a support case

By submitting, you are agreeing to have your personal information managed in accordance with the terms of Veeam's Privacy Notice.
Verify your email to continue your product download
We've sent a verification code to:
  • Incorrect verification code. Please try again.
An email with a verification code was just sent to
Didn't receive the code? Click to resend in sec
Didn't receive the code? Click to resend
Thank you!

Thank you!

Your feedback has been received and will be reviewed.

error icon

Oops! Something went wrong.

Please, try again later.