blog-banner

How LUSH optimized global inventory management with CockroachDB

Last edited on January 25, 2022

0 minute read

    Every day Lush processes hundreds of thousands of transactions in over 950 stores located across 49 different countries. Consistency is important. And inventory management can create extraordinary opportunities when the right tools are used to deliver real-time data insights.

    In this blog, we’ll cover what Lush’s inventory management architecture looked like before CockroachDB and what they’re able to accomplish with CockroachDB.

    Lush Architecture Prior to their Migration to CockroachDBCopy Icon

    If you haven’t already indulged in the fragrant self-care of a Lush bath bomb then you may not know that Lush Fresh Handmade Cosmetics is a global inventor, manufacturer and retailer of fresh handmade cosmetics - known for the quality of their ingredients and the environmental thoughtfulness of their packaging (or lack thereof).

    Prior to their migration to CockroachDB Lush’s database architecture was made up of MySQL instances in 20 of the countries in which the Lush Group operates. While this architecture was an integral part of the company as it grew globally, it created a lot of operational complexity. In particular, the disparate MySQL instances could not talk to each other, which made it difficult to optimize inventory or evaluate the company’s performance on a global scale.

    The Challenge of Disparate MySQL InstancesCopy Icon

    In this disparate MySQL instance architecture there is no easy way to immediately assess the performance of Lush’s products at global scale. The data needs to be located in the same system to make it easy to interrogate that data.

    The emergence of data protection laws and data localization regulations adds more challenges. As an international retailer that does business all over the globe, Lush is required to domicile some user data in particular countries. This is the cost of doing business on a global scale, and it has been incredibly tricky to accomplish.

    Lush wanted to simplify and modernize their data architecture in order to make it easier to analyze the company’s global performance, comply with local data regulations, and reduce operational complexity. Their requirements included:

    • High availability

    • Cloud neutral

    • Easy management of global user data

    • Source available

    • Standard SQL and simple insertion and extraction of data

    • A managed offering

    Migrating off Google Cloud SpannerCopy Icon

    Before eventually landing on CockroachDB Lush first turned from MySQL to Google Cloud Spanner in their early efforts to modernize their database. They quickly ran into a couple of problems:

    1. Cloud lock-in: Using Spanner locked Lush into the Google Cloud ecosystem. Even tasks like exporting data to CSV required use of Google products like exports to buckets.

    2. Blackbox: The lack of visibility into Spanner made it difficult for the engineering team to troubleshoot. Lush scaled to 10 nodes without issue, but they had to make that decision blind. Whereas with CockroachDB, they’re starting with 3 nodes and they can see everything that’s happening.

    3. Custom programming language: Spanner speaks a custom query language, rather than the standard SQL. This would require Lush’s engineering team, already versed in SQL, to learn a new programming language in order to program against Spanner.

    Because of these challenges Lush ultimately determined that Spanner was not the right solution and began evaluating alternatives. Their research led them to CockroachDB.

    How Lush Evaluated CockroachDBCopy Icon

    Lush began evaluating CockroachDB in 2017. Right out of the box CockroachDB met their most pressing requirements.

    To start, CockroachDB is a source available database with 100% visibility into the code. It uses standard SQL, making it easy for the Lush team to get up and running quickly.

    Being able to spin up a CockroachDB node locally with Docker in a matter of seconds allows Lush developers to learn by doing, which isn’t possible or as easy with other database technologies. The combination of Postgres language support in Go with the ease of getting started made for a seamless integration into Lush’s developer ecosystem.

    Lush also had exceptionally high availability requirements. As a global retailer that processes 165,000 financial transactions per day (in the UK), it was critical that their database be ultra-resilient and not have issues with outages or downtime. CockroachDB delivers zero RPO (recovery point objective) and an average of 4.5 second RTO (recovery time objective), ensuring that data is never lost and applications are highly available.

    Finally, Lush was seeking a managed database so that their engineering team could focus on application development, not on maintaining third-party software. When they began their evaluation in 2017, Managed CockroachDB was in development, and Lush became a design partner while CockroachDB Dedicated was brought to market.

    CockroachDB Workloads at LushCopy Icon

    Optimize Global Inventory and Order ManagementCopy Icon

    Lush plans to use CockroachDB for many different use cases, including as the system of record for all orders. The rollout will begin with all stores in the UK, of which there are over 100, and will expand to include all 950+ global stores.

    Lush will also be deploying CockroachDB as their stock management layer. This would give Lush a real-time view of global inventory, allowing them to see how much product they have in a particular store, in a particular country, and in the entire world – something they haven’t had visibility into before.

    Increased visibility into their inventory enables Lush to optimize the strategy with which they stock their stores. It allows them to avoid ever being understocked and to proactively take advantage of trends they see in particular regions.

    Analyze Global Business & Comply with RegulationsCopy Icon

    CockroachDB gives Lush a global view of all their data. At the same time, Lush can partition data to a particular region without losing the ability to access and analyze that data.

    What became particularly attractive to Lush is that they can configure their database before they decide where they need to geo-partition. They can then retroactively pick and choose where data is stored, satisfying both data sovereignty concerns and the need to have a global view of data. This is really powerful for Lush because it allows them to be strategic about how they handle (a very large data set) of product stock.

    Relieve Operational ManagementCopy Icon

    Reducing operational complexity is addition by subtraction. With CockroachDB, Lush no longer manages dozens of MySQL shards. CockroachDB’s ability to auto-rebalance, auto-recover from failures, and scale without manually sharding data relieves Lush’s engineering team of huge management overhead.

    As early users and design partners on CockroachDB Dedicated, Lush was able to reduce their operational management even further. This allows their developers to focus completely on application development without worrying about the underlying issues that surround distributed systems of any kind.

    Lush developers get time back because of what CockroachDB automates. This liberates developers to evaluate and use data to make good decisions.

    To learn more about CockroachDB workloads at Lush and other CockroachDB use cases check out our customers page.

    CockroachDB vs SpannerCopy Icon

    If you want to learn more about how CockroachDB compares with Google Cloud Spanner check out this video in which we cover four key differences between the two databases:

    Customer Stories
    case study
    customer
    spanner
    compliance
    latency
    retail
    ecommerce