Reputation: 41
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();
Upvotes: 0
Views: 1506
Reputation: 4936
There isn't a difference really, these are just different ways to create a connection pool.
The initial size is the number of open connections to the database once the application starts.
You can check that with the query:
select * from pg_stat_activity;
You'll see exactly the number you specified as initial size.
Max size is the maximum nuber of connections that can be open at the same time (you do not control that directly, underlying pool implementation will scale the number of opened connections with higher load)
Upvotes: 0