0

I am trying to understand the difference between 2 configurable parameters while creating a connection pool using r2dbc-pool.

I was able to configure the connection pool with the help of the below post: Connection pool size with postgres r2dbc-pool

But wanted to understand the difference while configuring max size and initial size while creating

ConnectionFactory connectionFactory = ConnectionFactories.get(ConnectionFactoryOptions.builder() .option(DRIVER, "pool") .option(PROTOCOL, "postgresql") .option(HOST, host) .option(USER, user) .option(PASSWORD, password) .option(MAX_SIZE, 30) .option(INITIAL_SIZE, 10) .option(DATABASE, database) .build());

ConnectionPoolConfiguration configuration = ConnectionPoolConfiguration.builder(connectionFactory) .maxIdleTime(Duration.ofMinutes(30)) .initialSize(initialSize) .maxSize(maxSize) .initialSize(20) .maxCreateConnectionTime(Duration.ofSeconds(1)) .build();

4

1 回答 1

0

真的没有区别,这些只是创建连接池的不同方式。

初始大小是应用程序启动后打开的数据库连接数。

您可以使用以下查询进行检查:

select * from pg_stat_activity;

您将看到您指定为初始大小的确切数字。

最大大小是可以同时打开的最大连接数(您不能直接控制它,底层池实现将缩放打开的连接数以更高的负载)

于 2020-06-20T09:21:59.250 回答