<?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 Tilakraj Desai on Medium]]></title>
        <description><![CDATA[Stories by Tilakraj Desai on Medium]]></description>
        <link>https://medium.com/@tilakraj.desai?source=rss-beb8923f15f2------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*fbQf8OB3L_G_LBREJZVN8A.jpeg</url>
            <title>Stories by Tilakraj Desai on Medium</title>
            <link>https://medium.com/@tilakraj.desai?source=rss-beb8923f15f2------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 19:51:34 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@tilakraj.desai/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[Breaking the Metrics Ceiling: Zepto’s Observability Evolution with Mimir]]></title>
            <link>https://blog.zepto.com/breaking-the-metrics-ceiling-zeptos-observability-evolution-with-mimir-18718c446670?source=rss-beb8923f15f2------2</link>
            <guid isPermaLink="false">https://medium.com/p/18718c446670</guid>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[prometheus]]></category>
            <category><![CDATA[observability]]></category>
            <category><![CDATA[site-reliability-engineer]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Tilakraj Desai]]></dc:creator>
            <pubDate>Tue, 29 Apr 2025 12:44:31 GMT</pubDate>
            <atom:updated>2025-04-29T18:50:25.774Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XloZGGaOs1YopsBOilQQZQ.png" /></figure><p>At Zepto, reliable and scalable observability is crucial for maintaining our fast-paced operations. Our existing monitoring system, built on Prometheus with a <a href="https://thanos.io/"><strong>Thanos</strong></a> sidecar, began facing significant challenges as our infrastructure and service landscape grew. To ensure stability and gain deeper insights, we embarked on a journey to build a new, robust metrics platform from the ground up. This blog details why we needed a change, how we chose Grafana <a href="https://grafana.com/docs/mimir/latest/"><strong>Mimir</strong></a> as our long-term solution, and the key technical hurdles we overcame in migrating from our previous setup to a highly scalable, multi-tenant architecture. We’ll cover the problems we faced, our evaluation process, the unexpected challenges during migration, and the solutions we engineered.</p><ul><li><strong>Problem Statement: </strong>Replacing a struggling Prometheus+Thanos setup with a horizontally scalable, multi-tenant metrics backend using Grafana Mimir.</li><li><strong>Motivation:</strong> We want to overcome reliability issues (OOM kills, slow queries, alerting failures) and management overhead with the existing setup.</li><li><strong>Objectives:</strong> Achieve high scalability, maintain Prometheus API compatibility for consumers, zero impact on developers’ experience during migration, and implement effective multi-tenancy for better governance.</li></ul><h4><strong>Problem Definition</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XXmIDq5RoaQckR1WiWx0uQ.png" /><figcaption>Previous setup with prometheus and Thanos sidecar</figcaption></figure><p>Our initial monitoring stack consisted of High Availability (HA) <a href="https://prometheus.io/"><strong>Prometheus</strong></a> instances scraping metrics from infrastructure components (every 30s) and end-user application microservices (every 5–20s). On average, we had <strong>8–9 million active series </strong>which when combined with a high frequency of scrapes resulted in a very high sample ingestion rate. Compounded by the HA setup (duplicate data streams), this put immense pressure on the overall setup.</p><p>At the same time, forecasts suggested that we would grow to<strong> 60 million</strong> active series within <strong>a year</strong>. Our system was already showing signs of strain — average read latencies were consistently well above<strong> 2 seconds</strong>, and query failure rates had climbed to over <strong>5%</strong>.</p><p>We encountered several critical issues:</p><ul><li><strong>Memory Spikes &amp; OOM Kills:</strong> Prometheus instances occasionally crashed due to Out-Of-Memory errors, even with a significant memory of 180GB and relatively short retention (6 hours).</li><li><strong>Slow Queries:</strong> Querying metrics data was sluggish due to the single, large index per Prometheus instance.</li><li><strong>Alerting System Outages:</strong> The instability caused short-lived outages in our alerting systems, undermining their primary purpose.</li><li><strong>Slow Recovery:</strong> Recovering failed Prometheus instances was time-consuming due to slow Write-Ahead Log (WAL) replays, which required us to have multiple <a href="https://prometheus.io/"><strong>Prometheus</strong></a> replicas for change deployments and HA.</li><li><strong>Impact on Automation and Scaling:</strong> Failures in the metrics system also risk scaling critical components like gateways and disrupting important automation workflows.</li></ul><p>These problems created significant reliability concerns, not just for the observability platform itself, but for the core services that depended on timely alerts.</p><h4><strong>Tenets Of The Solution</strong></h4><p>Several factors shaped our approach:</p><ul><li><strong>Scale &amp; Load:</strong> We needed a solution capable of handling our current high ingestion rate while preparing for future growth.</li><li><strong>HA Data Streams:</strong> High availability for our observability setup is non-negotiable. The solution must simplify and make the setup more reliable, avoiding any redundancy of components.</li><li><strong>Tenancy based on namespaces:</strong> At Zepto, namespaces were structured around teams to allow team-specific control. Out-of-the-box capability for similar segregation and control at the application layer is a must.</li><li><strong>Prometheus Compatibility:</strong> Maintaining compatibility with Prometheus APIs was essential for a seamless migration for existing consumers (dashboards, alerts) while ensuring minimal intervention in developers’ workflows.</li></ul><h4><strong>Proposed Solution</strong></h4><p>After evaluating options like VictoriaMetrics, Thanos Receiver architecture, and Grafana Mimir, we selected Mimir as our strategic, long-term metrics datastore as it meets all of our core tenets while providing granular controls at the ingestion layer and supporting object store as a long-term storage solution.</p><p>We conducted extensive load testing to validate Mimir’s capabilities, simulating up to<strong> 350 million</strong> active series and over <strong>2GB/s</strong> ingestion for 24 hours using the <a href="https://github.com/prometheus-community/avalanche"><strong>Avalanche</strong></a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ukdw9Y2mvFhsoG-qjd0k0Q.png" /><figcaption><strong>Network stats during loadtest</strong></figcaption></figure><figure><img alt="Active series count during load test" src="https://cdn-images-1.medium.com/max/1024/1*oW1FZkjDRU9Z2pnSvHH5oA.png" /><figcaption><strong>Active series during loadtest</strong></figcaption></figure><p>Confident in its performance, we planned our migration to Mimir.</p><p><strong>Migration Strategy</strong></p><ol><li><strong>Existing Prometheus (Temporary):</strong> We continued running our HA Prometheus instances but reduced their retention period to 2 hours and block duration to 30 minutes. They would act as the source, writing data to Mimir.</li><li><strong>Grafana Mimir Cluster:</strong> Deployed a Mimir cluster configured for namespace-based multi-tenancy.</li><li><strong>Remote Write Configuration:</strong> Configured Prometheus to remote-write metrics to Mimir, initially creating a dual-source setup for data validation.</li></ol><p>This setup allowed us to compare the old and new systems&#39; data and ensure consistency during the transition.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*M8_QaWbowIGBxp0ylq1jcQ.png" /><figcaption><strong>HLD Mimir as Platform</strong></figcaption></figure><h4>Key Challenges Faced (Part 1)<strong>: The OOM kills</strong></h4><p>We began the migration by configuring approximately 30 namespace-based remote write rules in Prometheus. Almost immediately, we hit two critical issues:</p><ol><li><strong>Prometheus Memory Spikes:</strong> The multiple remote write configurations, likely involving regex filtering for namespace routing, caused severe memory pressure on the Prometheus instances, leading to OOM kills.</li><li><strong>Inflated Mimir Ingestion:</strong> The sample ingestion rate observed in Mimir was nearly double what we anticipated during capacity planning which resulted in CPU/Memory pressure in the Mimir write path.</li></ol><p>This combination resulted in an outage as both our HA Prometheus instances were OOM killed simultaneously.</p><p>We found an open-source tool, <a href="https://github.com/blind-oracle/cortex-tenant"><strong>cortex-tenant</strong></a>, for the Prometheus memory issue caused by complex filtering. Instead of relying on potentially heavy regex filtering within Prometheus, <a href="https://github.com/blind-oracle/cortex-tenant"><strong>cortex-tenant</strong></a> efficiently extracts labels from metric samples and adds the necessary tenant information, significantly reducing Prometheus’s overhead.</p><p>The root cause for the doubled ingestion was straightforward: Mimir wasn’t deduplicating samples from the HA Prometheus replicas by default. We resolved this by enabling Mimir’s <strong>HA Tracker feature.</strong></p><p>With the HA deduplication and <a href="https://github.com/blind-oracle/cortex-tenant"><strong>cortex-tenant</strong></a> in place, we stabilized the dual-write setup. We monitored data consistency between Prometheus and Mimir for seven days. The results looked good, giving us the confidence to proceed with migrating consumers, starting with alerts.</p><p><strong>Key Challenges Faced(Part 2): Query Fanout Problem</strong></p><p>As we replicated our alerting rules onto Mimir, we encountered a new wave of problems. Mimir components like ingesters, distributors, and queriers started experiencing high latency and OOM kills. Despite tuning various configurations, the issue persisted.</p><p>A detailed Root Cause Analysis (RCA) revealed an unintended consequence of our multi-tenancy approach combined with federated queries. Alert queries, especially those needing a global view, were performing a <strong>fanout</strong>, querying across <em>all</em> tenant TSDBs within Mimir. This generated a massive, unnecessary load.</p><p>The easiest fix would have been reverting to a single-tenant Mimir setup or working with developers to add tenants in every query both of which seemed unpractical.</p><p>Our solution was to automate this which led us to build our very own <strong>custom tenant injector</strong>. This service runs periodically (every 12 hours), analyzes alert rules, and injects the specific tenant IDs required for each query. This prevents the inefficient fanout by directing queries only to the necessary tenant TSDBs. For federated alerts requiring data from multiple namespaces, it intelligently adds multiple tenant IDs to the same query. In the future, we plan to open-source our custom tenant injector to benefit the broader community.</p><h4><strong>Lessons Learned</strong></h4><p>This journey from a struggling legacy system to a scalable Mimir platform taught us several valuable lessons:</p><ul><li><strong>Explicit HA Handling:</strong> Distributed systems often require explicit configuration for HA scenarios, like Mimir’s HA Tracker for deduplication. Don’t assume it’s automatic.</li><li><strong>Multi-tenancy Complexity:</strong> While powerful, multi-tenancy adds complexity, especially in query patterns. Naive “query all” approaches can be detrimental to performance. Careful design and targeted querying are essential.</li><li><strong>Bridging Gaps with Custom Tooling:</strong> Sometimes, off-the-shelf solutions need augmentation. Our custom tenant injector was crucial for making multi-tenant alerting viable in our specific context.</li><li><strong>Phased Rollouts are Key:</strong> The dual-write phase and gradual migration of consumers (like alerts) were critical for identifying and resolving issues incrementally without major disruption.</li><li><strong>Load Testing Limitations:</strong> While essential, load testing primarily validated ingestion and basic query paths. Complex operational query patterns, like our alert fanout, only surfaced during real-world usage.</li></ul><figure><img alt="Reduced Average latencies" src="https://cdn-images-1.medium.com/max/1024/1*jHOl1giIxmnoOB5ZkIxuoQ.png" /><figcaption><strong>Average latencies</strong></figcaption></figure><h4>Conclusion</h4><p>Today, our Mimir-based metrics platform is live at full scale and handles significantly more load than our initial setup, peaking at over <strong>40 million active series</strong> and ingestions of up to <strong>2 million samples per second</strong>.</p><p>Average <strong>write latencies</strong> are under <strong>5ms</strong>, and average<strong> read latencies </strong>are under <strong>400ms</strong> for both instant and range queries while reducing the overall query failure rate to less than <strong>0.1%</strong>.</p><p>This project has successfully addressed our initial reliability and scalability challenges, providing Zepto with a robust foundation for observability for years to come.</p><p>Want to dive deeper or have questions about our setup? Drop a comment or reach out — we’d love to chat!</p><p><strong><em>We are Zepto, We move fast…</em></strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=18718c446670" width="1" height="1" alt=""><hr><p><a href="https://blog.zepto.com/breaking-the-metrics-ceiling-zeptos-observability-evolution-with-mimir-18718c446670">Breaking the Metrics Ceiling: Zepto’s Observability Evolution with Mimir</a> was originally published in <a href="https://blog.zepto.com/">Zepto TechXPress</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>