Asynchronous Refactoring of JD Retail Shopping Cart Service for Performance Improvement

This article details how JD's retail shopping‑cart team tackled growing business complexity by fully converting the cart service to an asynchronous architecture, addressing challenges such as increasing RPC dependencies, pagination, and resource costs, and achieving a 30% reduction in core interface latency.

JD Tech
JD Tech
JD Tech
Asynchronous Refactoring of JD Retail Shopping Cart Service for Performance Improvement

The shopping‑cart service faced several challenges: new business features increasing external RPC calls, interface sinking to the cart middle‑platform, pre‑checkout processes (coupons, JD beans) moving to the cart, and expanding capacity that raised the number of items handled.

To improve performance without adding server resources, the team adopted a full asynchronous refactor. The solution includes three key techniques:

Parallelizing independent RPC calls to reduce waiting time.

Batching and parallelizing multi‑page requests, using an asynchronous pagination tool that splits large data sets into parallel pages.

Leveraging JD's RPC framework JSF (version 1.7.5+) which supports CompletableFuture for async calls.

During implementation, several detailed problems were solved:

Fine‑grained retry logic: Asynchronous calls require retry handling after a timeout is detected in the result‑processing stage, and only the failed page should be retried.

Complex async RPC monitoring: Separate timing for RPC start and async result arrival, with distinct metrics for normal and retry calls, and additional monitoring of the result‑processing (Get) latency.

Preserving pagination results: Async results must be returned unchanged in wrapper objects to retain provider information for timeout diagnostics.

Per‑page timeout control: Each page’s timeout is calculated as

timeout = RPC_TIMEOUT > (now - async_start) ? RPC_TIMEOUT - (now - async_start) : 0

, ensuring the overall wait does not exceed the RPC limit.

Page load balancing: Data is evenly distributed across pages to avoid skewed final pages.

After the refactor, core cart interface latency decreased by about 30%, improving user experience while saving significant server resources; additional RPC interfaces added later have minimal impact as long as they stay off the critical path.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

BackendperformanceRPCAsynchronous
JD Tech
Written by

JD Tech

Official JD technology sharing platform. All the cutting‑edge JD tech, innovative insights, and open‑source solutions you’re looking for, all in one place.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.