Sandip Subedi
Sandip Subedi

Reputation: 1077

Should I use different databases or just different collections in MongoDB to store user information and rest of the database?

I am pretty new to MongoDB. I am creating an application where I will have users and a lot of other data.I have already created a database where I am storing user information using MongoDB. Now I have to create a new database or collection to store rest of the data. What are the pros and cons of creating different or different collection ?

Upvotes: 1

Views: 1272

Answers (1)

andresk
andresk

Reputation: 2845

I use MongoDB in a very similar way and have already thought a lot about dividing my database. Here are some of the things we considered:

  • Using 2 databases is harder to maintain, your application will have to know which database to update, also it can increase the costs (even more if you intend to monitor the databases and host on different infrastructure).

  • Mongo 2 used to lock the entire database when updating, so I think it would be better to separate then, but Mongo 3 with WiredTiger locks only the document, so you won't have the problems we used to have in the past.

  • One good thing about splitting the database in two is that even if your data explodes one database, the other will still work

IMHO, if you use a decent machine to store your databases and monitor it the right way, you won't have any troubles keeping just one until your system is giant with millions of active users. You can also use Replica Sets and Sharding to increase efficiency.

Upvotes: 1

Related Questions