Mafiree logo
  • About
  • Services
  • Blogs
  • Careers
  • Products
    • orbit logo Orbit
    • streamer logo Xstreami
  • Contact
Schedule a Call
Menu
  • About
  • Services
  • Blogs
  • Careers
  • Products
    • orbit logo Orbit
    • streamer logo Xstreami
  • Contact
  • Schedule a Call
Database
Database Managed Database Services
MySQL MySQL
MySQL Consulting
MySQL Migration Services
MySQL Optimization & Query Tuning
MySQL Database Administration
MySQL Backup & Recovery
MySQL Security & Maintenance
MySQL Cloud Services (AWS RDS, Aurora, Google Cloud SQL, Azure)
MySQL for Ecommerce
MySQL High Availability & Replication
MongoDB MongoDB
MongoDB Consulting
MongoDB Migration Services
MongoDB Optimization & Query Tuning
MongoDB Database Administration
MongoDB Backup & Recovery
MongoDB Security & Maintenance
MongoDB Cloud (Atlas)
MongoDB Solutions by Industry
MongoDB High Availability & Replication
PostgreSQL PostgreSQL
PostgreSQL Consulting
PostgreSQL Migration & Upgrades
Performance Tuning & Query Optimization
PostgreSQL Administration & Managed Services
High Availability, Clustering & Replication
PostgreSQL Backup, Recovery & Disaster Planning
PostgreSQL Security, Compliance & Auditing
PostgreSQL for Analytics & Data Warehousing
PostgreSQL on Cloud & Containers
PostgreSQL Extensions & Open-Source Integrations
PostgreSQL for Every Industry
SQL Server MSSQL
MSSQL Consulting
MSSQL Migration Services
MSSQL Optimization & Query Tuning Services
MSSQL Database Administration Services
MSSQL Backup & Recovery Services
MSSQL High Availability & Replication Services
MSSQL Security & Compliance Services
MSSQL Performance Monitoring & Health Checks
MSSQL Solutions by Industry
Aerospike Aerospike
Aerospike Consulting
Aerospike Migration Services
Aerospike Performance Optimization & Tuning
Aerospike Backup & Recovery
Aerospike High Availability
Aerospike Cloud & Hybrid Deployments
Aerospike for Real-Time Applications (AdTech, FinTech, Retail, IoT)
Clickhouse Clickhouse
ClickHouse Consulting
ClickHouse Migration Services
ClickHouse Optimization & Query Tuning
ClickHouse Database Administration
ClickHouse Backup & Recovery
ClickHouse Security & Maintenance
ClickHouse Cloud Services (ClickHouse Cloud, AWS, GCP, Azure)
ClickHouse Solutions by Industry
ClickHouse High Availability & Replication
TiDB TiDB
TiDB Consulting
TiDB Administration & Maintenance
TiDB Security and Privacy Maintenance
TiDB Performance & Query Optimization
TiDB Migration Services
TiDB Backup & Disaster Recovery
TiDB High Availability Solutions
TiDB Solutions by Industry
TiDB Cloud Services
ScyllaDB ScyllaDB
ScyllaDB Consulting
ScyllaDB Administration & Maintenance
ScyllaDB Security and Privacy Maintenance
ScyllaDB Performance & Query Optimization
ScyllaDB Migration Services
ScyllaDB Backup & Disaster Recovery
ScyllaDB High Availability Solutions
ScyllaDB Solutions by Industry
ScyllaDB Cloud Services
DevOps
DevOps DevOps Services
Version Control Version Control
Kubernetes Kubernetes
Infrastructure Infrastructure Management
Web Servers Web Servers
Networking
Networking Networking Services
Basic Basic
Advanced Advanced
MySQL MySQL
MongoDB MongoDB
PostgreSQL PostgreSQL
MSSQL MSSQL
Aerospike Aerospike
Clickhouse Clickhouse
TiDB TiDB
ScyllaDB ScyllaDB
Version Control Version Control
Kubernetes Kubernetes
Infrastructure Infrastructure Management
Web Servers Web Servers
Basic Basic
Advanced Advanced
MySQL Consulting
MySQL Migration Services
MySQL Optimization & Query Tuning
MySQL Database Administration
MySQL Backup & Recovery
MySQL Security & Maintenance
MySQL Cloud Services (AWS RDS, Aurora, Google Cloud SQL, Azure)
MySQL for Ecommerce
MySQL High Availability & Replication
MongoDB Consulting
MongoDB Migration Services
MongoDB Optimization & Query Tuning
MongoDB Database Administration
MongoDB Backup & Recovery
MongoDB Security & Maintenance
MongoDB Cloud (Atlas)
MongoDB Solutions by Industry
MongoDB High Availability & Replication
PostgreSQL Consulting
PostgreSQL Migration & Upgrades
Performance Tuning & Query Optimization
PostgreSQL Administration & Managed Services
High Availability, Clustering & Replication
PostgreSQL Backup, Recovery & Disaster Planning
PostgreSQL Security, Compliance & Auditing
PostgreSQL for Analytics & Data Warehousing
PostgreSQL on Cloud & Containers
PostgreSQL Extensions & Open-Source Integrations
PostgreSQL for Every Industry
MSSQL Consulting
MSSQL Migration Services
MSSQL Optimization & Query Tuning Services
MSSQL Database Administration Services
MSSQL Backup & Recovery Services
MSSQL High Availability & Replication Services
MSSQL Security & Compliance Services
MSSQL Performance Monitoring & Health Checks
MSSQL Solutions by Industry
Aerospike Consulting
Aerospike Migration Services
Aerospike Performance Optimization & Tuning
Aerospike Backup & Recovery
Aerospike High Availability
Aerospike Cloud & Hybrid Deployments
Aerospike for Real-Time Applications (AdTech, FinTech, Retail, IoT)
ClickHouse Consulting
ClickHouse Migration Services
ClickHouse Optimization & Query Tuning
ClickHouse Database Administration
ClickHouse Backup & Recovery
ClickHouse Security & Maintenance
ClickHouse Cloud Services (ClickHouse Cloud, AWS, GCP, Azure)
ClickHouse Solutions by Industry
ClickHouse High Availability & Replication
TiDB Consulting
TiDB Administration & Maintenance
TiDB Security and Privacy Maintenance
TiDB Performance & Query Optimization
TiDB Migration Services
TiDB Backup & Disaster Recovery
TiDB High Availability Solutions
TiDB Solutions by Industry
TiDB Cloud Services
ScyllaDB Consulting
ScyllaDB Administration & Maintenance
ScyllaDB Security and Privacy Maintenance
ScyllaDB Performance & Query Optimization
ScyllaDB Migration Services
ScyllaDB Backup & Disaster Recovery
ScyllaDB High Availability Solutions
ScyllaDB Solutions by Industry
ScyllaDB Cloud Services
  1. Home
  2. > Blogs
  3. > MongoDB
  4. > Reclaiming MongoDB Storage Space: A Journey to 50% Space Reduction

