A Case Study in Stably Migrating a Legacy System Using Real-Time Traffic Mirroring
Key point
Using Nginx traffic mirroring, the team migrated a WebFlux legacy system to WebMVC with zero downtime.
Details
As the Naver Pay Credit Score Inquiry service continued operating, its Spring WebFlux reactive code grew more complex, and the team's learning curve and maintenance costs increased as well. On top of this, MongoDB schema extension limitations compounded the problem, making it clear that what was needed was not a simple schema change but a migration to a new system.
The direction chosen for the migration was the more familiar and intuitive Spring WebMVC. Based on Java 21 Virtual Threads and an analysis of TPS traffic over the past 2 months, the team examined performance concerns and concluded that the Spring Boot 3 + JDK 17 combination alone would be sufficient. They also considered a structure that could later be extended with virtual threads or coroutines if needed.
The most critical requirement was maintaining 100% API compatibility. Given the nature of a financial service, response formats and semantics could not be changed, so the team closely analyzed the legacy behavior and implemented it identically in the new system—even intentionally reproducing potential bugs. At the same time, they chose traffic mirroring based on Nginx's ngx_http_mirror_module as a way to safely validate the new system against live production traffic.
The implementation approach is simple. Client requests are forwarded as-is to the legacy server, and the same requests are duplicated to the new server via the mirror directive. Users receive only the legacy response, while the new server's response is discarded. Instead, a comparison Middleware and logs automatically compare response codes, JSON fields, processing time, and more between the two systems, immediately catching any discrepancies.
The mirroring approach produced the following benefits:
- Validating the new system using live production traffic
- Automated response comparison with no impact on users
- Real-time logging and corner-case detection without delay
The results were also confirmed numerically. According to Detekt, compared to the existing WebFlux system, Cyclomatic Complexity (MCC) decreased by approximately 70%, and Cognitive Complexity decreased by approximately 87%. The key point isn't simply that the code became shorter—rather, with the reactive chains and branching structures eliminated, the design and flow itself became far clearer.
This summary was generated automatically by AI. Check the original for the author's claims and context. Copyright belongs to the original author.
Our guide explains how the AI works. Report summary errors, attribution issues, or removal requests via Contact.