<?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 Riya Negi on Medium]]></title>
        <description><![CDATA[Stories by Riya Negi on Medium]]></description>
        <link>https://medium.com/@riyasnegi12?source=rss-64118db8a09d------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*EYzIHGMzFvFGiNoWgy-Qsw.jpeg</url>
            <title>Stories by Riya Negi on Medium</title>
            <link>https://medium.com/@riyasnegi12?source=rss-64118db8a09d------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 20 Nov 2026 14:19:08 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@riyasnegi12/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[Wissen Technology Internship + PPO Interview Experience (2022)]]></title>
            <link>https://medium.com/@riyasnegi12/wissen-technology-internship-ppo-interview-experience-2022-1f87e2932cfa?source=rss-64118db8a09d------2</link>
            <guid isPermaLink="false">https://medium.com/p/1f87e2932cfa</guid>
            <category><![CDATA[internships]]></category>
            <category><![CDATA[campus-placements]]></category>
            <category><![CDATA[wissen]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[interview]]></category>
            <dc:creator><![CDATA[Riya Negi]]></dc:creator>
            <pubDate>Tue, 10 Feb 2026 12:32:00 GMT</pubDate>
            <atom:updated>2026-02-10T12:33:00.291Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>“The first job opportunity is always unforgettable”</strong></p><p>Not just because it brings financial independence, but because it gives you your first real exposure to the corporate world — where your knowledge is tested, your problem-solving is judged, and your confidence is built step by step.</p><p>In this blog, I’m sharing my complete interview experience for <strong>Wissen Technology</strong> during my <strong>7th semester (2022)</strong> for the <strong>Internship + PPO</strong> role.</p><h3>Internship Details</h3><ul><li><strong>Internship Duration:</strong> Jan 2023 — May 2023</li><li><strong>Package Offered: 11 LPA (8 LPA Base + 3 LPA Bonus)</strong></li></ul><h3>The Interview Process</h3><p>The selection process consisted of <strong>4 rounds</strong>:</p><ol><li><strong>Online Assessment</strong></li><li><strong>Technical Interview Round 1</strong></li><li><strong>Technical Interview Round 2</strong></li><li><strong>Technical Interview Round 3</strong></li></ol><h3>Round 1: Online Assessment (1 Hour)</h3><p>The first round was an online assessment of <strong>1 hour</strong>, which included:</p><ul><li>MCQs (Java, OOPs, SQL, OS, aptitude)</li><li>2 DSA coding questions</li></ul><p>The biggest challenge here was not the difficulty of the questions, but the <strong>time crunch</strong>. It felt like the test was designed to check both speed and accuracy.</p><p>This round set the tone: the process was going to be intense.</p><h3>Round 2: Technical Interview 1 (1 Hour)</h3><p>The interview started with the classic question:</p><p><strong>“Give me a brief introduction about yourself.”</strong></p><p>After that, the real interview began. The interviewer quickly shifted into core Java and OOPs concepts. The questions weren’t random — they were meant to test whether I truly understood how Java works internally.</p><h3>Java and OOPs Questions Asked:</h3><ul><li>final keyword in Java, static keyword, , difference between String and String Builder, features of Java, JVM, JRE, JDK, how java is platform independent etc.</li><li>Four pillars of OOPs (explain each in detail), classes and objects, method overloading vs method overriding, Interface vs Abstract class, Diamond problem, types of inheritance, polymorphism and its types</li><li>Exception Handling</li></ul><p>After covering Java, the interviewer moved to coding.</p><h3>DSA Questions Asked:</h3><ul><li>Balanced Parentheses</li><li>Check if two strings are valid anagrams</li></ul><p>Before writing code, I explained my approach. While coding, I made sure to speak out loud and describe what I was doing. Once the solution was complete, I was asked — Time complexity, Space complexity, how to optimize further.</p><h3>Round 3: Technical Interview 2 (1 Hour 30 Minutes)</h3><p>This round was longer and more challenging because it covered multiple subjects. The interviewer tested me on Java again, but this time the focus shifted more toward problem-solving and computer science fundamentals.</p><h3>DSA Questions Asked:</h3><ul><li>Sum of all root-to-leaf nodes (Tree problem)</li><li>Reverse K nodes in a linked list</li><li>Merge two linked lists</li></ul><h3>Operating System Questions Asked:</h3><ul><li>Why cache memory is faster</li><li>Starvation</li><li>Race condition and how to prevent it</li><li>Context switching</li></ul><h3>SQL Questions Asked:</h3><ul><li>Joins and types of joins</li><li>Normalization and its types (1NF, 2NF, 3 NF etc.)</li></ul><h3>Round 4: Technical Interview 3 (1 Hour 30 Minutes)</h3><p>The final round was again technical-heavy. At this point, I expected fewer questions, but it was the opposite — they were still testing deeply. They again grinded me on Java and OOPs.</p><h3>DSA Questions Asked:</h3><ul><li>Sum of root nodes in a tree</li><li>Detect cycle in linked list → If a cycle exists, return the node where the cycle begins (with a modification)</li></ul><h3>SQL Questions Asked:</h3><ul><li>Indexes and types of indexes</li><li>Types of keys - primary key, candidate key, foreign key, super key, unique key</li><li>Aggregate Functions</li><li>Use of <strong>Limit </strong>keyword</li></ul><h3>What Wissen Technology Really Looks For</h3><p>After going through all rounds, I understood what Wissen values the most:</p><ol><li>Strong Java Fundamentals</li><li>OOPs Clarity</li><li>DSA Problem Solving (Trees, linked lists, stacks, and strings were the most common topics)</li><li>SQL + OS Knowledge</li><li>Communication and Thought Process → Explaining your approach matters a lot. They observe your thinking, not only your code.</li></ol><h3>My Preparation Resources</h3><p>Here are the resources that helped me the most:</p><ol><li>Java → Java Interview Questions by InterviewBit</li><li>OOPs → OOPs Interview Questions by InterviewBit</li><li>DSA → Striver’s A-Z DSA Sheet, Leetcode Top 150, Aditya Verma (Best for DP, Stacks, Binary Search)</li></ol><h3>🎯Final Thoughts</h3><p>Getting selected for Wissen Technology Internship + PPO during the 7th semester was a major milestone for me.</p><p>This process taught me one important thing: <strong>Good placements are not about luck. They are about consistency and fundamentals.</strong></p><p>If you are preparing for Wissen Technology, focus on:</p><ul><li>Java + OOPs concepts (deep understanding)</li><li>DSA practice (especially trees and linked lists)</li><li>SQL (joins, normalization, indexing)</li><li>OS basics (race condition, starvation, context switching)</li></ul><h3>✨ All the best!</h3><p>With the right preparation, the interview becomes manageable. If you’re reading this and preparing for placements — keep going.<br><strong>Consistency always pays off!</strong> 🚀</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1f87e2932cfa" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ My HashedIn by Deloitte Interview Experience | SDE II]]></title>
            <link>https://medium.com/@riyasnegi12/my-hashedin-by-deloitte-interview-experience-sde-ii-9bff0eced6b6?source=rss-64118db8a09d------2</link>
            <guid isPermaLink="false">https://medium.com/p/9bff0eced6b6</guid>
            <category><![CDATA[sde-interview]]></category>
            <category><![CDATA[java-developer]]></category>
            <category><![CDATA[hashedin-by-deloitte]]></category>
            <category><![CDATA[interview-experience]]></category>
            <dc:creator><![CDATA[Riya Negi]]></dc:creator>
            <pubDate>Wed, 12 Nov 2025 08:20:35 GMT</pubDate>
            <atom:updated>2025-11-13T12:50:56.209Z</atom:updated>
            <content:encoded><![CDATA[<p>Breaking into a new role is always a mix of excitement and nervousness — especially when it’s with a company known for its strong engineering culture like <strong>HashedIn by Deloitte</strong>.</p><p>After going through multiple rounds of interviews that tested my <strong>Java fundamentals</strong>, <strong>system design thinking</strong>, and <strong>problem-solving skills</strong>, I’m thrilled to share that I’ve joined <strong>HashedIn by Deloitte as SDE II</strong>.</p><p>Ever since I made the announcement, many friends and connections have been asking about my interview process — what kind of questions were asked, what the rounds were like, and how I prepared for them.</p><p>So in this blog, I’ll walk you through my <strong>entire interview journey</strong>, from the <strong>technical deep dives in Java and Spring Boot</strong> to the <strong>system design discussions</strong> and the <strong>managerial round</strong> that tested my soft skills and decision-making approach.</p><p>If you’re preparing for an <strong>SDE role</strong> or want to understand how interviews at HashedIn by Deloitte typically go, this might help you get a realistic idea of what to expect.</p><h3>🧩 Round 1: Technical (Java + Spring Boot + DSA)</h3><p>The first round was completely focused on <strong>core Java concepts</strong>, <strong>Spring Boot</strong>, and <strong>problem-solving</strong>.<br> The interviewer started with some basic questions but kept diving deeper into each topic to test my understanding.</p><p>Some of the areas we discussed:</p><ul><li>Java fundamentals and OOPs concepts</li><li>Exception handling and collections</li><li>Spring Boot annotations and dependency injection</li><li>How to optimize APIs and handle exceptions</li><li>Output-based Java questions</li></ul><p>After the conceptual part, I was asked to solve <strong>two LeetCode medium-level problems</strong>:</p><ol><li><strong>Binary Search</strong> based problem</li><li><strong>Sliding Window</strong> based problem</li></ol><p>I was able to solve both within 20 minutes, and we discussed possible optimizations as well.<br>The round lasted for a little over <strong>an hour</strong> and was a great mix of theory and coding.</p><h3>🧱 Round 2: System Design &amp; Architecture Discussion</h3><p>This round was all about <strong>design thinking and architectural understanding</strong>.<br> It started with a quick discussion of my <strong>previous projects</strong> and the <strong>architecture</strong> I had implemented.</p><p>Then we moved into a detailed <strong>system design discussion</strong>, covering:</p><ul><li><strong>Microservices vs Monolithic</strong> architecture — and interestingly, <em>why monolithic can still be a good choice in certain cases.</em></li><li>Key components of scalable systems</li><li>Role of <strong>API Gateway</strong> and <strong>Load Balancer (its types as well)</strong></li><li><strong>Database query optimization</strong> techniques and how to improve performance</li><li>SOLID Principles and Design Patterns (Even asked me to explain two design patterns that I had implemented in my previous projects)</li><li>Asked me to draw the whole HLD of my previous project and improvements that can be done</li></ul><p>This round tested not just my technical knowledge but also how I approach real-world problems and design decisions. It lasted for around <strong>1 hour 15 minutes</strong>.</p><h3>💬 Round 3: Managerial + HR Discussion</h3><p>The final round was a mix of <strong>managerial</strong>, <strong>situational</strong>, and <strong>behavioral</strong> questions.<br> The interviewer wanted to understand how I handle challenges within a team and my thought process in tricky situations.</p><p>A few examples:</p><ul><li><em>What if your manager favors one of your teammates and everyone else is upset — how would you handle it?</em></li><li><em>If one team member is struggling with tasks and affecting others, what would you do?</em></li><li><em>Estimate the number of pet dogs or petrol pumps in your city.</em> (Yes, some fun guesstimate questions 😄)</li><li><em>Why are you leaving your current company and what excites you about HashedIn by Deloitte?</em></li></ul><p>This round lasted for about <strong>45 minutes</strong> and felt more like a conversation than an interview.</p><h3>🌱 Final Thoughts</h3><p>Overall, the entire process was <strong>smooth, structured, and well-organized</strong>.<br> Each round tested a different dimension — <strong>technical depth</strong>, <strong>design thinking</strong>, and <strong>behavioral maturity</strong>.</p><p>I really appreciated how the interviewers focused on <strong>understanding my approach</strong> rather than just the final answer.<br>Joining HashedIn by Deloitte has been an exciting step, and I’m looking forward to working on impactful, large-scale systems with amazing people.</p><h3>💡 Tips for Future Candidates</h3><ul><li>Brush up on <strong>Java fundamentals</strong> and <strong>Spring Boot concepts</strong> deeply.</li><li>Practice <strong>DSA problems (LeetCode medium level)</strong>, especially arrays, strings, and binary search patterns.</li><li>Revisit <strong>system design basics</strong> — scalability, fault tolerance, and architecture trade-offs.</li><li>Prepare for <strong>behavioral questions</strong> with real examples from your experience.</li></ul><p>If you found this article helpful, <strong>give it a clap</strong> (or a few 👏) — it really motivates me to share more such experiences and tips!<br>And if you have any <strong>questions or doubts</strong>, feel free to <strong>drop them in the comments</strong> — I’ll be happy to answer and help you out.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9bff0eced6b6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[From PHP Monolith to Java Microservices: Lessons Learned & Pitfalls to Avoid]]></title>
            <link>https://medium.com/@riyasnegi12/from-php-monolith-to-java-microservices-lessons-learned-pitfalls-to-avoid-94083e84c019?source=rss-64118db8a09d------2</link>
            <guid isPermaLink="false">https://medium.com/p/94083e84c019</guid>
            <category><![CDATA[microservices]]></category>
            <category><![CDATA[scalability]]></category>
            <category><![CDATA[migration]]></category>
            <category><![CDATA[monolithic-architecture]]></category>
            <category><![CDATA[spring-boot]]></category>
            <dc:creator><![CDATA[Riya Negi]]></dc:creator>
            <pubDate>Fri, 08 Aug 2025 16:26:33 GMT</pubDate>
            <atom:updated>2025-08-08T16:26:33.582Z</atom:updated>
            <content:encoded><![CDATA[<p>Our EV charging management platform started as a <strong>simple PHP monolith</strong>. It worked… until it didn’t :)</p><p>As we expanded into new countries, added more features, and faced deployment headaches, it became clear — we had outgrown our architecture.</p><p>This is the story of how we migrated from a <strong>monolithic PHP application</strong> to <strong>Spring Boot microservices</strong> — why we did it, how we approached it, the challenges we faced, and why monoliths still have their place.</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*mnf8ggrfFJGa-Bc9" /></figure><h3>Monolithic vs Microservices — The Quick Primer</h3><h4>Monolithic Architecture</h4><ul><li>A single unified codebase (frontend, backend, business logic all bundled together)</li><li>Tight coupling between modules</li><li>One deployment = restart the whole system</li><li>Easier to start with, harder to scale in parts</li></ul><p><strong>Example from our old system:</strong><br>Updating a small payment flow in PHP meant <strong>redeploying the entire app</strong> and risking downtime for unrelated services like driver management or charger monitoring. These regular downtimes not only affected the service but also caused revenue loss to the company during that time.</p><h4>Microservices Architecture</h4><ul><li>Independent, loosely coupled services</li><li>Each has its own codebase, database, and deployment pipeline</li><li>Deploy one service without affecting others</li><li>More complex to set up, but easier to scale specific modules</li></ul><p><strong>Example from our new system:</strong><br>We can now push a <strong>Payments Service update</strong> without touching Notification Service, Vehicle Service or Driver Management.</p><h3>Why We Migrated</h3><ol><li><strong>Deployment Pain</strong> — Any change meant redeploying the whole app → downtime for all features.</li><li><strong>Global Expansion</strong> — Each country had its own payment gateway, localization, and compliance rules. Handling all in one codebase was getting messy.</li><li><strong>Scaling Bottlenecks</strong> — Some modules like Payments needed extra resources; scaling the whole app was wasteful.</li><li><strong>Team Efficiency</strong> — Multiple developers working on a single repo caused merge conflicts and slowed delivery.</li></ol><h3>How We Did It — Our Migration Approach</h3><p>We didn’t rip everything apart at once — that’s a recipe for disaster. Instead, we followed an <strong>incremental migration strategy</strong>.</p><h3>1. Strangler Fig Pattern</h3><p>We started carving out <strong>self-contained modules</strong> from the monolith and reimplementing them in Spring Boot microservices. Example order:</p><ul><li>Payment Service</li><li>Charging Management Service</li><li>Driver Management Service</li><li>Inventory Service</li><li>Notification Service</li></ul><h3>2. Dual Database Writes (Data Synchronization Phase)</h3><p>To avoid data inconsistency during the transition, <strong>every write operation was performed in both the monolithic DB and the new microservice DB</strong>.</p><p>Example: When a payment was processed:</p><ul><li>PHP monolith wrote to payments collection in MongoDB</li><li>Spring Boot microservice wrote to payments table in its own MySQL</li><li>We added logging to flag any mismatches</li></ul><p>This allowed us to:</p><ul><li>Keep both systems in sync during migration</li><li>Test microservices in production without breaking the old system</li><li>Switch over completely once stable</li></ul><h3>3. Eliminating Legacy Code</h3><p>When a service was fully tested and stable:</p><ul><li>We removed related business logic from the monolith</li><li>Updated the API Gateway to route all requests for that module to the new microservice</li><li>Shut down old DB collections for that module</li></ul><p>Example: Once Payments Service was stable in Spring Boot, <strong>all payment-related PHP code was deleted</strong> and the payment endpoints were handled entirely by the new service.</p><h3>4. API Gateway &amp; Service Communication</h3><p>We introduced an <strong>API Gateway</strong> for routing:</p><ul><li>/payments/** → Payment Service</li><li>/battery/** → Battery Charging Service</li><li>/drivers/** → Driver Service</li></ul><p>Microservices communicated with each other via:</p><ul><li><strong>REST APIs</strong> for synchronous calls</li><li><strong>Message queues</strong> (Kafka) for async events like <em>payment success → update charging session status</em></li></ul><h3>5. Monitoring &amp; Observability</h3><p>We implemented:</p><ul><li><strong>Centralized Logging</strong> with ELK stack (Elasticsearch, Logstash, Grafana)</li><li><strong>Health Checks</strong> with Spring Boot Actuator</li></ul><h3>How Microservices Helped Us</h3><ul><li><strong>Independent Deployments</strong> — Payments could be fixed without touching Charger Management.</li><li><strong>Scalability</strong> — We scaled Payments during peak hours without touching other services.</li><li><strong>Technology Freedom</strong> — We kept MongoDB for real-time services, PostgreSQL for transactional modules.</li><li><strong>Faster Delivery</strong> — Teams worked in parallel on separate services without stepping on each other’s toes.</li></ul><h3>Pitfalls &amp; Challenges We Faced</h3><ol><li><strong>Increased Complexity</strong> — Service discovery, gateways, configs — more moving parts.</li><li><strong>Network Latency</strong> — Multiple API calls replaced in-process function calls.</li><li><strong>Data Consistency</strong> — Distributed transactions were tricky; we moved towards eventual consistency.</li><li><strong>DevOps Overhead</strong> — CI/CD pipelines, container orchestration, and monitoring became must-haves.</li></ol><h3>When Monolithic is Still Better</h3><p>Microservices are not the magic answer for every project.<br>Stick with monolith if:</p><ul><li>You’re a small startup or team</li><li>Your application is simple and doesn’t require heavy scaling</li><li>You want to prototype fast</li><li>You don’t have the DevOps resources for distributed systems</li></ul><h3>Lessons Learned</h3><ul><li><strong>Start small</strong> — carve out the most isolated module first.</li><li><strong>Sync data during migration</strong> — dual writes saved us from inconsistencies.</li><li><strong>Invest in monitoring early</strong> — flying blind in microservices is dangerous.</li><li><strong>Expect a mindset shift</strong> — microservices require teams to own their services end-to-end.</li></ul><h3>Final Thoughts</h3><p>Migrating from a PHP monolith to Spring Boot microservices transformed our system’s scalability, resilience, and deployment speed. But it came with its share of complexity and cultural change.</p><p><strong>Microservices are a trade-off</strong> — they shine in the right context, but can slow you down if adopted prematurely.</p><p>If you’re planning a migration, remember:</p><blockquote><em>“Don’t move to microservices because it’s trendy — move because your system truly demands it.”</em></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=94083e84c019" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Solving a MongoDB Outage in Production: From Downtime to Performance Win]]></title>
            <link>https://medium.com/@riyasnegi12/solving-a-mongodb-outage-in-production-from-downtime-to-performance-win-df571ffc8850?source=rss-64118db8a09d------2</link>
            <guid isPermaLink="false">https://medium.com/p/df571ffc8850</guid>
            <category><![CDATA[mongodb]]></category>
            <category><![CDATA[database]]></category>
            <category><![CDATA[production-issue]]></category>
            <category><![CDATA[performance-management]]></category>
            <category><![CDATA[indexing]]></category>
            <dc:creator><![CDATA[Riya Negi]]></dc:creator>
            <pubDate>Wed, 07 May 2025 06:06:15 GMT</pubDate>
            <atom:updated>2025-05-07T06:22:59.484Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*5TO_xsRHhj82SCyF" /></figure><h3>Introduction 🚨</h3><p>Imagine this: your application usage spikes, but instead of scaling gracefully, your database starts to choke, leading to <strong>downtime</strong> and <strong>revenue loss</strong>. That’s exactly what we faced in our production environment running on <strong>MongoDB Atlas</strong>. The database would scale from <strong>M30</strong> to <strong>M50 or M60 tiers</strong> to handle the load — but that came with a heavy <strong>cost per hour</strong>.</p><p>This is the story of how we <strong>diagnosed and fixed a recurring MongoDB outage</strong> using techniques like <strong>query optimization</strong>, <strong>indexing</strong>, <strong>purging</strong>, and <strong>log analysis</strong> — and in the process, saved both <strong>time and money</strong>.</p><h3>System Architecture: A Quick Overview 🧠</h3><p>MongoDB Cluster with 3 nodes:<br>🟢 1 Primary — handles all writes<br>🟡 2 Secondaries — used for reads<br>Hosted on MongoDB Atlas, initially on the M30 tier<br>Encountered downtime during high-demand periods</p><h3>The Problem ⚠️</h3><p>Every time client traffic spiked:<br>1. API latency increased<br>2. MongoDB’s CPU usage exceeded 90%<br>3. Auto-scaling kicked in, jumping to M50 or M60 tiers</p><p>💸 Result: huge infrastructure cost + revenue loss. Clearly, a <strong>band-aid solution</strong> wasn’t enough. We needed a permanent fix!</p><h3>Diagnosis🔍</h3><p><strong>Step 1: Performance Monitoring with MongoDB Atlas</strong></p><p>MongoDB Atlas provides a visual dashboard that helped us identify which collections had:</p><ol><li>Unindexed queries.</li><li>More query execution times.</li><li>More disk and memory consumption patterns.</li></ol><p><strong>Step 2:</strong> <strong>Reading Logs and Analyzing Slow Queries</strong></p><p>We started by analyzing MongoDB logs to identify bottlenecks. Logs pointed us to:</p><ol><li><strong>Collections with slow queries</strong> performing full collection scans</li><li><strong>High replication lag</strong></li></ol><p><strong>Step 3: Data Purging &amp; Archiving</strong></p><p>Collections with millions of documents and no cleanup strategy led to slower response time.</p><h3>Solutions</h3><h3>1. Indexing: Speeding Up Searches</h3><p><strong>What is Indexing?</strong><br>Think of a MongoDB index like the index at the front of a book. Instead of flipping through every page, you can jump directly to the information you need. Similarly, indexes let MongoDB find relevant documents faster, instead of scanning the entire collection.</p><p><strong>What We Did:</strong></p><ul><li>Used <strong>MongoDB Atlas Performance Advisor</strong>, which helped identify the slow queries and suggested columns that lacked indexes.</li><li>Created <strong>single-field indexes</strong> (e.g., on userId, createdAt) and <strong>compound indexes</strong> (e.g., on { vehicleId, timestamp }) to significantly reduce the query execution time.</li><li>Continuously monitored query patterns to ensure index effectiveness and avoid unused index bloat.</li></ul><blockquote><em>✅ </em>Result: Reduced response times and CPU load, particularly during peak traffic.</blockquote><h3>2. Query Optimization with Aggregation</h3><p><strong>What is Aggregation?</strong><br>Aggregation in MongoDB is like a <strong>data pipeline</strong>, where documents are processed step-by-step (stages like $match, $group, $project, $sort). It lets you perform real-time analytics, transformation, and summarization efficiently.</p><p><strong>What We Did:</strong></p><ul><li>Replaced multiple small queries with a <strong>single, optimized aggregation pipeline</strong>.</li><li>Avoided unnecessary recalculations by caching pre-aggregated results.</li><li>For dashboards: Instead of aggregating the <strong>entire data daily</strong>, we stored <strong>pre-calculated results</strong> for previous days then fetched and added only the <strong>delta (today’s data)</strong> to update the dashboard.</li></ul><blockquote><em>✅ </em>Result: Huge improvement in dashboard load speed and massive savings in query cost.</blockquote><h3>3. Purging: Clean the Clutter</h3><p><strong>What is Purging?</strong><br> Purging is the deletion of obsolete or temporary data, which helps maintain database performance and reduce storage costs.</p><p><strong>What We Did:</strong></p><ul><li>Wrote <strong>Python scripts</strong> to purge:</li></ul><p>i. OTP collections daily (data older than 24 hours).</p><p>ii. Temporary tokens or session data periodically.</p><p>iii. Set up <strong>cron jobs</strong> to automate purging tasks at regular intervals.</p><blockquote><em>✅ </em>Result: Reduced collection sizes and improved index efficiency.</blockquote><h3>4. Archiving: Store, Don’t Hoard</h3><p><strong>What is Archiving?</strong><br> Archiving is the process of moving inactive data (still valuable for reporting or compliance) to cold storage.</p><p><strong>What We Did:</strong></p><ul><li>Implemented a <strong>data retention policy</strong>:</li><li>Battery swap history older than 6 months.</li><li>Transaction and usage logs older than 1 year.</li><li>Used mongoexport to move data to <strong>AWS S3</strong> or other archival services.</li><li>Cleared archived records from the live DB to reduce overhead.</li></ul><blockquote><em>✅ </em>Result: Reduced data footprint and improved long-term maintainability.</blockquote><h3>🧾 Lessons Learned</h3><ol><li><strong>Indexing is non-negotiable:</strong> Regularly monitor queries using MongoDB Atlas and ensure proper indexing.</li><li><strong>Don’t wait to archive:</strong> Implement data retention early to avoid last-minute performance fire-fighting.</li><li><strong>Replica lag can bite:</strong> It’s not just a stat — laggy secondaries can serve stale data, affecting user experience.</li><li><strong>Aggregation is powerful:</strong> A well-structured aggregation pipeline can replace multiple costly queries.</li><li><strong>Automation is key:</strong> Cron jobs for purging and archiving saved us from manual intervention and potential human errors.</li><li><strong>Design for scale:</strong> Pre-calculate wherever possible, especially for high-load dashboards.</li></ol><h3>Conclusion 💬</h3><p>Production issues are stressful, but they teach you a lot more than theoretical knowledge ever could. Solving this MongoDB outage gave me deeper insights into performance tuning, data management, and the importance of proactive monitoring.</p><p>If you’re managing a MongoDB-based system, I hope this guide helps you identify red flags early and take the right actions.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=df571ffc8850" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>