Reclaiming MongoDB Storage Space: A Journey to 50% Space Reduction

Efficiently Reclaim Disk Space in MongoDB: Strategies and Solutions for Optimal Performance.

Thivakar November 03, 2026

Table of Contents

  • Architecture of the MongoDB setup
  • Before Optimization
  • After Optimization
  • Key Actions Taken
  • Architecture of the MongoDB setup after adding temporary node
  • IP Swap process
  • Results
  • Best Practices for Ongoing Optimization

Subscribe for email updates

RSS feed
Summarize with AI: ChatGPT Google AI Perplexity Claude Grok

Managing disk space in a MongoDB setup can be challenging, especially as data continues to grow. In this blog, we share how we effectively reclaimed over 50% of the disk space in a MongoDB environment using strategic node management and optimization techniques.

 

Architecture of the MongoDB setup

 

PSS Architecture

 

Before Optimization

 

Our MongoDB setup consisted of 1 primary node and 2 secondary nodes, all running version 4.0.3. The system was heavily burdened with fragmented data, leading to excessive disk usage.


Disk Usage Breakdown

 

Nodes

Used %

Disk space

Node 192%2TB
Node 292%2TB
Node 392%2TB

Challenges

 

  • Fragmented Data: Excessive fragmentation caused inefficient disk usage.
  • High Downtime: Older MongoDB versions (4.0.3) had limitations with compact operations, leading to long downtimes.
  • Application Constraints: Pointing applications between nodes was not feasible due to setup constraints.

After Optimization


Through strategic actions, we were able to reclaim a substantial portion of disk space, reducing usage from 92% to just 54%.


Disk Usage Breakdown

 

Nodes

Used %

Disk space

Node 154%1TB
Node 254%1TB
Node 354%1TB


A graphical representation of storage optimization achieved by resolving fragmented data, showcasing significant disk space gains post-optimization.

 

 

Key Actions Taken

 

1. Introduction of a New Node:

