Spring WebFlux hangs on Mac OS with Apache Benchmark with more than 16000 requests

30 Views Asked by At

The source code is available https://github.com/fmcarvalho/webflux-demo and you can check the results or run from its Github actions for both Ubuntu and Mac OS.

I have built a Spring WebFlux application with Maven from scratch, incorporating the most straightforward functional route as follows:

@Configuration
open class RouterConfig {

    @Bean
    open fun route() = router { GET("/hello", ::sayHello) }

    fun sayHello(request: ServerRequest): Mono<ServerResponse> {
        val htmlBody = "<html><body><p>Hello, WebFlux!</p></body></html>"
        return ok().contentType(MediaType.TEXT_HTML).bodyValue(htmlBody)
    }
}

Running this WebFlux application and executing it with Apache Benchmark using the following command in the terminal of Mac Os will hang after serving 16K requests:

ab -n 20000 http://localhost:8080/hello

The output:

This is ApacheBench, Version 2.3 <$Revision: 1903618 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking localhost (be patient)
Completed 2000 requests
Completed 4000 requests
Completed 6000 requests
Completed 8000 requests
Completed 10000 requests
Completed 12000 requests
Completed 14000 requests
Completed 16000 requests
apr_pollset_poll: The timeout specified has expired (70007)
Total of 16375 requests completed

However, this issue only occurs on Mac OS. I have tested the application on two different local machines—one running Windows 10 and the other Mac OS Ventura (13.4.1)—and the problem only manifests on the Mac.

I created a GitHub Action to conduct the same test on both ubuntu-latest and macos-latest, and we observed the same behavior. From the last job you can get the results for:

The former finished after reaching the timeout and only processed 16377 requests, whereas the latter successfully completed all 20K requests.

I am unable to determine whether this is a Mac OS issue, a WebFlux issue, a web server issue, or something else?

0

There are 0 best solutions below