After I deleted a large amount of redundant data in mongo, I found that the memory and files did not shrink and still occupied a large amount of memory and hard disk, with little performance change. How did mongodb defragment?
What version of MongoDB, what engine?
More than 3.2 WT engines can be usedCompactTo free up space, previous versions, whether WT or MMAPv1, could only free up space by resynchronizing replication sets.
The problem is that the production environment generally does not need to be released, because it will occupy back sooner or later, and free space will be reused anyway. If there is not a real lack of space, don’t release it.
As for the problem of downtime, it is not only this problem, most of the time should consider replication set to solve, multiple nodes running in parallel is to prepare for downtime, take off one down for maintenance will not have much problem, take the main node may not be written for a few seconds.
Theoretically, reclaiming disk space will not have any beneficial effect on performance. However, a bug occurred on the WiredTiger engine used in 3.0.6 and 3.0.7. BTree will have an incorrect balance when deleting a large number of documents, resulting in serious performance degradation. Please refer to JIRA Ticket for details.SERVER-21063.