spring-framework: Slow WebClient Under Heavy Load >500 users
Hi everyone, I created 2 Spring Webflux applications with the following version: spring-boot: 2.3.2.RELEASE spring-webflux: 5.2.8.RELEASE reactor-core: 3.3.8.RELEASE reactor-netty: 0.9.10.RELEASE
App1
@RestController
class DemoController(webClientBuilder: WebClient.Builder) {
private val webClient = webClientBuilder.build()
private val counter = AtomicLong(0)
@GetMapping("/")
fun demo(@RequestParam delay: Long): Mono<String> {
return webClient.get()
.uri("http://localhost:8080/delay?delay=$delay") // This calls App2
.retrieve()
.bodyToMono(String::class.java)
}
}
App2
@RestController
class DelayController {
@GetMapping("/delay")
fun getUserWithDelay(@RequestParam delay: Long): Mono<String> {
return Mono.just("OLOLO").delayElement(Duration.ofMillis(delay))
}
}
Then I run some load test scenarios:
Scenario 1 (Expected) Users/Threads: 500 Target Throughput: 30k/min Delay: 1s
Result when calling directly to App2: Throughput: 500/s (expected because 30k/min ~ 500/s) Median Latency: 1s (expected because the delay is also 1s)
Result when calling to App1 -> App2: Throughput: 500/s (expected because 30k/min ~ 500/s) Median Latency: 1s (expected because the delay is also 1s)
Scenario 2 (App 1 slow, App2 expected) Users/Threads: 1000 Target Throughput: 60k/min Delay: 1s
Result when calling directly to App2: Throughput: 1k/s (expected because 60k/min ~ 1k/s) Median Latency: 1s (expected because the delay is also 1s)
Result when calling to App1 -> App2: Throughput: 500/s (expecting 1k/s) Median Latency: 2s (expecting 1s)
Scenario 3 (App1 slow, App2 expected) Users/Threads: 2000 Target Throughput: 60k/min Delay: 1s
Result when calling directly to App2: Throughput: 1k/s (expected because 60k/min ~ 1k/s) Median Latency: 1s (expected because the delay is also 1s)
Result when calling to App1 -> App2: Throughput: 500/s (expecting 1k/s) Median Latency: 4s (expecting 1s)
Summary It’s causing higher latency and lower throughput when using WebClient (App1) with higher threads (>500) from jmeter
Any advice regarding this problem?
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 17 (6 by maintainers)
Turns out the slow throughput because on version >= 2.2.x, spring webclient uses reactor-netty 0.9.x that implement default connection limit to 500. After changing the connection limit, the throughput improves a lot. I’ll close this ticket