MongoDB provides several mechanisms to optimize performance, scaling, and reliability. As you are contemplating your database design, you should consider each of the following options:
Indexing: Indexes improve performance for frequent queries by building a lookup index that can be easily sorted. The _id
property of a collection is automatically indexed on since it is a common practice to look items up by ID. However, you also need to consider what other ways users access data before you implement indexes that will enhance those lookup methods as well.
Sharding: Sharding is the process of slicing up large collections of data that can be split between multiple MongoDB servers in a cluster. Each MongoDB server is considered a shard. This provides the benefit of utilizing multiple servers to support a large number of requests to a large system. It thus provides horizontal scaling to your database. You should look at the size of your data and the number of requests that will be accessing it to determine whether and how much to shard your collections.
Replications: Replication is the process of duplicating data on multiple MongoDB instances in a cluster. When considering the reliability aspect of a database, you should implement replication to ensure that a backup copy of data that is critical is always readily available.