Limit the number of parallel mongodump workers based on CPU count #77
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
On hosts with many shards there can be some significant CPU contention and high load average when using mongodump 3.2.0+, which defaults to using 4 x dump workers per instance of mongodump.
For example on a system with 4 x CPUs and 4 x shards requiring backup this will create 16 x mongodump threads (4 shards x 4 collection dump threads), and the threads start to starve and fight for resources, especially considering gzip is involved in 3.2+. This contention seems to be limiting performance of the backup and causing the system to be very slow.
This PR moves to:
There is a new log message to specify how many dump threads are used here ('0' = no threading used):
[2017-01-14 18:25:44,467] [INFO] [MainProcess] [Dumper:run:103] Starting backups using mongodump 3.2.11 (inline gzip: True, threads per dump: 2)
Tested on 2.6.x and 3.2.x.