How to speed up MongoDB Inserts/sec?

Writes to MongoDB currently aquire a global write lock, although collection level locking is hopefully coming soon. By using more threads you’re likely introducing more concurrency problems as the threads block eachother while they wait for the lock to be released.

Indexes will also slow you down, to get the best insert performance it’s ideal to add them after you’ve loaded your data, however this isn’t always possible, for example if you’re using a unique index.

To really maximise write performance, your best bet is sharding. This’ll give you a much better concurrency and higher disk I/O capacity as you distribute writes across several machines.

Leave a Comment

tech