Backend Development 11 min read

Traffic Replay Technology in YouZan: Automated Regression Testing for Mid-Platform Marketing Business

YouZan’s traffic‑replay platform records real production calls and replays them in test environments—both read‑only and mock‑write modes—to automatically verify thousands of marketing interfaces, visualize scenario coverage, capture low‑traffic cases, and has already enabled zero post‑launch failures while guiding future expansion into deeper coverage and performance testing.

Youzan Coder
Youzan Coder
Youzan Coder
Traffic Replay Technology in YouZan: Automated Regression Testing for Mid-Platform Marketing Business

This article introduces traffic replay technology and its application at YouZan for automated regression testing during system refactoring and mid-platform transformation.

1. Traffic Replay Overview

Traffic replay is a crucial automated regression testing method used during system refactoring, splitting, and mid-platform migration. It works by recording real production traffic, replaying it in a specified environment, and comparing each call and sub-call difference to identify potential issues in interface code. Since production traffic is extensive and covers comprehensive scenarios, it effectively compensates for the limitations of manual test coverage assessment, reducing risks associated with rapid business iteration.

2. YouZan Traffic Replay Platform

YouZan's traffic replay platform is based on jvm-sandbox-repeater for secondary development. It uses AOP to non-intrusively record interface input parameters and return values during runtime. It can also record sub-call inputs and outputs, including Dubbo, MyBatis, Redis calls. This enables support for both read traffic replay and write traffic mock replay.

The platform operates in two modes:

Read Mode (Pre-environment non-mock replay):

Recording: Captures Dubbo entry requests and return values; uses MyBatis/HBase enhancement points to identify write operations and mark them.

Replay: Manages blacklist/whitelist interfaces, automatically supplements blacklist based on write operation flags, performs generalized Dubbo calls in pre-environment, compares results, identifies noise paths, and saves failed cases.

Write Mode (QA environment mock replay):

Recording: Generates unique trace IDs for requests, records request/response at each enhancement point, serializes and sends via NSQ after Dubbo execution.

Replay: Uses generalized Dubbo calls with trace IDs in attachments, retrieves all sub-calls, performs mock matching based on sub-call type, class, method, and parameters, compares final results with recorded values.

3. Application in Mid-Platform Marketing Business

Marketing is the foundation of YouZan's business, involving rich promotional activities and complex scenarios. The price calculation with overlapping and exclusion rules很容易造成场景遗漏。The article explains how they analyzed business distribution and core scenarios, covering 19 applications with 170+ interfaces for read traffic replay.

Key Challenges and Solutions:

Scene Coverage Visualization: Defined scenes for core interfaces using tags (interface names or parameter JSONPath). After replay, the platform displays coverage statistics including covered/uncovered interfaces and scenarios with coverage counts, increasing confidence in test coverage.

Handling Low-Traffic Scenarios: Two approaches: (1) Manual construction of specific scenarios in pre-environment; (2) Embedding logic in business code to actively report low-traffic scenarios to the platform. The second method was preferred as it requires no manual recording and maintenance while capturing richer traffic for low-volume scenarios.

4. Practical Results

In the product detail page marketing refactoring project, traffic replay was the primary quality assurance method. Without dedicated testing resources, the project went live without any post-launch failures.

5. Future Outlook

Future plans include: expanding write interface coverage (especially for loss-prone logic), abstracting the low-traffic reporting functionality for easier adoption via tag markers, integrating JaCoCo for code branch/line-level coverage analysis, leveraging traffic replay for performance testing with sufficient sampling rates, and implementing sensitive data encryption to prevent data leakage.

traffic replayquality assurancesoftware testingJVM sandboxYouzanautomated regression testingDubbo mockmid-platform testing
Youzan Coder
Written by

Youzan Coder

Official Youzan tech channel, delivering technical insights and occasional daily updates from the Youzan tech team.

0 followers
Reader feedback

How this landed with the community

login 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.