How do you manage MongoDB storage and capacity planning?

Instruction: Describe how you would approach managing storage and planning capacity for a MongoDB database.

Context: This question tests the candidate's ability to plan for database growth and manage storage efficiently in MongoDB, ensuring the database scales effectively with the application.

Updated

Official answer

Build a capacity model from measured document and index growth, peak read/write rates, retention and recovery requirements. Include replicas, oplog history, temporary index/migration work, logs and backups; logical data size alone is not a disk budget.

For an illustrative per-node disk model, suppose data plus indexes currently use 400 GiB, net growth is 10 GiB/day and the planning horizon is 30 days. That gives 700 GiB before temporary work. Reserving another 100 GiB and targeting at most 80% utilization requires 1000 GiB of usable capacity under these assumptions. Backup storage and other nodes must be budgeted separately.

Measure compressed on-disk size, active working set, cache pressure, IOPS, latency and recovery throughput. Compression trades CPU for storage/I/O and varies with data. Do not size memory solely from total database size or assume deleting records immediately returns all allocated disk space.

Forecast normal and peak scenarios, define expansion lead times and alert before headroom is exhausted. Validate indexes and retention policies, test restores, and measure sharding skew before choosing a geographical key. Review the model after workload or schema changes instead of treating a forecast as a guarantee.

MongoDB WiredTiger, storage statistics

Related Questions