Skip to content

Commit a397a80

Browse files
author
mariascharin
committed
Editorial changes
1 parent 619bb42 commit a397a80

File tree

2 files changed

+52
-29
lines changed

2 files changed

+52
-29
lines changed

src/main/asciidoc/client-applications.adoc

+52-28
Original file line numberDiff line numberDiff line change
@@ -366,18 +366,38 @@ include::{python-examples}/config_trust_example.py[tags=config-trust]
366366
[[driver-config-connection-pool-management]]
367367
=== Connection pool management
368368

369-
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.
371400

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.
381401

382402
[.tabbed-example]
383403
.Connection pool management
@@ -416,85 +436,89 @@ include::{python-examples}/config_connection_pool_example.py[tags=config-connect
416436
====
417437

418438

419-
[[driver-load-balancing-strategy]]
420-
=== Load balancing strategy
421-
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.
443+
For example:
422444

423445
[.tabbed-example]
424-
.Load balancing strategy
446+
.Connection timeout
425447
====
426448
[.include-with-dotnet]
427449
======
428450
[source, csharp]
429451
----
430-
include::{dotnet-examples}/Examples.cs[tags=config-load-balancing-strategy]
452+
include::{dotnet-examples}/Examples.cs[tags=config-connection-timeout]
431453
----
432454
======
433455
434456
[.include-with-java]
435457
======
436458
[source, java]
437459
----
438-
include::{java-examples}/ConfigLoadBalancingStrategyExample.java[tags=config-load-balancing-strategy]
460+
include::{java-examples}/ConfigConnectionTimeoutExample.java[tags=config-connection-timeout]
439461
----
440462
======
441463
442464
[.include-with-javascript]
443465
======
444466
[source, javascript]
445467
----
446-
include::{javascript-examples}/examples.test.js[tags=config-load-balancing-strategy]
468+
This feature is not available in the Javascript driver.
447469
----
448470
======
449471
450472
[.include-with-python]
451473
======
452474
[source, python]
453475
----
454-
include::{python-examples}/config_load_balancing_strategy_example.py[tags=config-load-balancing-strategy]
476+
include::{python-examples}/config_connection_timeout_example.py[tags=config-connection-timeout]
455477
----
456478
======
457479
====
458480

459481

460-
[[driver-configuration-connection-timeout]]
461-
=== Connection timeout
482+
[[driver-load-balancing-strategy]]
483+
=== Load balancing strategy
462484

463-
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.
488+
Default value: `least-connected`.
465489

466490
[.tabbed-example]
467-
.Connection timeout
491+
.Load balancing strategy
468492
====
469493
[.include-with-dotnet]
470494
======
471495
[source, csharp]
472496
----
473-
include::{dotnet-examples}/Examples.cs[tags=config-connection-timeout]
497+
include::{dotnet-examples}/Examples.cs[tags=config-load-balancing-strategy]
474498
----
475499
======
476500
477501
[.include-with-java]
478502
======
479503
[source, java]
480504
----
481-
include::{java-examples}/ConfigConnectionTimeoutExample.java[tags=config-connection-timeout]
505+
include::{java-examples}/ConfigLoadBalancingStrategyExample.java[tags=config-load-balancing-strategy]
482506
----
483507
======
484508
485509
[.include-with-javascript]
486510
======
487511
[source, javascript]
488512
----
489-
This feature is not available in the Javascript driver.
513+
include::{javascript-examples}/examples.test.js[tags=config-load-balancing-strategy]
490514
----
491515
======
492516
493517
[.include-with-python]
494518
======
495519
[source, python]
496520
----
497-
include::{python-examples}/config_connection_timeout_example.py[tags=config-connection-timeout]
521+
include::{python-examples}/config_load_balancing_strategy_example.py[tags=config-load-balancing-strategy]
498522
----
499523
======
500524
====

src/main/asciidoc/sessions-and-transactions.adoc

-1
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,6 @@ include::{python-examples}/read_write_transaction_example.py[tags=read-write-tra
288288
======
289289
====
290290

291-
--
292291

293292
== Asynchronous programming
294293

0 commit comments

Comments
 (0)