A new hidden node was added to the replica set, enabling an initial sync of defragmented data without disrupting existing operations.


2. IP Swap Process:

To minimize downtime, we performed an IP swap between the newly added node and an existing secondary node.


Process:

  • Stopped MongoDB services for both nodes involved in the swap.
  • Swapped IP addresses and restarted services to apply the changes.

Architecture of the MongoDB setup after adding temporary node:

 

Hidden Node Added

 

IP Swap process

 

IP Swap
 

Challenges Addressed

Despite the older MongoDB version limitations, we tackled challenges such as fragmented data and network errors efficiently by:

 

  • Adjusting the initialSyncTransientErrorRetryPeriodSeconds parameter.
  • Using hidden nodes for smooth, incremental syncing of data.

Results

 

By reclaiming over 50% of the disk space, we achieved significant cost reduction and improved system performance. The newly optimized setup is running efficiently, with a smooth flow of data management.


Best Practices for Ongoing Optimization
 

  • Regular Monitoring: Continuously track disk usage and performance to identify potential issues early.
  • Upgrade Planning: Schedule MongoDB upgrades during maintenance windows to leverage advanced features.
  • Data Management: Implement robust archiving and cleanup processes to manage data growth effectively.

Reclaiming MongoDB storage space through strategic node management and optimization proved to be a successful approach. By introducing new nodes, performing IP swaps, and efficiently handling fragmentation, we successfully reduced disk usage by over 50%, ensuring a more efficient and cost-effective MongoDB environment.


If you’re facing similar challenges with your MongoDB setup, Mafiree can help optimize your data management. Reach out to us at sales@mafiree.com  to streamline your MongoDB performance and reduce storage costs effectively.

FAQ

The main cause was fragmented data. Over time, deletes and updates leave unused space inside the data files, and MongoDB does not always return that space to the operating system. The files kept growing while much of that space sat unused, so all three nodes showed 92% usage on 2TB disks.
In MongoDB 4.0.3, the compact operation blocks operations on the database it is running against and takes a long time on large collections. That means significant downtime. It also has to run on each node separately. Because of these limitations, we chose a safer approach that kept the application available.
A hidden node is a replica set member that holds a full copy of the data but is invisible to applications. It cannot become primary, and clients do not read from it. We added a new hidden node and let it perform an initial sync. An initial sync copies the data into fresh files, so the data arrives defragmented and takes much less space. The existing nodes kept serving traffic the whole time.
Applications could not be re-pointed between nodes, so we swapped IP addresses instead. We stopped MongoDB on the new node and on the secondary being replaced, swapped their IPs, and restarted both services. The application kept connecting to the same IP and reached the optimized node without any configuration change. The only interruption was the short restart window.
Initial sync on a large dataset takes a long time, so temporary network errors can interrupt it. On an older version like 4.0.3, a sync that hits such an error can fail. We handled this by increasing the initialSyncTransientErrorRetryPeriodSeconds parameter, which lets the sync keep retrying through transient errors instead of failing. Using a hidden node also meant the long sync did not affect production traffic.

Leave a Comment

Related Blogs

MongoDB Atlas Vector Search Tutorial: Build Semantic Search for Free

Build semantic search on MongoDB Atlas without paying for an embedding API. This tutorial shows two free routes: automatic embeddings with Voyage AI models (autoEmbed), where Atlas creates the vectors for you, and open-source sentence-transformers embeddings that you generate yourself. You will load sample data, create a vector index, query with $vectorSearch, add filters, and learn how to troubleshoot common problems, with an optional section for OpenAI embeddings.

  333 views
MongoDB Use Cases That Actually Need Expert Consulting Support

Not every MongoDB project needs a consultant—but complex workloads often do. This guide covers five MongoDB use cases where expert support can make the difference: schema design, large-scale migration, performance optimization, high availability and disaster recovery, and security and compliance.

  402 views
MongoDB Schema Design Patterns: Embedding vs. Referencing for Scale

Scale your MongoDB database by choosing the right relationship model. This guide breaks down the transition from traditional Referencing to high-performance Embedding and hybrid patterns like Extended References. Learn how to optimize your read/write paths and when to engage Mafiree’s performance tuning experts for enterprise-grade optimization.

  3094 views
MongoDB Query Optimization: How Mafiree Reduced E-Commerce Latency by 73%

