Victoria’s Secret Turns to MongoDB to Migrate Billions of Documents with Zero Downtime

A young woman smiling while looking at her mobile phone.

INDUSTRY

Retail

PRODUCT

MongoDB Atlas Vector Search
MongoDB Atlas Online Archive
MongoDB Atlas Data Federation

USE CASE

Modernization
Migrations

CUSTOMER SINCE

2023

For specialty retailer Victoria’s Secret, running its global e-commerce brand meant managing terabytes of data across hundreds of on-premises databases. Victoria’s Secret processes thousands of transactions every day from customers around the world. With this volume of transaction activity, the retailer’s data platform comprises more than 2.5 billion documents. But as its business grew, the company found that its monolithic architecture was limited in flexibility. As a result, it faced rising costs and required significant operational maintenance, increasing the cognitive overhead for developers during database troubleshooting.

So the company began adopting microservices for its e-commerce solution using CouchDB, an open-source NoSQL database. Then, it migrated to Microsoft Azure, which worked with its existing operating system. But to ensure a fast transition, Victoria’s Secret performed a standard lift-and-shift migration without any significant changes to its infrastructure. That left it with the same overhead costs and operational challenges as before.

That’s when the company decided to transform its database architecture on MongoDB. With zero downtime, Victoria’s Secret migrated its entire e-commerce platform to MongoDB Atlas, which improved its overall performance, scalability, and cost efficiency.

Hemanth Kumar Vemula, Lead Platform Engineer at Victoria’s Secret, discusses how his team utilizes MongoDB Atlas during the .local Austin 2024 event.

Adopting cloud database technology

As it began transitioning to a microservices-based architecture, Victoria’s Secret initially adopted CouchDB because it was immediately compatible with the company’s virtual private cloud (VPC) operating system.

But during the standard lift-and-shift migration to Azure — which involves moving applications to the cloud without significant changes — the company carried over the existing deployment setup along with all its overhead and costs. This accelerated the migration but left the retailer with several limitations and most of its previous challenges. The CouchDB database lacked clustering and clustered indexing, which led to frequent data duplication, higher costs, and limited availability.

“Anytime you wanted to query a document or look up a shopping cart based on a customer’s email address, it was nearly impossible,” said Hemanth Kumar Vemula, Lead Platform Engineer at Victoria’s Secret. “We had close to 200 databases, and this was a cut-copy-paste architecture for all 200 databases.”

Victoria’s Secret wanted a solution that offered features not supported by CouchDB, such as database clustering, clustered indexing, vector search, and other native features, along with dedicated support. In 2023, Victoria’s Secret began migrating from CouchDB to MongoDB Atlas.

Migrating billions of documents to MongoDB

For the migration to be successful, it was critical to avoid downtime for Victoria’s Secret’s databases. “We could not take any database offline to migrate it,” said Vemula. The company needed to replicate data between CouchDB and MongoDB in both directions so that it could fall back to CouchDB if needed during the migration while also reflecting all changes in both locations.

To solve this, Victoria’s Secret used bidirectional replication. “We built a custom bidirectional replication system to facilitate the migration,” said Vemula. “In this process, we not only were able to migrate the data, but we also unlocked a few performance and scalability improvements that we didn’t have with CouchDB.”

A diagram showing the custom bidirectional replicator

A diagram showing the custom bidirectional replicator, which is designed to be aware of schema changes and ensure accurate data replication.

Victoria’s Secret started by sorting all 200 databases into five categories. Then it chose a few databases from each group to migrate. After finishing with each group of databases, the Victoria’s Secret engineering team adjusted the process to optimize it for the next group. In the end, the migration of all 200 databases took just four months.

Throughout the migration, the retailer distributed traffic between both versions of its database architecture, so some traffic went to the new MongoDB database while other requests went to CouchDB. Each time a database got a request, it would create a read-only note and replicate that change in the other database. The company ran four versions of its database code in parallel. As the application teams were making upstream changes, database engineers hot swapped the database interface and kept it synchronized with those updates.

To avoid throttling database performance when building indexes, Victoria’s Secret temporarily updated the maximum build memory use setting from the default of 200 megabytes to 1–2 gigabytes for any database larger than 500 gigabytes. This allowed the company to build more than one index at a time and test several at once. Victoria’s Secret also modified the operations log size to better manage local database size when migrating clusters larger than 200 gigabytes and built indexes after migrating.

“Precreating the indexes and then migrating the data made the entire migration process slower,” said Vemula. “So, we first migrated all the document assets, and then we started to build indexes.” Once it finished the migration, Victoria’s Secret scaled the capacity back down to what it needed for typical workloads.

The company also reduced the amount of energy, resources, and manual work its developers would have to do compared to CouchDB. “We built a wrapper on top of MongoDB that abstracts the cognitive complexity for our developers,” said Vemula.

Improving efficiency and performance for 200 databases

Victoria’s Secret tested its new architecture thoroughly using a similar method to its phased migration. “Performance testing and benchmarking every one of the more than 200 databases is not realistic,” said Vemula. “So, we went back to our five categories, picked one or two databases from each, and generated a synthetic load against it to test it on steady-state volumes.” The company set the load at double the previous year’s peak volume on CouchDB. Once it determined the ideal resource capacity, Victoria’s Secret applied that scaling logic to all the databases involved in similar workloads.

In all, the retailer migrated more than 4 terabytes of data across more than 200 databases with zero downtime. Victoria’s Secret reduced the number of disks that it provisions by 90%, and it reduced its disk hydration time for caching by 80%. In addition, the company reduced its total number of cores from 1,100 to 250. And it drastically reduced the amount of disk space it provisioned from 120 terabytes to just 8 terabytes.

On MongoDB, the company made further operational enhancements to optimize scalability and cost. It reduced CPU core use by 75% and achieved a 240% improvement in API performance. And the retailer has automated 100% of data backups with the backup scheduling feature of MongoDB Atlas.

“MongoDB and everything that comes with it was great. On MongoDB, we could automate our deployments and scalability monitoring, and we had advanced features like search charts and an online vector store that didn’t exist in the CouchDB ecosystem.”

Hemanth Kumar Vemula, Lead Platform Engineer, Victoria’s Secret.

Adopting additional MongoDB Atlas features

With its new data architecture on MongoDB, Victoria’s Secret has also begun onboarding more advanced features from MongoDB Atlas. For example, it created an interface to use MongoDB Atlas Vector Search, and it’s exploring additional capabilities, such as MongoDB Atlas Online Archive and MongoDB Atlas Data Federation.
Dive deeper into how MongoDB enables Victoria’s Secret &Co. to deliver fast, reliable, and personalized e-commerce experiences to each and every customer. Read their full Wall Street Journal profile now.

What will your story be?

MongoDB will help you find the best solution.