'Netty Http Client Connection Pool
I am trying to understand netty http client connection pool. If it is NIO and asynchronous, then what is the significance of this connection pool?
For ex: if service A calls service B and service A has the client connection pool count set as 50, then does it mean we can make only 50 parallel requests at the max?
UPDATE:
// remote server
@GetMapping("echo")
public Mono<String> echo(){
return Mono.just("echo")
.delayElement(Duration.ofSeconds(3));
}
// client 1 conneciton
HttpClient httpClient = HttpClient.create(ConnectionProvider.newConnection());
WebClient client = WebClient.builder()
.baseUrl("http://localhost:8080/echo")
.clientConnector(new ReactorClientHttpConnector(httpClient))
.build();
// run
var start = System.currentTimeMillis();
Flux.range(1, 50)
.flatMap(i -> client.get().retrieve().bodyToMono(String.class))
.collectList()
.doOnNext(System.out::println)
.doFinally(s -> System.out.println("Total Time Taken : " + (System.currentTimeMillis() - start) + " ms"))
.block();
I get all the calls get completed in 3.5 seconds. Ideally with 1 connection I should have got them completed in 150 seconds.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
