How Amazon Handles Millions of Orders on Sale Day - The Engineering Behind It
It's Amazon Great Indian Sale. Midnight strikes. Millions of people hit refresh simultaneously. Your internet slows down. The app feels laggy. You're frantically trying to add that phone to your cart before it goes out of stock. And somehow Amazon doesn't crash. Millions of orders. Milliseconds apart. Payments processing. Inventory updating. Warehouses getting notified. Delivery partners being…
Amazon's Great Indian Sale is a monumental event where millions of people attempt to purchase items all at once. This overwhelming demand places immense pressure on Amazon's systems to process orders, payments, and inventory updates simultaneously. In this report, we explore how Amazon handles this massive task through its unique engineering solutions.
Amazon Prime Day 2024 witnessed over 200 million items sold in just 48 hours, translating to approximately 1.4 million items per minute and 23,000 items per second at peak times. Each order involves multiple critical steps, including inventory checks, payment processing, stock updates, warehouse notifications, delivery scheduling, confirmation emails, and updating the seller dashboard.
At a rate of 23,000 orders per second, a normal web application would quickly become a bottleneck, leading to potential crashes and downtime.
To avoid these catastrophic failures, Amazon utilizes a robust microservices architecture. Rather than relying on a single large application, Amazon breaks down its system into hundreds of small, independent services. Each service has a specific function, such as managing inventory, creating orders, processing payments, sending notifications, handling recommendations, and facilitating search queries.
By running these services independently, each can scale according to its needs, ensuring that a failure in one service does not bring down the entire system.
One of the key challenges Amazon faces during sale day is the cart problem. When a user adds an item to their cart, Amazon uses the concept of eventual consistency. This means that the addition of an item to the cart is instantaneous and always successful. However, the real inventory check occurs at checkout when the user proceeds to pay. This approach allows for faster browsing experiences for millions of users during peak times, as the initial cart addition does not rely on live inventory data.
To ensure that orders are not lost during the processing, Amazon employs message queues. When an order is placed, it is placed into a queue rather than being processed synchronously. Users receive immediate confirmation of their order, while the system works in the background to handle various aspects, such as warehouse notifications, payment processing, email confirmations, and more.
Each step in the queue is processed in order, ensuring that no orders are overlooked or skipped. If one service is temporarily slow, the queue holds the work until that service catches up, preventing any loss of orders.
Another critical aspect of Amazon's architecture is database sharding. A single database cannot handle millions of reads and writes per second during a sale event. To address this, Amazon divides its databases into smaller pieces called shards. Each shard contains a portion of the products, such as electronics, clothing, or books.
When a user checks the stock for a specific item, only the relevant shard for that category is queried. This distribution of the load across multiple shards prevents any single database from becoming overwhelmed and ensures smooth operation during high traffic periods.
To provide fast loading times for users, Amazon utilizes Content Delivery Networks (CDNs). When a user accesses Amazon, product images, CSS files, and JavaScript are not fetched from the main servers in Mumbai and Chennai. Instead, they are retrieved from the nearest edge location in the CDN. These edge locations are strategically placed across India and the world, minimizing the physical distance between the user and the server.
This proximity significantly reduces latency and speeds up the loading of Amazon's website for users worldwide.
Amazon's payment processing system is another crucial component that must remain flawless during sale day. When a user clicks "Pay Now," the payment is routed through a highly available system with multiple payment processors on standby. If one payment processor fails, another takes its place instantly, ensuring uninterrupted processing.
The payment data is encrypted end-to-end, adhering to the strictest security standards, such as PCI DSS, to protect user information. Additionally, transactions are designed to be idempotent, meaning that if a user accidentally clicks "Pay" twice, the second click is recognized as a duplicate, and only a single payment is processed.
Lastly, Amazon's warehouses play a vital role in fulfilling orders placed during sale day. The company employs various technologies to optimize the fulfillment process. Kiva robots move entire shelves of products to human pickers, reducing the time workers spend searching for items. Computer vision systems identify products, verify their accuracy, and check for any damages.
Conveyor systems automatically sort packages and route them to the appropriate shipping carriers. Real-time tracking technology enables users to monitor the status of their orders, from "Out for Delivery" notifications to updates on delivery status, all through their mobile devices.
In summary, Amazon's ability to handle millions of orders during its Great Indian Sale is a testament to its innovative engineering solutions. By leveraging microservices architecture, eventual consistency, message queues, database sharding, content delivery networks, secure payment processing, and advanced warehouse automation, Amazon can efficiently process orders, payments, and inventory updates simultaneously.
These strategies ensure that even during peak times, when millions of users attempt to purchase items simultaneously, the Amazon system remains robust, scalable, and reliable, delivering a seamless shopping experience to customers around the world.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.