-
Notifications
You must be signed in to change notification settings - Fork 51
DOCSP-31596: improve slow operation faq #728
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -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,25 +267,40 @@ 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 | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Issue: I think "cache" is more of a memory storage/lookup paradigm and is dissimilar from the functionality of a pool, which needs to manage the usage lifecycle of the resources. A cache manages storage and memory allocation. Suggestion:
Suggested change
|
||||||
connections that the driver maintains at any time. By increasing the | ||||||
maximum connection pool size, you can reduce application latency. | ||||||
ccho-mongodb marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
|
||||||
To control the maximum size of a connection pool, you can set the | ||||||
``maxPoolSize`` option in the :ref:`connection options | ||||||
<node-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``. | ||||||
until a connection becomes available. The following code sets | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Question: Whatever the answer is, could this relationship be clarified in the introductory paragraph? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. changed one of the sentences to reference both possible solutions. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Per my response below, just removing the second strategy |
||||||
``maxPoolSize`` to ``150`` when creating a new ``MongoClient``: | ||||||
|
||||||
.. code-block:: js | ||||||
|
||||||
const client = new MongoClient(uri, { maxPoolSize: 150 }); | ||||||
|
||||||
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. | ||||||
You can also limit application latency by specifying the amount of time | ||||||
(in milliseconds) that requests wait for socket availability. The driver | ||||||
ccho-mongodb marked this conversation as resolved.
Show resolved
Hide resolved
ccho-mongodb marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
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 | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Question: I think it would be helpful to the reader to explain or link to this info since it may not be an appropriate solution depending on their use case. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the original wording here was vague when referencing "long-running" operations. Maybe the original intention was to say that having a lot of operations waiting in the queue can also cause latency? I think it could be useful just to strike this section from this entry. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @ccho-mongodb this is the response I left for why I removed the section on |
||||||
complete every operation. The following code sets ``waitQueueTimeoutMS`` | ||||||
to ``100`` when creating a new ``MongoClient``: | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Suggestion: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not applicable as I removed the section There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Question: was this section intentionally removed? If so, what were the reasons for removing it? |
||||||
|
||||||
.. code-block:: js | ||||||
|
||||||
const client = new MongoClient(uri, { waitQueueTimeoutMS: 100 }); | ||||||
|
||||||
.. tip:: | ||||||
|
||||||
To learn more about connection pooling, see :ref:`How Does Connection | ||||||
Pooling Work in the Node Driver? <node-faq-connection-pool>`. | ||||||
To learn more about connection pooling, see the :ref:`How Does Connection | ||||||
Pooling Work in the Node Driver? <node-faq-connection-pool>` entry on | ||||||
this page. | ||||||
ccho-mongodb marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
|
||||||
How Can I Ensure My Connection String Is Valid for a Replica Set? | ||||||
----------------------------------------------------------------- | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion:
I think this "preventative" FAQ entry is trickier than others to answer, and maybe the prior entry can benefit from this suggestion too, since it is also a "preventative" one.
Perhaps a better structure for presenting this information could be: