MongoDB Performance: single collection vs multiple collections

I’m utilizing a local database to sync certain data from external APIs. The local database would be used to serve the web application. The data I’m syncing is different for each user who would be visiting the web app. Since the sync job is periodically writing to the DB while users are accessing their data from the web page, I’m wondering what would give me the best performance here.

Since the sync job is continuously writing to the DB, I believe the collection is locked until it’s done. I’m thinking that having multiple collections would help here since the lock would be on a particular collection that is being written to rather than on a single collection every time.

Is my thinking correct here? I basically don’t want reads to get throttled since the write operation is continuously locking up one collection.

Welcome to the community @Anish_Sana!

WiredTiger, the default storage engine in all modern versions of MongoDB, uses document-level concurrency control. Continuously writing to a collection does not prevent reads. See: Does a read or write operation ever yield?.

There are some administrative commands that require an exclusive lock at the collection level.

For more information see FAQ: Concurrency.



Thanks, @Stennie! This is exactly what I was looking for.