<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Ravindar Karampuri on Medium]]></title>
        <description><![CDATA[Stories by Ravindar Karampuri on Medium]]></description>
        <link>https://medium.com/@ravindar.karampuri?source=rss-b051562b02f7------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*W_GC_IAYOepnRudLK9fbWg.jpeg</url>
            <title>Stories by Ravindar Karampuri on Medium</title>
            <link>https://medium.com/@ravindar.karampuri?source=rss-b051562b02f7------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 00:11:56 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ravindar.karampuri/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Automating MongoDB Atlas Cluster Discovery Across All Projects Using PowerShell]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-snippet">Overview:</p><p class="medium-feed-link"><a href="https://medium.com/@ravindar.karampuri/automating-mongodb-atlas-cluster-discovery-across-all-projects-using-powershell-c41b04369e20?source=rss-b051562b02f7------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://medium.com/@ravindar.karampuri/automating-mongodb-atlas-cluster-discovery-across-all-projects-using-powershell-c41b04369e20?source=rss-b051562b02f7------2</link>
            <guid isPermaLink="false">https://medium.com/p/c41b04369e20</guid>
            <dc:creator><![CDATA[Ravindar Karampuri]]></dc:creator>
            <pubDate>Thu, 06 Nov 2025 09:18:50 GMT</pubDate>
            <atom:updated>2025-11-06T09:18:50.752Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Zero-Downtime Cloud Migration in MongoDB Atlas Cluster| Multi-Cloud | Best Practices]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-snippet">&#x1F534; Problem Statement:</p><p class="medium-feed-link"><a href="https://medium.com/@ravindar.karampuri/zero-downtime-cloud-migration-in-mongodb-atlas-cluster-multi-cloud-best-practices-28d6424aad10?source=rss-b051562b02f7------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://medium.com/@ravindar.karampuri/zero-downtime-cloud-migration-in-mongodb-atlas-cluster-multi-cloud-best-practices-28d6424aad10?source=rss-b051562b02f7------2</link>
            <guid isPermaLink="false">https://medium.com/p/28d6424aad10</guid>
            <dc:creator><![CDATA[Ravindar Karampuri]]></dc:creator>
            <pubDate>Thu, 11 Sep 2025 12:30:21 GMT</pubDate>
            <atom:updated>2025-09-11T12:30:21.894Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Understanding MongoDB Document Size: Internal Structure, Calculation, and Best Practices]]></title>
            <link>https://medium.com/@ravindar.karampuri/understanding-mongodb-document-size-internal-structure-calculation-and-best-practices-d9fdc95e3de6?source=rss-b051562b02f7------2</link>
            <guid isPermaLink="false">https://medium.com/p/d9fdc95e3de6</guid>
            <dc:creator><![CDATA[Ravindar Karampuri]]></dc:creator>
            <pubDate>Mon, 04 Aug 2025 05:11:57 GMT</pubDate>
            <atom:updated>2025-08-04T05:11:57.904Z</atom:updated>
            <content:encoded><![CDATA[<p>MongoDB is a powerful NoSQL database known for its flexibility and scalability. However, like all technologies, it comes with constraints. One such limitation is the 16MB document size cap. This article explores how MongoDB calculates document size, the implications of the size limit, and offers best practices to work effectively within these constraints.</p><h3>What Is a MongoDB Document?</h3><p>MongoDB stores data in BSON (Binary JSON) format. Each document is a key-value pair structure that supports nested objects and arrays, offering a rich data model. Example shown below.</p><h3>MongoDB Document Size Limit</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/674/1*_8N_vwOsQtYaFu_R09nYrQ.png" /><figcaption>Figure: Internal structure of a BSON document</figcaption></figure><p>MongoDB enforces a strict <strong>maximum document size of 16 megabytes (MB)</strong>. This includes:</p><ul><li>Field Names</li><li>Field Types</li><li>Field Values</li><li>BSON encoding overhead</li></ul><h3>How Is Document Size Calculated?</h3><p>Document size is based on its BSON representation. BSON adds metadata to each field, such as:</p><ul><li>Field type</li><li>Field name length</li><li>Array index keys as strings</li></ul><p>All of these contribute to the total byte size.</p><p><strong>Example:</strong> Consider the following document:</p><pre>{<br>  &quot;name&quot;: &quot;Alice&quot;,<br>  &quot;age&quot;: 30,<br>  &quot;skills&quot;: [&quot;MongoDB&quot;, &quot;Node.js&quot;]<br>}</pre><p>In BSON:</p><ul><li>Each field is prefixed with a type indicator (e.g., string, int32, array)</li><li>The key “name” is 4 characters long, and this name is stored as part of the document</li><li>The value “Alice” adds 6 bytes (1 byte for type, 1 byte for null-terminator, and 4 for the string)</li><li>Arrays like skills are stored as embedded documents with numeric keys like &quot;0&quot;, &quot;1&quot;</li></ul><p>So this document will include:</p><ul><li>Overhead for document header and field count</li><li>Field metadata for each entry</li><li>Actual values</li></ul><p>Thus, although the document appears small, its BSON representation might be significantly larger depending on nesting and field names.</p><p><strong>What contributes to size?</strong></p><ul><li>Number and length of field names</li><li>Embedded arrays and subdocuments</li><li>Value types (e.g., large strings, binary data)</li><li>BSON metadata overhead</li></ul><h3>Methods to Measure Document Size</h3><p>To measure the size of documents in a MongoDB collection using the shell, you need to install the mongocompat module, as it is not included by default. Once installed, you can use the bsonsize function directly from the shell prompt to accurately determine the size of individual documents. This is especially useful when monitoring document growth in relation to MongoDB’s 16MB size limit.</p><p><strong>Steps:</strong></p><ol><li>Open your <strong>MongoDB Atlas web shell</strong> (from your cluster interface).</li><li>Type and run the following command:</li></ol><pre>snippet install mongocompat</pre><ol><li>Once installed, you can then run shell commands that rely on legacy methods such as Object.bsonsize()</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/796/1*NfqeFtLSqLu9MU1M0b8AJw.png" /><figcaption>Install Mongocompat snippet</figcaption></figure><p><strong>To check if </strong><strong>mongocompat is installed:</strong> Run the following command:</p><p>&gt; snippet ls</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/828/1*fnq_bQoLmCzzDFAIERizfg.png" /><figcaption>Figure: Validate Snippet installed info</figcaption></figure><h4>1. Using Object.bsonsize() in mongosh</h4><pre>var doc = db.collection_name.findOne();<br>var size = Object.bsonsize(doc);<br>print(&quot;Size in bytes:&quot;, size);</pre><p>This image shows how to calculate the size of a MongoDB document using the shell. It retrieves one document from the movies collection in the sample_mflix database using findOne(), then calculates its size in BSON format with the Object.bsonsize() function. The size is stored in the sizeInBytes variable and printed out, showing that the document is 2,580 bytes. This method is useful for checking if documents are within MongoDB’s 16MB size limit.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/946/1*C6GbNXGtYsT9ry8Ju5jJSQ.png" /><figcaption>Figure: A single document size returns from this code.</figcaption></figure><h4>2. Using Aggregation with $bsonSize (MongoDB 6.1+)</h4><pre>db.colelction_name.aggregate([<br>  { $project: { size: { $bsonSize: &quot;$$ROOT&quot; } } }<br>]);</pre><p>This image shows how MongoDB’s aggregation framework is used to calculate the size of a document in the movies collection from the sample_mflix database. The query limits the result to one document and uses the $bsonSize operator to measure its size in bytes. The $$ROOT keyword refers to the entire document, and the result shows that the selected document is 2,580 bytes in size. This is a helpful way to check if documents are nearing MongoDB’s 16MB limit, which is the maximum size allowed for a single document.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/691/1*f-sJBcTC-EYUrgtvbdZn8g.png" /><figcaption>Figure: Alterernate way to identify size of document.</figcaption></figure><h3>Detecting Large Documents (&gt;10MB Example)</h3><pre>db.collection.aggregate([<br>  { $project: { _id: 1, size: { $bsonSize: &quot;$$ROOT&quot; } } },<br>  { $match: { size: { $gt: 10 * 1024 * 1024 } } }<br>]);</pre><pre>// document_size_scanner.js<br>db.yourCollection.find().forEach(doc =&gt; {<br>    let size = Object.bsonsize(doc);<br>    if (size &gt; 16000000) {<br>        print(&quot;⚠️ Large Document Detected:&quot;, doc._id, &quot;-&quot;, size, &quot;bytes&quot;);<br>    }<br>});</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d9fdc95e3de6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Managing MongoDB database changes using Liquibase pro]]></title>
            <link>https://medium.com/@ravindar.karampuri/managing-mongodb-database-changes-using-liquibase-pro-39b06b0e5a59?source=rss-b051562b02f7------2</link>
            <guid isPermaLink="false">https://medium.com/p/39b06b0e5a59</guid>
            <dc:creator><![CDATA[Ravindar Karampuri]]></dc:creator>
            <pubDate>Sun, 22 Jun 2025 05:54:28 GMT</pubDate>
            <atom:updated>2025-07-31T04:37:07.415Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*m8ksPHBXdIV55Dd_.png" /></figure><p>This article explores how Liquibase and MongoDB can be integrated with Git actions to implement source control for database changes</p><p><strong>What is Liquibase?</strong><br> Liquibase is an open-source tool designed to manage version control for database schema changes. It allows developers to simplify and automate the process of applying database updates across various database platforms. By using database-independent formats like XML, YAML, or JSON, Liquibase enables teams to define changes in a consistent and structured way. In a Java project, these updates are organized into files containing <em>changesets</em>, which outline the specific instructions needed to modify or refactor the database schema.</p><p><strong>What is MongoDB?</strong><br> MongoDB is an open-source NoSQL database management system that provides an alternative to traditional relational databases. It is designed to store and manage document-oriented data, making it ideal for scenarios that require flexible, scalable, and high-performance data storage and retrieval.</p><p><strong>Setting Up a Local MongoDB Instance on Windows</strong></p><p>To test the integration of tools like Liquibase with MongoDB, we need a MongoDB server running locally. Install MongoDB directly on a Windows machine.</p><h3><strong>Use Liquibase with MongoDB</strong></h3><p><a href="https://www.mongodb.com/">MongoDB</a> is a document-oriented NoSQL database. For more information, see the <a href="https://www.mongodb.com/docs/">MongoDB Documentation</a>.</p><p><strong>Supported database versions:</strong></p><p>Liquibase supports MongoDB versions starting from 5.0 on wards</p><p>5.x, 6.x, 7.x, 8.x</p><p><strong>Prerequisites</strong></p><ol><li>Download the latest version of the Liquibase MongoDB Pro Extension <a href="https://mvnrepository.com/artifact/org.liquibase.ext/liquibase-commercial-mongodb">here</a>.</li><li><a href="https://docs.liquibase.com/start/install/liquibase-requirements.html">Ensure Java is installed</a>: Liquibase requires Java to run. If you used the Liquibase Installer, Java is included automatically. Otherwise, you must <a href="https://www.java.com/en/download/">install Java</a> manually.</li><li>If you use Liquibase Pro, or a Liquibase Pro extension, confirm that you have a valid license key. For more information, see <a href="https://docs.liquibase.com/liquibase-pro/license-key.html">How to Apply Your Liquibase Pro License Key</a></li></ol><p><strong>Install supporting drivers:</strong></p><ol><li>Download the following four JAR files available in the (https://mvnrepository.com/artifact/org.liquibase.ext)</li></ol><ul><li><a href="https://mvnrepository.com/artifact/org.mongodb/mongodb-driver-core">MongoDB Java Driver Core</a> (mongodb-driver-core-&lt;version&gt;.jar)</li><li><a href="https://mvnrepository.com/artifact/org.mongodb/mongodb-driver-sync">MongoDB Synchronous Driver</a> (mongodb-driver-sync-&lt;version&gt;.jar)</li><li><a href="https://mvnrepository.com/artifact/org.mongodb/bson">MongoDB BSON</a> (bson-&lt;version&gt;.jar)</li><li><a href="https://github.com/liquibase/liquibase-mongodb/releases/">Liquibase MongoDB extension</a> (liquibase-mongodb-&lt;version&gt;.jar)</li></ul><p>2. Place above 4 jar files in the specified path C:\Program Files\liquibase\lib</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/694/1*s-VaTouZonOVdunuGNLaMA.png" /><figcaption>list of jarfiles required for this project</figcaption></figure><h3><strong>Connection Configuration:</strong></h3><p>1. MongoDB installed and configured as expected in your machine.</p><p>2. Ensure Liquibase Pro license key is specified in a <strong>liquibase.properties</strong> file.</p><p>3. Define the database URL in the defaults file, i.e.., connection string and credentials to connect successfully.</p><p>4. Install Mongosh to run mongoshell commands though Liquibase.</p><h3><strong>Connection Test:</strong></h3><ol><li>Create a text file called <a href="https://docs.liquibase.com/concepts/changelogs/home.html">changelog</a> (.js, .yaml, .json, or .xml) in your project directory and add a <a href="https://docs.liquibase.com/concepts/changelogs/changeset.html">changeset</a>.</li><li>Create files as per requirement.</li><li>Setup the git actions for the changes</li></ol><h3><strong>Hands-on execution steps detailed</strong></h3><h3><strong>1. Create project &amp; Add files</strong></h3><p>called, theliquibase-mdb-demo project demonstrates how to automate MongoDB database changes using Liquibase, a popular database change management tool. Here’s a detailed explanation of the project structure, the purpose of each folder and file, and how they are utilized:</p><pre>PS E:\temp&gt; mkdir liquibase-mdb-demo<br><br>    Directory: E:\temp<br><br>Mode                 LastWriteTime         Length Name<br>----                 -------------         ------ ----<br>d----          22-06-2025    07:24                liquibase-mdb-demo<br><br>PS E:\temp&gt; cd .\liquibase-mdb-demo\<br>PS E:\temp\liquibase-mdb-demo&gt; git init<br>Initialized empty Git repository in E:/temp/liquibase-mdb-demo/.git/<br>PS E:\temp\liquibase-mdb-demo&gt; </pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*2c6G5MeZixn1wcJ8g25VYQ.png" /><figcaption>Git project structure and its files</figcaption></figure><h3><strong>2. Project structure in VS Code</strong></h3><pre>liquibase.properties<br>README.md<br>Update-report-22-Jun-2025-081340.html<br>Update-report-22-Jun-2025-083530.html<br>changelog/<br>    changelog.json<br>mongoscripts/<br>    create_person_collection.js<br>    delete_person_data.js<br>    drop_person_collection.js<br>    insert_person_data.js</pre><h3><strong>3. Lifecycle of liquibase:</strong></h3><p><strong>3.1 Configuration: </strong>liquibase.properties tells Liquibase where to find the changelog and how to connect to MongoDB.</p><p><strong>3.2 Changelog Execution: </strong>changelog.json lists the database changes to apply, referencing scripts in mongoscripts.</p><p><strong>3.3 Script Execution: </strong>When you run liquibase update, Liquibase reads the changelog and executes the specified MongoDB scripts (e.g., inserting data, creating collections).</p><p><strong>3.4 Rollback Support: </strong>Each change set can specify a rollback script (e.g., delete_person_data.js) to undo changes if needed.</p><p><strong>3.5 Reporting: </strong>Update reports are generated for auditing.</p><h3><strong>4. Verify the liquibase version by using inbuilt command.</strong></h3><pre>PS E:\temp\liquibase-mdb-demo&gt; liquibase --version<br>#################################################### <br>##   _     _             _ _                      ## <br>##  | |   (_)           (_) |                     ## <br>##  | |    _  __ _ _   _ _| |__   __ _ ___  ___   ## <br>##  | |   | |/ _` | | | | | &#39;_ \ / _` / __|/ _ \  ## <br>##  | |___| | (_| | |_| | | |_) | (_| \__ \  __/  ## <br>##  \_____/_|\__, |\__,_|_|_.__/ \__,_|___/\___|  ## <br>##              | |                               ## <br>##              |_|                               ## <br>##                                                ## <br>##  Get documentation at docs.liquibase.com       ## <br>##  Get certified courses at learn.liquibase.com  ##<br>##                                                ##<br>####################################################<br>Liquibase Home: C:\Program Files\liquibase<br>Java Home C:\Program Files\liquibase\jre (Version 21.0.7)<br>Liquibase Pro Version: 4.32.0<br>To renew Liquibase Pro or Liquibase Labs please contact sales@liquibase.com or go to https://www.liquibase.com/pricing<br>=============================================================================<br>PS E:\temp\liquibase-mdb-demo&gt; liquibase checks run<br>Starting Liquibase Pro at 08:05:46 using Java 21.0.7 (version 4.32.0 #53 built at 2025-05-22 20:36:18 UTC)<br>Liquibase Pro Version: 4.32.0<br>To renew Liquibase Pro or Liquibase Labs please contact sales@liquibase.com or go to https://www.liquibase.com/pricing<br>INFO: Checks executed against changes generated by MongoDB at mongodb://localhost:27019/testdb.<br>Executing Policy Checks against changelog/changelog.json</pre><p>Once liquibase check commmand succeeded and no errors, we can run the execution by using the liquibase update command.</p><pre>PS E:\temp\liquibase-mdb-demo&gt; liquibase update<br>####################################################<br>##   _     _             _ _                      ##<br>##  | |   (_)           (_) |                     ##<br>##  | |    _  __ _ _   _ _| |__   __ _ ___  ___   ##<br>##  | |   | |/ _` | | | | | &#39;_ \ / _` / __|/ _ \  ##<br>##  | |___| | (_| | |_| | | |_) | (_| \__ \  __/  ##<br>##  \_____/_|\__, |\__,_|_|_.__/ \__,_|___/\___|  ##<br>##              | |                               ##<br>##              |_|                               ##<br>##                                                ##<br>##  Get documentation at docs.liquibase.com       ##<br>##  Get certified courses at learn.liquibase.com  ##<br>##                                                ##<br>####################################################<br>Starting Liquibase Pro at 08:35:26 using Java 21.0.7 (version 4.32.0 #53 built at 2025-05-22 20:36:18 UTC)<br>Liquibase Pro Version: 4.32.0<br>To renew Liquibase Pro or Liquibase Labs please contact sales@liquibase.com or go to https://www.liquibase.com/pricing<br><br>UPDATE SUMMARY<br>Run:                          2<br>Previously run:               0<br>Filtered out:                 0<br>Failed deployment:            0<br>-------------------------------<br>Total change sets:            2<br><br>Liquibase: Update has been successful. Rows affected: 0<br>Pro Update Report created!<br>* File &#39;/E:/temp/liquibase-mdb-demo/Update-report-22-Jun-2025-083530.html&#39; was created.<br>** To suppress Update reports add command arg &#39;liquibase update --report-enabled=false&#39;<br>** To suppress all Pro Reports set liquibase.reports.enabled=false, or LIQUIBASE_REPORTS_ENABLED=false<br>Liquibase command &#39;update&#39; was executed successfully.<br>PS E:\temp\liquibase-mdb-demo</pre><p>After success excution you will be redirected to html report generation for the same excution process for detailed audit process.</p><p>This screenshot shows a <strong>Liquibase Update Report</strong>, confirming a successful database update. The report indicates that <strong>2 change sets</strong> were executed with <strong>no previous runs, no filters, and no deployment failures</strong>, meaning all intended changes were applied cleanly. The message “Rows affected: 0” suggests schema-level updates (e.g., table creation or modification) rather than data changes. This ensures the changelog is working as expected and keeps the database schema version-controlled and consistent.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CI7crpK1NhpGRjQtzBlqow.png" /></figure><figure><img alt="This Liquibase report shows that two changesets were successfully executed with zero failures or skips. The changeset with ID 2025062202 inserted multiple documents into a MongoDB collection named person, adding sample data. These changes were defined in a JSON changelog file (changelog.json) and executed by user Ravindar. It confirms that Liquibase is being used to version and track NoSQL schema/data changes reliably." src="https://cdn-images-1.medium.com/max/1024/1*KVFXOJvHRks2eIk_f-kFWg.png" /></figure><p>Above Liquibase report shows that <strong>two changesets</strong> were successfully executed with <strong>zero failures or skips</strong>. The changeset with ID 2025062202 inserted multiple documents into a MongoDB collection named person, adding sample data. These changes were defined in a JSON changelog file (changelog.json) and executed by user <em>Ravindar</em>. It confirms that Liquibase is being used to version and track NoSQL schema/data changes reliably.</p><p>It create the collection named as <strong>person </strong>and insert data as provided in the file mongoscripts\insert_person_data.js</p><p>login to Mongodb database and check collection and data inside the collection for newly created one.</p><p>This screenshot from <strong>MongoDB Compass</strong> shows the successful insertion of four documents into the person collection in the testdb database. The data was pushed using <strong>Liquibase</strong>, as verified by the earlier changeset execution report, demonstrating how Liquibase can manage and apply structured NoSQL data changes to MongoDB collections in a controlled, versioned manner.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YzxJMJRZicpVAQojyt52EQ.png" /><figcaption>After success execution of liquibase update documents present in the collection — person</figcaption></figure><p>If those database changes need to rollback and keep it in previous consistent state, we can make it though the command:</p><p>To bring back one step: <strong>liquibase rollbackCount 1</strong></p><pre>PS E:\temp\liquibase-mdb-demo&gt; liquibase rollbackCount 1<br>####################################################<br>##   _     _             _ _                      ##<br>##  | |   (_)           (_) |                     ##<br>##  | |    _  __ _ _   _ _| |__   __ _ ___  ___   ##<br>##  | |   | |/ _` | | | | | &#39;_ \ / _` / __|/ _ \  ##<br>##  | |___| | (_| | |_| | | |_) | (_| \__ \  __/  ##<br>##  \_____/_|\__, |\__,_|_|_.__/ \__,_|___/\___|  ##<br>##              | |                               ##<br>##              |_|                               ##<br>##                                                ##<br>####################################################<br>To renew Liquibase Pro or Liquibase Labs please contact sales@liquibase.com or go to https://www.liquibase.com/pricing<br>Rolling Back Changeset: changelog/changelog.json::2025062202::Ravindar<br>Pro Rollback Count Report created!<br>* File &#39;/E:/temp/liquibase-mdb-demo/Rollback-count-report-22-Jun-2025-105836.html&#39; was created.<br>** To suppress Rollback Count reports add command arg &#39;liquibase rollback-count --report-enabled=false&#39;<br>** To suppress all Pro Reports set liquibase.reports.enabled=false, or LIQUIBASE_REPORTS_ENABLED=false<br>Liquibase command &#39;rollbackCount&#39; was executed successfully.<br>PS E:\temp\liquibase-mdb-demo&gt; </pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*k_qe8w3Ln21N6BPtLWT0ng.png" /><figcaption>HTML report: After rollback changes completed</figcaption></figure><p>This screenshot from <strong>MongoDB Compass</strong> shows that the person collection is now empty, verifying that the rollback removed the inserted documents. This highlights how Liquibase can manage and reverse schema or data changes in MongoDB with precision and traceability.</p><p>Database changes reflect in the compass for the same as shown below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OAHcNBgYUwP-VEbAnrfCJA.png" /></figure><p>In Liquibase with MongoDB, two special collections are automatically created and managed by Liquibase to track and control database changes:</p><p>This table explains two important internal collections used by <strong>Liquibase in MongoDB</strong> to manage database change tracking and ensure safe deployments. The <strong>databasechangelog</strong> collection keeps a record of all applied changesets, including details like the id, author, filename, and dateExecuted, so Liquibase knows what has already been executed. The <strong>databasechangeloglock</strong> collection is used to <strong>prevent concurrent updates</strong> by managing a locking mechanism. It includes fields like locked, lockGranted, and lockedBy, ensuring that only one process can apply changes at a time, avoiding conflicts or duplicate executions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/725/1*EKt7cX-f2KXQ0rolHeDy6w.png" /></figure><p><strong>In short:</strong></p><ul><li>databasechangelog = &quot;What changes have been applied?&quot;</li><li>databasechangeloglock = &quot;Is someone already running Liquibase right now?&quot;</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tJsnFW67HPpIiW-UC9IsMw.png" /><figcaption>Databasechangelog collection documents</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5Jxv7vD4-YlNK5bpmYllpA.png" /><figcaption>Databasechangeloglock collection document</figcaption></figure><h3><strong>5. Scripts used for this project</strong></h3><pre>mongoscripts\create_person_collection.js<br>db.createCollection(&#39;person&#39;);<br><br>mongoscripts\drop_person_collection.js<br>db.person.drop();<br><br>mongoscripts\insert_person_data.js<br>db.person.insertMany([<br>  { name: &quot;Alice &quot;, year: 2018, major: &quot;History&quot;, address: { city: &quot;NYC&quot;, street: &quot;123 3rd St&quot; } },<br>  { name: &quot;White Rabbit&quot;, year: 2017, major: &quot;English&quot;, address: { city: &quot;Rabbit&quot;, street: &quot;9 Down St&quot; } },<br>  { name: &quot;Mad Hatter&quot;, year: 2024, major: &quot;Math&quot;, address: { city: &quot;Hattery&quot;, street: &quot;5th Ave&quot; } },<br>  { name: &quot;Dutches&quot;, year: 2034, major: &quot;English&quot;, address: { city: &quot;The Manor&quot;, street: &quot;123 Down st&quot; } }<br>]);<br><br>mongoscripts\delete_person_data.js<br>db.person.deleteOne({ name: &quot;Alice &quot; });<br>db.person.deleteOne({ name: &quot;White Rabbit&quot; });<br>db.person.deleteOne({ name: &quot;Mad Hatter&quot; });<br>db.person.deleteOne({ name: &quot;Dutches&quot; });<br></pre><p>changelog.json</p><pre>{<br>  &quot;databaseChangeLog&quot;: [<br>   <br>     {<br>      &quot;changeSet&quot;: {<br>        &quot;id&quot;: &quot;2025062201&quot;,<br>        &quot;author&quot;: &quot;RK&quot;,<br>  &quot;labels&quot;: [&quot;git-1000&quot;, &quot;version 1.0&quot;],<br>        &quot;runWith&quot;: &quot;mongosh&quot;,<br>        &quot;changes&quot;: [<br>          {<br>            &quot;mongoFile&quot;: {<br>              &quot;dbms&quot;: &quot;mongodb&quot;,<br>              &quot;path&quot;: &quot;../mongoscripts/create_person_collection.js&quot;,<br>              &quot;relativeToChangelogFile&quot;: true<br>            }<br><br>          }<br>        ],<br>        &quot;rollback&quot;: [<br>          {<br>            &quot;mongoFile&quot;: {<br>              &quot;dbms&quot;: &quot;mongodb&quot;,<br>              &quot;path&quot;: &quot;../mongoscripts/drop_person_collection.js&quot;,<br>              &quot;relativeToChangelogFile&quot;: true<br>            }<br>           <br>          }<br>        ]<br>      }<br>    }, <br>     {<br>      &quot;changeSet&quot;: {<br>        &quot;id&quot;: &quot;2025062202&quot;,<br>        &quot;author&quot;: &quot;RK&quot;,<br>  &quot;labels&quot;: [&quot;git-1001&quot;, &quot;version 1.0&quot;],<br>        &quot;runWith&quot;: &quot;mongosh&quot;,<br>        &quot;changes&quot;: [<br>          {<br>            &quot;mongoFile&quot;: {<br>              &quot;dbms&quot;: &quot;mongodb&quot;,<br>              &quot;path&quot;: &quot;../mongoscripts/insert_person_data.js&quot;,<br>              &quot;relativeToChangelogFile&quot;: true<br>            }<br><br>          }<br>        ],<br>        &quot;rollback&quot;: [<br>          {<br>            &quot;mongoFile&quot;: {<br>              &quot;dbms&quot;: &quot;mongodb&quot;,<br>              &quot;path&quot;: &quot;../mongoscripts/delete_person_data.js&quot;,<br>              &quot;relativeToChangelogFile&quot;: true<br>            }<br>           <br>          }<br>        ]<br>      }<br>    }<br>   <br>  ]<br>}</pre><h3><strong>6. Liquibase Commands:</strong></h3><pre>liquibase status -verbose<br>liquibase checks run<br>liquibase update<br>liquibase history<br>liquibase rollbackCount 1<br>liquibase update - log-level=debug // Detailed log view<br>liquibase --help // To explore more on Liquibase commands</pre><h3>7. Create a git project info:</h3><ol><li>git add .</li></ol><p>2. git commit -m “Initial MongoDB automation setup with Liquibase Pro”</p><p>3. git remote add origin &lt;your-repo-url&gt;</p><p>4. git push -u origin main</p><p><strong>References:</strong></p><ul><li><a href="https://docs.liquibase.com/start/tutorials/mongodb-pro/home.html">Using Liquibase MongoDB Pro with MongoDB platforms</a></li><li><a href="https://www.mongodb.com/docs/drivers/java/sync/current/">MongoDB Java Driver - Java Sync Driver v5.5 - MongoDB Docs</a></li></ul><p>Liquibase Pro vs Open Source visit link <a href="https://cdn.prod.website-files.com/65c3a844357606c1b08a1e74/67ed23ac369e4789677b26a1_Liquibase%20Pro%20vs%20OSS.pdf">here</a>:</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=39b06b0e5a59" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[When configuring cache size for a WiredTiger-based on-prem MongoDB deployment, consider these…]]></title>
            <link>https://medium.com/@ravindar.karampuri/when-configuring-cache-size-for-a-wiredtiger-based-on-prem-mongodb-deployment-consider-these-7c19ae4c5abe?source=rss-b051562b02f7------2</link>
            <guid isPermaLink="false">https://medium.com/p/7c19ae4c5abe</guid>
            <dc:creator><![CDATA[Ravindar Karampuri]]></dc:creator>
            <pubDate>Tue, 27 May 2025 18:42:43 GMT</pubDate>
            <atom:updated>2025-05-27T18:49:05.978Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Best Practices for Configuring and Tuning WiredTiger Cache Size in MongoDB Deployments</strong></p><ol><li><strong>Default Cache Size</strong>: The default WiredTiger internal cache size is the larger of either 50% of (RAM — 1 GB) or 256 MB. This default is suitable for most deployments where a single mongod instance runs per machine.</li><li><strong>Containerization</strong>: When running mongod in a container, ensure that cacheSizeGB under storage.wiredTiger.engineConfig is set below the container’s total memory, considering the memory needs of other processes</li><li><strong>Filesystem Cache</strong>: MongoDB leverages the operating system’s filesystem cache to keep compressed data files in memory, which helps minimize disk I/O. To maintain this efficiency, configure the WiredTiger cache size to leave enough memory for the filesystem cache.</li><li><strong>Cache Allocation</strong>: Avoid increasing the WiredTiger internal cache size beyond its default unless absolutely necessary, as doing so may limit memory available for the filesystem cache and other system processes.</li><li><strong>Monitoring and Adjustment</strong>: Regularly monitor cache usage and eviction statistics using the serverStatus command to ensure optimal performance. Adjust the cache size based on the workload and memory usage patterns.</li></ol><p><strong>MongoDB configuration setup script</strong> (YAML for mongod.conf) that calculates and allocates WiredTiger cache size based on server RAM.<br> <strong>Best practice:</strong> Allocate ~50% of total RAM to WiredTiger cache, leaving the rest for the OS and other processes.</p><p><strong>Step 1: Calculate Cache Size</strong></p><p>Suppose your server has <strong>32 GB RAM</strong>:</p><ul><li>50% of 32 GB = <strong>16 GB</strong> for WiredTiger cache.</li></ul><p><strong>Step 2: Example mongod.conf</strong></p><pre>storage:<br>dbPath: /var/lib/mongo<br>journal:<br>enabled: true<br>wiredTiger:<br>engineConfig:<br>cacheSizeGB: 16 # Set to 50% of total RAM (adjust as needed)<br>systemLog:<br>destination: file<br>path: /var/log/mongodb/mongod.log<br>logAppend: true<br>net:<br>port: 27017<br>bindIp: 0.0.0.0<br>processManagement:<br>fork: true<br>security:<br>authorization: enabled</pre><p><strong>Step 3: Apply and Start MongoDB</strong></p><p>sudo systemctl restart mongod</p><p>or</p><p>mongod — config /etc/mongod.conf</p><p><strong>To check the total RAM size on a Linux system, you can use any of the following commands:</strong></p><p><strong>Using below list of commands:</strong></p><pre>free -h<br><br>grep MemTotal /proc/meminfo<br><br>vmstat -s | grep &quot;total memory&quot;</pre><p><strong>Using </strong><strong>top or </strong><strong>htop:</strong></p><ul><li>Run top and look at the memory summary near the top.</li><li>htop (if installed) provides a more visual and interactive display.</li></ul><p><strong>Tip:</strong></p><ul><li>Adjust cacheSizeGB based on your server’s RAM.</li><li>Always leave enough RAM for the OS and other applications.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7c19ae4c5abe" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding Oplog Churn in MongoDB]]></title>
            <link>https://medium.com/@ravindar.karampuri/understanding-oplog-churn-in-mongodb-ab07930584b6?source=rss-b051562b02f7------2</link>
            <guid isPermaLink="false">https://medium.com/p/ab07930584b6</guid>
            <dc:creator><![CDATA[Ravindar Karampuri]]></dc:creator>
            <pubDate>Wed, 02 Apr 2025 17:40:26 GMT</pubDate>
            <atom:updated>2025-04-05T16:57:40.445Z</atom:updated>
            <content:encoded><![CDATA[<p>Oplog churn is the term used to describe a replica set’s high turnover, or frequent overwriting, of the operations log, or oplog. If the oplog is too tiny, this might result in secondary node desynchronization, replication slowness, and full resync problems.</p><p><strong>What Causes High Oplog Churn?</strong></p><ul><li><strong>High Write Volume</strong> →Frequent insert/update/delete operations</li><li><strong>Small Oplog Size</strong> → Oplog fills up too fast, forcing old entries to be overwritten quickly</li><li><strong>Bulk Updates/Inserts</strong> → Large batch operations consume oplog rapidly</li><li><strong>Sharded Cluster Imbalances</strong> → If one shard gets more writes than others</li><li><strong>Secondary Lag</strong> → Slow replication leads to oplog getting purged before secondaries sync</li></ul><p><strong>Find Current Oplog Size</strong></p><pre>db.getReplicationInfo()</pre><h4><strong>Check Oplog Entries &amp; Their Age</strong></h4><pre>use local<br>db.oplog.rs.find().sort({ ts: 1 }).limit(1)<br>db.oplog.rs.find().sort({ ts: -1 }).limit(1)</pre><pre>// Here, Its one of sharding node, running from local database.<br>shard2rs [primary] local&gt; db.getReplicationInfo()<br>{<br>  configuredLogSizeMB: 48682.645263671875,<br>  logSizeMB: 48682.645263671875,<br>  usedMB: 8.56,<br>  timeDiff: 22391729,   // in seconds<br>  timeDiffHours: 6219.92,<br>  tFirst: &#39;Sat Jul 20 2023 18:09:48 GMT+0530 (India Standard Time)&#39;,<br>  tLast: &#39;Sat Apr 05 2024 22:05:17 GMT+0530 (India Standard Time)&#39;,<br>  now: &#39;Sat Apr 05 2024 22:05:18 GMT+0530 (India Standard Time)&#39;<br>}</pre><p>First timestamp = Oldest oplog entry<br>Last timestamp = Most recent oplog entry<br>Difference = Oplog Retention Window<br>If this window is only a few minutes or hours, it’s too small!<br>Check Oplog Usage Rate</p><pre>use admin<br>db.serverStatus().metrics.repl.apply.batches.totalMillis</pre><pre>// Here we will get detailed info using this command<br>shard2rs [primary] admin&gt; db.serverStatus().metrics.repl.apply<br>{<br>  attemptsToBecomeSecondary: Long(&#39;1&#39;),<br>  batchSize: Long(&#39;1162&#39;),<br>  batches: { num: 1158, totalMillis: 7889 },<br>  ops: Long(&#39;1162&#39;)<br>}</pre><p>Shows total oplog batches applied</p><p>If rapidly increasing, indicates high churn</p><p><strong>How to Fix High Oplog Churn?</strong></p><p>Increase Oplog Size</p><pre>db.adminCommand({ replSetResizeOplog: 1, size: 50000 }) // 50GB</pre><p>Optimize write workload</p><pre>db.collection.bulkWrite([...])</pre><p><strong>Avoid unnecessary updates</strong></p><ul><li>Instead of updateMany(), prefer updateOne()</li><li>Use $set instead of full document overwrites</li></ul><p><strong>Reduce Index Maintenance Overhead</strong></p><ul><li>Too many indexes can <strong>increase oplog churn</strong> due to frequent updates</li><li>Check unused indexes:</li></ul><pre>db.collection.aggregate([ { $indexStats: {} } ])</pre><ul><li>Drop unused indexes:</li></ul><pre>syntax: db.collection.dropIndex(&quot;index_name&quot;)</pre><h3><strong>Monitor Replication Lag</strong></h3><p>Use <strong>Ops Manager or Mongodb Atlas UI and setup alerts accordingly.</strong></p><p>Login to any replicaset node and run the replication lag info command from mongoshell.</p><pre>rs.printSecondaryReplicationInfo()<br><br>//example:<br>shard2rs [primary] admin&gt; rs.printSecondaryReplicationInfo()<br>source: 192.168.56.1:27108<br>{<br>  syncedTo: &#39;Sat Apr 05 2024 22:25:12 GMT+0530 (India Standard Time)&#39;,<br>  replLag: &#39;0 secs (0 hrs) behind the primary &#39;<br>}<br>---<br>source: 192.168.56.2:27018<br>{<br>  syncedTo: &#39;Sat Apr 05 2024 22:25:02 GMT+0530 (India Standard Time)&#39;,<br>  replLag: &#39;-10 secs (0 hrs) behind the primary &#39;<br>}</pre><p>If replication lag is high:</p><ol><li><strong>Increase oplog size</strong></li><li><strong>Check disk IOPS</strong> (slow disks can delay replication)</li><li><strong>Upgrade secondary servers if needed</strong></li></ol><h3><strong>Summary:</strong></h3><ol><li>Oplog churn = Rapid oplog turnover → Risk of replication failure</li><li>Monitor oplog size, retention window, and write volume</li><li>Increase oplog size to keep 24–48 hours of operations</li><li>Optimize writes &amp; reduce unnecessary updates</li><li>Ensure secondaries can replicate fast enough</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ab07930584b6" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>