Will MongoDB utilize all my 4 CPUs?

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