You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The driver maintains a pool of connections. The pooled connections are reused by sessions and transaction to avoid overhead added by establishing new connections every time to run a query.
370
-
The connection pool always start with an empty pool. New connections are created on demand by sessions and transactions to run queries. When a sessions or a transaction has done query execution with a connection, the connection will be returned to the pool to be reused.
369
+
The driver maintains a pool of connections.
370
+
The pooled connections are reused by sessions and transactions to avoid the overhead added by establishing new connections for every query.
371
+
The connection pool always starts up empty.
372
+
New connections are created on demand by sessions and transactions.
373
+
When a session or a transaction is done with its execution, the connection will be returned to the pool to be reused.
374
+
375
+
Application users can tune connection pool settings to configure the driver for different use cases based on client performance requirements and database resource consumption limits.
376
+
377
+
Detailed descriptions of connection pool settings available via driver configuration are listed below:
378
+
379
+
`MaxConnectionLifetime`::
380
+
Pooled connections older than this threshold will be closed and removed from the pool.
381
+
Such removal happens during connection acquisition so that new session is never backed by an old connection.
382
+
Setting this option to a low value will cause a high connection churn and might result in a performance drop.
383
+
It is recommended to set driver's maximum lifetime to a value smaller than the maximum lifetime configured in its application system infrastructure (such as operation system, router, load balancer, proxy and firewall).
384
+
Negative values result in lifetime not being checked.
385
+
Default value: 1h.
386
+
387
+
`MaxConnectionPoolSize`::
388
+
This setting defines the maximum total number of connections allowed to be managed by the connection pool on each host.
389
+
In other words, for a direct driver, this sets the maximum amount of connections towards a single database.
390
+
For a routing driver this sets the maximum amount of connections towards each cluster member.
391
+
If a session or transaction tries to acquire a connection at a time when the pool size is at its full capacity, it must wait until a free connection is available in the pool or the request to acquire a new connection times out.
392
+
The connection acquiring timeout is configured via `ConnectionAcquisitionTimeout`.
393
+
Default value: This is different for different drivers, but is a number in the order of 100.
394
+
395
+
`ConnectionAcquisitionTimeout`::
396
+
This setting limits the amount of time a session or transaction can spend waiting for a free connection to appear in the pool before throwing an exception.
397
+
The exception thrown in this case is `ClientException`.
398
+
Timeout only applies when connection pool is at its max capacity.
399
+
Default value: 1m.
371
400
372
-
Application users could tune connection pool settings to fit the driver for different usecases based on client performace requirement and database resourse consumption limit.
373
-
374
-
The detailed description of the available connection pool settings via driver configuratoin are listed bellow:
375
-
376
-
* `MaxConnectionLifetime` - Default value: 1h. Pooled connections older than this threshold will be closed and removed from the pool. Such removal happens during connection acquisition so that new session is never backed by an old connection. Setting this option to a low value will cause a high connection churn and might result in a performance drop. It is recommended to set driver's maximum lifetime to a value smaller than the maximum lifetime configured in its application system infrastructure (such as operation system, router, load balancer, proxy, firewall, etc.). Negative values result in lifetime not being checked.
377
-
378
-
* `MaxConnectionPoolSize` - Default value: a large number such as 100 but vary in drivers. It defines the maximum total number of connections allowed to be managed by the connection pool per host. In other words, for direct driver this sets the max amount of connections towards a single database. While for routing driver this sets the max amount of connections towards each cluster member. When a session or transaction tries to acquire connection and pool is at its full capacity, then the session or transaction has to wait until a free connection is availble in the pool or the request to acquire a new connection times out. The connection acquiring timeout is configured via `connectionAcquisitionTimeout`.
379
-
380
-
* `ConnectionAcquisitionTimeout` - Default value: 1m. This setting limits amount of time a session or transaction can spend waiting for a free connection to appear in the pool before throwing an exception. Exception in this case is `ClientException`. Timeout only applies when connection pool is at its max capacity.
For the routing driver, the driver contains a simple load balancer to route queries evenly among many cluster members. The built-in load balancer provides two strategies: `Least-connected` (Default) and `round-robin`. The `least-connection` strategy in general gives a better performance as it takes query execution time and server load into consideration when distrbuting queries among the cluster memebers. The 1.5 drivers adopt `least-connected` as default load balancing strategy.
439
+
[[driver-configuration-connection-timeout]]
440
+
=== Connection timeout
441
+
442
+
To configure the maximum time allowed to establish a connection, pass a duration value to the driver configuration.
To configure the maximum time allowed to establish a connection, pass a duration value to the driver configuration.
464
-
For example:
485
+
A routing driver contains a load balancer to route queries evenly among many cluster members.
486
+
The built-in load balancer provides two strategies: `least-connected` and `round-robin`.
487
+
The `least-connected` strategy in general gives a better performance as it takes query execution time and server load into consideration when distributing queries among the cluster members.
0 commit comments