Will MongoDB utilize all my 4 CPUs?

my cloudInstance has 4cpu’s 8gb ram.
iam running mongodb4.2 community version in it.
will mongodb make use of all cores in my 4cpu’s or wiill it utilize 1 cpu only?

Yep.

The WiredTiger storage engine is multithreaded and can take advantage of additional CPU cores. Specifically, the total number of active threads (i.e. concurrent operations) relative to the number of available CPUs can impact performance

1 Like

Thank you for the detail.

i would like to clarify my understanding/.

Lets assume there are 4CPU’s and 8 requests coming in. Then wiredTiger would split these 8 requests into all the 4CPU’s and then serve it? is my understanding correct?
i’m looking forward for your response.
if you think some articles can help me with more detail, please share it

Hi,

WiredTiger is a storage engine, so deals with requests at a lower layer (reading data to/from storage) rather than at the networking level. The core MongoDB server is responsible for handling incoming client requests and coordinating with the storage engine API.

The MongoDB server currently uses a thread per connection plus a number of internal threads. You can list all threads (including idle and system) using db.currentOp(true) in the mongo shell.

If you have 8 incoming requests, each of those will be handled by a separate connection thread. Your O/S will manage concurrent execution (distributing threads across available CPU cores). Individual operations (for example, a query or index build) will generally run on a single thread. Internal operations such as syncing changes to disk may take advantage of parallel threads if appropriate.

In general, multithreading enables higher concurrency for multiple operations on a deployment rather than enabling a single operation to dominate all available resources. Long running read and write operations will also yield to allow other operations to interleave.

For more information on concurrency in MongoDB, see FAQ: Concurrency.

Regards,
Stennie

3 Likes

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.