From 7d6024b5bd902b24cb5d4d3586b1eed344a3d315 Mon Sep 17 00:00:00 2001 From: Rea Radhika Rustagi Date: Tue, 25 Jul 2023 10:15:40 -0400 Subject: [PATCH 1/6] DOCSP-31596: imrpove slow op faq --- source/faq.txt | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/source/faq.txt b/source/faq.txt index d757f462d..c5b536015 100644 --- a/source/faq.txt +++ b/source/faq.txt @@ -190,7 +190,7 @@ will close the socket. We recommend that you select a value for ``socketTimeoutMS`` that is two to three times as long as the expected duration of the slowest operation that your application executes. -How Can I Prevent Sockets From Timing out Before They Become Active? +How Can I Prevent Sockets From Timing Out Before They Become Active? -------------------------------------------------------------------- Having a large connection pool does not always reduce reconnection @@ -267,20 +267,34 @@ are some things to check: How Can I Prevent a Slow Operation From Delaying Other Operations? ------------------------------------------------------------------ +You can prevent an operation from slowing down your application by +specifying the size of the connection pool, which is the cache of +connections that the driver maintains at any time. By increasing the +maximum connection pool size, you can reduce application latency. + To control the maximum size of a connection pool, you can set the ``maxPoolSize`` option in the :ref:`connection options `. The default value of ``maxPoolSize`` is ``100``. If the number of in-use connections to a server reaches ``maxPoolSize``, the next request to that server will wait -until a connection becomes available. To prevent long-running operations -from slowing down your application, you can increase ``maxPoolSize``. - -The driver does not limit the number of requests that can wait for -sockets to become available. Requests wait for the amount of time -specified in the ``waitQueueTimeoutMS`` option, which -defaults to ``0`` (no limit). You should set this option if it is -more important to stop long-running operations than it is to complete -every operation. +until a connection becomes available. The following code sets +``maxPoolSize`` to ``150`` when creating a new ``MongoClient``: + +.. code-block:: js + + const client = new MongoClient(uri, { maxPoolSize: 150 }); + +You can also limit application latency by specifying the amount of time +(in milliseconds) that requests wait for socket availability. The driver +does not limit this wait time by default, but to specify a value, you +can set the ``waitQueueTimeoutMS`` option. You should set this option if +it is more important to stop long-running operations than it is to +complete every operation. The following code sets ``waitQueueTimeoutMS`` +to ``100`` when creating a new ``MongoClient``: + +.. code-block:: js + + const client = new MongoClient(uri, { waitQueueTimeoutMS: 100 }); .. tip:: From 459cc87317bab3e66682eecf2d398d90368b02d9 Mon Sep 17 00:00:00 2001 From: Rea Radhika Rustagi Date: Tue, 25 Jul 2023 10:20:42 -0400 Subject: [PATCH 2/6] quick fix --- source/faq.txt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/source/faq.txt b/source/faq.txt index c5b536015..7b4223804 100644 --- a/source/faq.txt +++ b/source/faq.txt @@ -298,8 +298,9 @@ to ``100`` when creating a new ``MongoClient``: .. tip:: - To learn more about connection pooling, see :ref:`How Does Connection - Pooling Work in the Node Driver? `. + To learn more about connection pooling, see the :ref:`How Does Connection + Pooling Work in the Node Driver? ` entry on + this page. How Can I Ensure My Connection String Is Valid for a Replica Set? ----------------------------------------------------------------- From 8168f9ce9ee8777c9a6926de1c27215b5585586e Mon Sep 17 00:00:00 2001 From: Rea Radhika Rustagi Date: Thu, 27 Jul 2023 10:31:01 -0400 Subject: [PATCH 3/6] CC PR fixes 1 --- source/faq.txt | 59 ++++++++++++++++++++++++++++---------------------- 1 file changed, 33 insertions(+), 26 deletions(-) diff --git a/source/faq.txt b/source/faq.txt index 7b4223804..a3e704655 100644 --- a/source/faq.txt +++ b/source/faq.txt @@ -261,46 +261,53 @@ socket connections. If you experience unexpected network behavior, here are some things to check: -#. The firewall should send a ``FIN packet`` when closing a socket,allowing the driver to detect that the socket is closed. +#. The firewall should send a ``FIN packet`` when closing a socket, + allowing the driver to detect that the socket is closed. #. The firewall should allow ``keepAlive`` probes. How Can I Prevent a Slow Operation From Delaying Other Operations? ------------------------------------------------------------------ -You can prevent an operation from slowing down your application by -specifying the size of the connection pool, which is the cache of -connections that the driver maintains at any time. By increasing the -maximum connection pool size, you can reduce application latency. - -To control the maximum size of a connection pool, you can set the -``maxPoolSize`` option in the :ref:`connection options -`. The default value of ``maxPoolSize`` is -``100``. If the number of in-use connections to a server reaches -``maxPoolSize``, the next request to that server will wait -until a connection becomes available. The following code sets +Before you make changes to your connection configuration or application, +you should determine which operations could be causing delays. You can +investigate the performance of in-progress operations by using the +following strategies: + +- Enable the database profiler on your deployment. To learn more, see + :manual:`Database Profiler ` + in the Server manual. +- Run the ``db.currentOp()`` :manual:`shell command `. To learn more, see the + :manual:`db.currentOp() ` + documentation in the Server manual. +- Enable connection pool monitoring. To learn more, see + :ref:`node-connection-pool-monitoring`. + +Once you determine how and why your operations are delayed, if possible, +try to improve the performance of your application. Read the :website:`Best +Practices Guide for MongoDB Performance ` for +possible solutions. + +If you cannot avoid time-consuming or slow operations, you can +modify your connection settings to increase the size of the connection +pool, a group of connections to the server that the driver maintains at +any time. + +To specify the maximum size of a +connection pool, you can set the ``maxPoolSize`` option in the +:ref:`connection options `. The default value +of ``maxPoolSize`` is ``100``. If the number of in-use connections to a +server reaches ``maxPoolSize``, the next operation sent to the server +will wait until a connection becomes available. The following code sets ``maxPoolSize`` to ``150`` when creating a new ``MongoClient``: .. code-block:: js const client = new MongoClient(uri, { maxPoolSize: 150 }); -You can also limit application latency by specifying the amount of time -(in milliseconds) that requests wait for socket availability. The driver -does not limit this wait time by default, but to specify a value, you -can set the ``waitQueueTimeoutMS`` option. You should set this option if -it is more important to stop long-running operations than it is to -complete every operation. The following code sets ``waitQueueTimeoutMS`` -to ``100`` when creating a new ``MongoClient``: - -.. code-block:: js - - const client = new MongoClient(uri, { waitQueueTimeoutMS: 100 }); - .. tip:: To learn more about connection pooling, see the :ref:`How Does Connection - Pooling Work in the Node Driver? ` entry on - this page. + Pooling Work in the Node Driver? ` FAQ entry. How Can I Ensure My Connection String Is Valid for a Replica Set? ----------------------------------------------------------------- From 0f82e0315933baafaa30ff62829255d607ff58f8 Mon Sep 17 00:00:00 2001 From: Rea Radhika Rustagi Date: Thu, 3 Aug 2023 13:10:49 -0400 Subject: [PATCH 4/6] CC PR fixes 2 --- source/faq.txt | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/source/faq.txt b/source/faq.txt index a3e704655..9336bc2e6 100644 --- a/source/faq.txt +++ b/source/faq.txt @@ -268,37 +268,40 @@ are some things to check: How Can I Prevent a Slow Operation From Delaying Other Operations? ------------------------------------------------------------------ -Before you make changes to your connection configuration or application, -you should determine which operations could be causing delays. You can -investigate the performance of in-progress operations by using the -following strategies: +When you use one ``MongoClient`` to run multiple MongoDB operations +concurrently, a slow operation can cause delays to other operations. The +slow operation keeps a connection to MongoDB occupied, which can cause other +operations to wait until a connection is available. + +If you suspect that slow MongoDB operations are causing delays, you +can check the performance of in-progress operations by using the +following methods: - Enable the database profiler on your deployment. To learn more, see :manual:`Database Profiler ` in the Server manual. -- Run the ``db.currentOp()`` :manual:`shell command `. To learn more, see the +- Run the ``db.currentOp()`` MongoDB Shell command. To learn more, see the :manual:`db.currentOp() ` documentation in the Server manual. - Enable connection pool monitoring. To learn more, see :ref:`node-connection-pool-monitoring`. -Once you determine how and why your operations are delayed, if possible, -try to improve the performance of your application. Read the :website:`Best -Practices Guide for MongoDB Performance ` for -possible solutions. +After you determine which operations are causing delays, try to improve +the performance of these operations. Read the :website:`Best Practices +Guide for MongoDB Performance ` for possible solutions. -If you cannot avoid time-consuming or slow operations, you can -modify your connection settings to increase the size of the connection -pool, a group of connections to the server that the driver maintains at -any time. +If you implement performance best practices but still +experience delays, you can modify your connection settings to increase +the size of the connection pool. A connection pool is the group of +connections to the server that the driver maintains at any time. To specify the maximum size of a connection pool, you can set the ``maxPoolSize`` option in the :ref:`connection options `. The default value of ``maxPoolSize`` is ``100``. If the number of in-use connections to a server reaches ``maxPoolSize``, the next operation sent to the server -will wait until a connection becomes available. The following code sets -``maxPoolSize`` to ``150`` when creating a new ``MongoClient``: +pauses until a connection to the driver becomes available. The following +code sets ``maxPoolSize`` to ``150`` when creating a new ``MongoClient``: .. code-block:: js From d08924ede584d53bf366beeb94d5894703646b26 Mon Sep 17 00:00:00 2001 From: Rea Radhika Rustagi Date: Thu, 3 Aug 2023 13:16:04 -0400 Subject: [PATCH 5/6] small fixes --- source/faq.txt | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/source/faq.txt b/source/faq.txt index 9336bc2e6..cbaef5787 100644 --- a/source/faq.txt +++ b/source/faq.txt @@ -268,13 +268,14 @@ are some things to check: How Can I Prevent a Slow Operation From Delaying Other Operations? ------------------------------------------------------------------ -When you use one ``MongoClient`` to run multiple MongoDB operations -concurrently, a slow operation can cause delays to other operations. The -slow operation keeps a connection to MongoDB occupied, which can cause other -operations to wait until a connection is available. +When you use the same ``MongoClient`` instance to run multiple MongoDB +operations concurrently, a slow operation can cause delays to other +operations. The slow operation keeps a connection to MongoDB occupied, +which can cause other operations to wait until an additional connection +becomes available. If you suspect that slow MongoDB operations are causing delays, you -can check the performance of in-progress operations by using the +can check the performance of all in-progress operations by using the following methods: - Enable the database profiler on your deployment. To learn more, see @@ -297,7 +298,8 @@ connections to the server that the driver maintains at any time. To specify the maximum size of a connection pool, you can set the ``maxPoolSize`` option in the -:ref:`connection options `. The default value +:ref:`connection options ` for your +``MongoClient`` instance. The default value of ``maxPoolSize`` is ``100``. If the number of in-use connections to a server reaches ``maxPoolSize``, the next operation sent to the server pauses until a connection to the driver becomes available. The following From 3b51cd82fcbffae68bbd99abb8c6136f2bcb5919 Mon Sep 17 00:00:00 2001 From: Rea Radhika Rustagi Date: Fri, 4 Aug 2023 09:55:59 -0400 Subject: [PATCH 6/6] final suggestion --- source/faq.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/faq.txt b/source/faq.txt index cbaef5787..f9af87092 100644 --- a/source/faq.txt +++ b/source/faq.txt @@ -270,7 +270,7 @@ How Can I Prevent a Slow Operation From Delaying Other Operations? When you use the same ``MongoClient`` instance to run multiple MongoDB operations concurrently, a slow operation can cause delays to other -operations. The slow operation keeps a connection to MongoDB occupied, +operations. Slow operations keep a connection to MongoDB occupied, which can cause other operations to wait until an additional connection becomes available.