Context
Walmart is the world’s largest retailer, with thousands of stores, hundreds of distribution centers of varying types and a fast-growing e-commerce business. Shopping is no longer just the physical store: customers search in the app, buy on the site, pick up in store or get home delivery, and expect the product to be available on any of those paths.
To support that, the company needs an up-to-date snapshot of every item’s inventory position at every location, at all times. Walmart’s engineering solved this at scale with a real-time inventory system based on event streaming with Apache Kafka, described publicly by then director of engineering Suman Pattnaik.
The problem
Inventory and replenishment were batch processes. Stock position was recomputed in cycles, and store replenishment was planned on that stale snapshot. With more than ten event sources changing inventory (sales, receipts, returns, transfers, adjustments), each store’s view arrived hours after the fact, causing stock-outs on some items and excess on others.
There was also the integration challenge: each source had its own format and came from different systems. Without a common model, every new consumer of inventory information had to understand all the origins.
The solution
Walmart designed a real-time inventory system on Kafka with a transformation engine at its center: it reads events from several source topics and converts them into a canonical inventory model, with item, store, quantity and event type. Kafka Streams holds the aggregated stock-position state, and connectors deliver the result to Apache Cassandra and other stores consumed by applications.
Sizing was part of the design. Since each Kafka partition is read by a single consumer within a group, the number of consumers must track the number of partitions to reach the required parallelism. The real-time replenishment system was built on the same event base, with a set of high-throughput processors that generate the order plan for the entire store network.
Results
The inventory system ingests around 500 million events a day and processes 1 million online transactions so stores do not run out of the items customers are looking for. The replenishment system processes tens of billions of messages from nearly 100 million SKUs in under 3 hours a day, at throughput above 85 GB of messages per minute, generating the order plan accurately for the whole network.
In 2022 Walmart was recognized at the Data Streaming Awards for moving batch inventory and replenishment to real time at scale. In the company’s words, the investment in event streaming with Confluent contributed to business innovation and to the company’s growth.
What this means for your team
The design applies to any multichannel retailer, from large supermarkets to pharmacy chains: a canonical inventory event model, an engine that translates every origin into that model and the right partition count for consumer parallelism. It is the same pattern we apply in our retail case.
The business lesson is that real-time inventory is not an IT project: it decides whether the sale happens. When stock position is right, the site does not offer what it lacks and the store does not lose the sale for want of replenishment.