MongoDB Inc.

12/17/2024 | News release | Distributed by Public on 12/16/2024 20:13

Commerce at Scale: Zepto Reduces Latency by 40% With MongoDB

Zepto is one of the fastest-growing Indian startups and a pioneer in introducing quick commerce to India. Quick commerce, sometimes referred to as "Q-commerce" is a new, faster form of e-commerce promising ultra-quick deliveries, typically in less than one hour.

Founded in July 2021, Zepto has revolutionized the Indian grocery delivery industry, offering users a choice of over 15,000 products with a promised 10-minute delivery. Since its launch, the company has rapidly expanded its operations, recording 20% monthly growth and achieving annualized sales of $1.5 billion by July 2024.

Zepto's order processing and delivery system is instrumental in meeting its promise to customers. Zepto's system routes new orders to a "dark store," where bleeding-edge assignment systems help pack orders in under 75 seconds. A proprietary navigation system ensures riders can then deliver these orders promptly.

As Zepto expanded, its monolithic infrastructure, based on a relational SQL database, could not achieve the scalability and operational efficiency the company needed. Zepto changed the game by turning to MongoDB Atlas.

Mayank Agarwal, Senior Architect at Zepto, shared the company's journey with MongoDB during a presentation at MongoDB.local Bengaluru in September 2024.

"We had a big monolith. All the components were being powered by PostgreSQL and a few Redis clusters," said Agarwal. "As our business was scaling, we were facing a lot of performance issues, as well as restrictions in terms of the velocity at which we wanted to operate."

Zepto's legacy architecture posed four key issues:

  • Performance bottlenecks: As Zepto grew, the need for complex database queries increased. These queries required multiple joins, which put a significant strain on the system, resulting in high CPU usage and an inability to provide customers and delivery partners with accurate data.

  • Latency: Zepto needed its API response times to be fast. However, as the system grew, background processing tasks slowed down. This led to delays and caused the system to serve stale data to customers.

  • A need for real-time analytics: Teams on the ground, such as packers and riders, required real-time insights on stock availability and performance metrics. Building an extract, transform, and load (ETL) pipeline for this was both time-consuming and resource-intensive.

  • Increased data scaling requirements: Zepto's data was growing exponentially. Managing it efficiently became increasingly difficult, especially when real-time archival and retrieval were required.

MongoDB Atlas meets Zepto's goals

"We wanted to break our monolith into microservices and move to a NoSQL database. But we wanted to evaluate multiple databases," said Agarwal.

Zepto was looking for a document database that would let its team query data even when the documents were structured in a nested fashion. The team also needed queryability on array-based attributes or columns.

MongoDB fulfilled both use cases. "Very optimally, we were able to do some [proofs of concept]. The queries were very performant, given the required indexes we had created, and that gave us confidence," said Agarwal. "The biggest motivation factor was when we saw that MongoDB provides in-memory caching, which could address our huge Redis cluster that we couldn't scale further."

Beyond scalability, MongoDB Atlas also provided high reliability and several built-in capabilities. That helped Zepto manage its infrastructure day to day, and create greater efficiencies for both its end users and its technical team.

Speaking alongside Agarwal at MongoDB.local Bengaluru, Kshitij Singh, Technical Lead for Zepto, explained: "When we discovered MongoDB Atlas, we saw that there were a lot of built-in features like the MongoDB chat support, which gave us very qualitative insights whenever we faced any issues. That was an awesome experience for us."

Data archival, sharding support, and real-time analytic capabilities were also key in helping the Zepto team improve operational efficiencies.

With MongoDB, Zepto was able to deploy new features more quickly. Data storage at the document level meant less management overhead and faster time to market for new capabilities.

Furthermore, MongoDB's archival feature made it easier for Zepto to manage large datasets. The feature also simplified the setup of secondary databases for ETL pipelines, reducing the heavy lifting for developers.

"You go on the MongoDB Atlas platform and can configure archival in just one click," said Singh.

Zepto reduces latency, handles six times more traffic, and more

The results of migrating to MongoDB Atlas were immediate and significant:

  • Zepto saw a 40% reduction in latency for some of its most critical APIs, which directly improved the customer experience.

  • Postmigration, Zepto's infrastructure could handle six times more traffic than before, without any degradation in performance. This scalability enabled the company to continue its rapid growth without bottlenecks.

  • Page load times improved by 14%, leading to higher conversion rates and increased sales.

  • MongoDB's support for analytical nodes helped Zepto segregate customer-facing workloads from internal queries. This ensured that customer performance was never compromised by internal reporting or analytics.

"MongoDB is helping us grow our business exponentially," said Agarwal at the end of his presentation.

Visit our product page to learn more about MongoDB Atlas.