How We Built a Scalable Pricing Engine for E‑commerce Promotions

This article explains the design and implementation of a modular, configurable pricing engine that handles real‑time and simulated price calculations for complex e‑commerce promotions, addressing rule fragmentation, extensibility, priority conflicts, and transaction‑level precision while ensuring high performance and reliability.

Yanxuan Tech Team
Yanxuan Tech Team
Yanxuan Tech Team
How We Built a Scalable Pricing Engine for E‑commerce Promotions

1. Background

Product price calculation in promotional pricing systems depends on user identity, assets, applicable activities, coupons, and red packets, affecting the final payment price in transaction scenarios (cart, checkout, order) and the estimated price in browsing scenarios (detail page, list).

As the business and channels expand, activity rules become increasingly diverse, making the original pricing system unable to support new play‑styles quickly, necessitating an independent pricing service decoupled from transaction and mall logic.

2. Challenges and Solutions

The pricing needs fall into three categories: actual paid price, estimated price, and the lowest estimated price within a time window, requiring real‑time, forecast, and simulation capabilities.

2.1 Challenge: Inconsistent Activity Rules

Different business groups maintain activity rules, leading to divergent interpretations and calculation results.

Solution: Componentize activity calculations—encapsulate each activity as a black‑box component with standardized inputs and outputs.

2.2 Challenge: High Extensibility for Browsing Scenarios

New activities may need to be inserted at any point in the calculation chain, and priority adjustments are frequent.

Solution: Either hard‑code the global context and modify code for order changes, or make the calculation flow configurable by reading the order from a file, enabling rapid, code‑free adjustments.

2.3 Challenge: Activity Priority Matrix Conflicts

Activities can be mutually exclusive, and when multiple activities of equal priority apply, the lowest price must be chosen.

Solution: Configure mutual exclusivity per activity and select the optimal price among competing activities.

2.4 Challenge: Transaction‑Level Accuracy

Pricing in transaction scenarios is core logic involving user assets, requiring utmost precision to avoid losses.

Solution: Use multi‑level caching for hot activity data, monitor and alert risky calculations, and add component‑level downgrade mechanisms to ensure stability.

3. Birth of the Pricing Engine

The new pricing service aims to:

Rapidly extend new promotional play‑styles and remove activities without impact.

Adjust calculation order quickly.

Meet high RT and throughput requirements for browsing and ensure stability for transactions.

Improve development efficiency and reduce iteration side effects.

3.1 Implementation Details

Inspired by workflow engines, the solution adopts componentization, configurable pipelines, plug‑in capability, and scenario‑aware processing.

3.1.1 Pricing Pipeline

Each pipeline executes nodes sequentially; within a node, calculation units run in order. The node selects the highest‑priority result and discards non‑optimal snapshots.

3.1.2 Lane Processor

A lane represents a user identity over a time interval; the processor determines applicable activities for each lane and prepares time slices for calculation.

3.1.3 Driver

Real‑time calculation fetches current eligible discounts and feeds them to the pipeline; simulation first builds lanes for a time window, then processes each slice through the pipeline.

3.1.4 Configuration Management

Activity order and other orchestration info are stored in JSON files loaded at service startup, allowing runtime adjustments without code changes.

[
    [
        {
            "componentType": 1,
            "componentName": "Limited‑time Purchase Component",
            "conflictInfo": ["5"]
        },
        {
            "componentType": 2,
            "componentName": "Special Price Component"
        }
    ],
    [
        {
            "componentType": 3,
            "componentName": "N‑Yuan Choice Component"
        }
    ],
    [
        {
            "componentType": 4,
            "componentName": "Full‑store Threshold Discount Component"
        }
    ],
    [
        {
            "componentType": 5,
            "componentName": "Shipping Fee Component"
        }
    ]
]

3.1.5 Overall Design

The input adapter converts incoming parameters to engine inputs, the engine processes them, and the result adapter formats the output for external consumption.

4. Summary and Outlook

The new pricing engine now serves cart, order, and grouping scenarios in the platform.

Browsing scenarios (detail, list, recommendation) are being integrated and will support all site pages for the 2021 Double‑11 event.

Future articles will share concurrency, caching, and operational challenges encountered during rollout.

The promotion team will redesign activity rules and build a dedicated rule engine to further enhance the pricing system.

e-commercebackend architecturemicroservicespricing engineprice calculation
Yanxuan Tech Team
Written by

Yanxuan Tech Team

NetEase Yanxuan Tech Team shares e-commerce tech insights and quality finds for mindful living. This is the public portal for NetEase Yanxuan's technology and product teams, featuring weekly tech articles, team activities, and job postings.

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.