Slow MongoDB queries silently erode user experience and revenue. This case study walks through how Mafiree’s MongoDB consulting team audited and optimized the query layer of a high-traffic e-commerce platform in India, reducing average API response times from 340ms to 92ms—a 73% improvement. It covers the diagnostic process using explain plans and profiler data, the indexing strategy overhaul, aggregation pipeline refactoring, and the monitoring framework that keeps performance on track.

  1946 views
MongoDB Transactions: A Comprehensive Guide to ACID Compliance

MongoDB ensures data consistency with single-document atomic operations and multi-document transactions. This guide explains how to implement transactions, their limitations, performance impacts, and best practices for production environments. It also highlights when to use distributed transactions and how expert consulting can help optimize performance.

  6909 views
Let MongoDB Clean Up After Itself: A Complete Guide to TTL Indexes

Tired of bloated log collections and messy data? TTL indexes in MongoDB automate your cleanup no cron jobs, no scripts. Learn how to set up, monitor, and optimize TTL for cleaner, faster, and self-maintaining databases.

  8103 views
Top 10 MongoDB Operators Every Developer Should Know (With Examples)

Unlock MongoDB’s full potential! Discover the most powerful MongoDB query operators to supercharge your queries with practical examples every developer can use. #MongoDB #DeveloperTips

  4891 views
Don't Let Hackers In: How to Secure and Harden Your MongoDB Database

Learn how to protect your MongoDB database with robust security practices, including user authentication, encryption, IP whitelisting, and input validation. Ensure your data remains safe and accessible in today's evolving threat landscape.

  5128 views
Seamless Data Transition: Exploring MongoDB Cluster To Cluster Sync

Achieve real-time data consistency with MongoDB Cluster-to-Cluster Sync. Discover how MongoSync enables seamless data synchronization for disaster recovery, global availability, and smooth migrations.

  8852 views
MongoDB Data Masking: Protect Card PII with Aggregation Pipelines and Views

MongoDB data masking helps organizations protect sensitive data like card numbers, names, and security codes while keeping data queryable. This guide explains how to implement masking using aggregation pipelines and RBAC-secured views, especially for environments where MongoDB field-level or queryable encryption is not available. Learn practical techniques, best practices, and real-world implementation steps to achieve MongoDB GDPR compliance.MongoDB data masking helps organizations protect sensitive data like card numbers, names, and security codes while keeping data queryable. This guide explains how to implement masking using aggregation pipelines and RBAC-secured views, especially for environments where MongoDB field-level or queryable encryption is not available. Learn practical techniques, best practices, and real-world implementation steps to achieve MongoDB GDPR compliance.

  1988 views
A Practical Guide to MongoDB Schema Validation

MongoDB schema validation helps maintain data consistency while preserving MongoDB’s flexible document model. It allows you to define rules for document structure, required fields, data types, and permitted values using JSON Schema. It also demonstrates how MongoDB rejects documents that fail the defined rules, helping applications prevent unintended schema changes and invalid data.

  1186 views
Protecting Sensitive Data: Mastering Queryable Encryption in MongoDB

Blog post showing how queryable encryption is being used to protect sensitive data.

  2820 views
6 Interesting Features In MongoDB 6.0

Upgrade to MongoDB 6.0 for improved index management, error handling, powerful aggregation, replicaset enhancements, time series collection improvements, and embedded field exclusion. Experience efficient database management.

  3378 views
Whats new in MongoDB 4.2

The wait is over for MongoDB 4.2. In this article, we will be discussing all the new features of MongoDB 4.2.

  3234 views
Why Use MongoDB for Modern Applications

Next generation databases must address some of the points such as being non-relational,highly available,open source and horizontally scalable. NoSQL databases has much increased features when it comes to non-structural data. In this article, we will discuss basics of NoSQL databases and why you need.

  1937 views

Subscribe for email updates

RSS feed
Get in touch with us

Highlights

More than 6000 Servers Monitored

Happy Clients

Certified DBAs

24 x 7 x 365 Support

PCI

Database Services

MySQL MongoDB PostgreSQL SQL Server Aerospike Clickhouse TiDB ScyllaDB

Quick Links

Careers Blog Contact Privacy Policy Disclaimer Policy

Contacts

Linkedin Mafiree Facebook Mafiree Twitter Mafiree

Nagercoil Office

Miru IT Park, Vallankumaranvillai,

Nagercoil, Tamilnadu - 629 002.

Bangalore Office

Unit 303, Vanguard Rise,

5th Main, Konena Agrahara,

Old Airport Road, Bangalore - 560 017.

Call: +91 6383016411

Email: sales@mafiree.com


Copyright © - All Rights Reserved - Mafiree