How RocketMQ Cut Costs and Stabilized Alibaba Logistics During Double‑11
Facing soaring order peaks each Double‑11, Alibaba's logistics arm re‑engineered its architecture with RocketMQ, using asynchronous decoupling to handle payment‑order traffic, dramatically reduce hardware spend, and keep logistics QPS stable without sacrificing user experience.
Background
Alibaba's logistics platform was originally built as a tightly coupled extension of the e‑commerce system. During Double‑11 events the order‑creation peak grew from 180,000 orders/s in 2015 to 300,000 orders/s in 2016. The logistics side, which mainly handles physical shipment, does not need to scale with the same peak, but the shared architecture forced it to provision hardware for the highest transaction spikes, leading to excessive cost.
Why RocketMQ?
Traditional relational databases and Redis could not provide the required asynchronous decoupling and rate‑controlled consumption. RocketMQ, Alibaba’s internally‑used distributed messaging middleware, offers:
High‑throughput, durable message storage (supporting billions of messages).
Fine‑grained consumption control via SDKs (e.g., per‑consumer flow control).
Built‑in support for pull‑based consumers, message batching, and back‑pressure handling.
These features make RocketMQ suitable for smoothing traffic spikes between the order‑creation service and the logistics order center.
Architecture and Implementation
The solution inserts a RocketMQ cluster between the order‑creation service (producer) and the logistics order center (consumer). The key steps are:
Deploy RocketMQ cluster : launch a NameServer and a set of broker nodes with sufficient storage and network bandwidth.
Define topic : create a topic (e.g., order_payment) with appropriate partition count to match the expected throughput.
Producer integration : modify the order‑creation service to publish a message for each successful payment using the RocketMQ Java/Python SDK.
Consumer with throttling : implement a pull consumer in the logistics order center that limits the consumption rate to a safe level (e.g., 80,000 messages/s). This can be achieved by configuring pullThresholdForQueue, consumeMessageBatchMaxSize, and applying a sleep or token‑bucket algorithm after each batch.
Monitoring and alerting : track lag (messages pending in the broker) and QPS using RocketMQ’s built‑in metrics or external monitoring tools (Prometheus, Grafana).
Example consumer configuration (Java SDK):
DefaultMQPullConsumer consumer = new DefaultMQPullConsumer("logistics_consumer");
consumer.setNamesrvAddr("mq-nameserver:9876");
consumer.start();
while (true) {
PullResult pullResult = consumer.pullBlockIfNotFound("order_payment", "*", offset, 1000);
List<MessageExt> msgs = pullResult.getMsgFoundList();
// Process messages in batches
process(msgs);
// Simple rate‑limit: sleep to keep ~80k msgs/s
Thread.sleep(12); // adjust based on batch size
offset = pullResult.getNextBeginOffset();
}Results
During the 2016 Double‑11 event the order‑creation peak reached 500,000 messages/s for 20 minutes. The logistics consumer, limited to 80,000 messages/s, processed the entire backlog within two hours without any visible delay to end users. This decoupling eliminated the need to provision logistics‑specific hardware for peak traffic, reducing both capital and operational expenses.
After two months of development, testing, and staged rollout, the logistics platform maintained a stable QPS even as overall order peaks grew fourfold in subsequent years. The architecture also lowered the risk of synchronous failures caused by tight coupling between transaction and logistics services.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
ITPUB
Official ITPUB account sharing technical insights, community news, and exciting events.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
