Backend Development 14 min read

Optimizing Hotel Business Gateway with Spring WebFlux: Performance Improvements and Service Orchestration

This case study describes how the hotel business gateway at Qunar was refactored using Spring WebFlux to achieve full‑process asynchronous handling, service orchestration, and significant performance gains—including a 100% increase in single‑machine throughput, 50% reduction in response latency, and lower code complexity—while outlining the analysis, solution design, results, and future work.

Qunar Tech Salon
Qunar Tech Salon
Qunar Tech Salon
Optimizing Hotel Business Gateway with Spring WebFlux: Performance Improvements and Service Orchestration

Background

Qunar's hotel business gateway was merged into a unified front‑end under a DDD‑guided architecture, resulting in massive hard‑coded logic, inconsistent code styles, and performance degradation: 20% lower peak throughput, 10% longer main‑process latency, and poor maintainability.

Current Situation Analysis

Throughput Degradation

The synchronous servlet container blocks threads during peak traffic, causing CPU waste, excessive thread‑pool usage, and low resource utilization.

Response Time Increase

Complex, scattered business logic across many sub‑gateways leads to duplicated calls and blocking dependencies, inflating the core interface latency.

Solution

Full‑Process Asynchronous Architecture

Adopt Spring WebFlux, a reactive, non‑blocking framework that leverages the Reactor library to improve concurrency, CPU utilization, and scalability. The architecture includes Web Server, HttpHandler, DispatcherHandler, HandlerMapping, HandlerAdapter, HandlerResultHandler, and Reactive Streams.

Implementation Details

Servlet requests are converted to asynchronous mode via request.startAsync() , handled by ServletHttpHandlerAdapter , and processed as Mono streams that execute only upon subscription, freeing servlet threads.

Service Orchestration to Reduce Latency

Using Flux and Mono, services are composed of small, independent service units, each containing invoker (asynchronous third‑party calls) and handler (pure in‑memory logic). Parallel and serial compositions are expressed with flatMap , Mono.zip , and other reactive operators, allowing optimal ordering and eliminating redundant calls.

Optimization Effects

Page Load Speed

Front‑end page rendering time noticeably decreased.

Response Time Reduction

Core API P50 latency dropped by ~50% (e.g., from 366 ms to 36 ms for one endpoint).

Throughput Improvement

Single‑machine QPS capacity rose from 100 to 200, handling peak traffic spikes of over 200k QPS.

Code Complexity Reduction

Effective code lines reduced by 60 k, cyclomatic complexity fell 38% (from 19 518 to 12 084), and development efficiency increased by ~30%.

Conclusion and Future Work

The Spring WebFlux‑based redesign delivered substantial performance and maintainability gains for the hotel gateway. Ongoing work includes building monitoring and attribution tools for response‑time changes and enhancing the orchestration engine to dynamically adapt to upstream latency fluctuations.

JavaPerformance Optimizationbackend architecturereactive programmingservice orchestrationSpring WebFlux
Qunar Tech Salon
Written by

Qunar Tech Salon

Qunar Tech Salon is a learning and exchange platform for Qunar engineers and industry peers. We share cutting-edge technology trends and topics, providing a free platform for mid-to-senior technical professionals to exchange and learn.

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.