官方文档地址:Number of threads
Apache Http Async 客户端在默认情况下启动一个调度程序线程,以及连接管理器使用的多个工作线程,与本地检测到的处理器数量相同(取决于Runtime.getRuntime().availableProcessors()
返回的内容)。线程数修改方式如下:
RestClientBuilder builder = RestClient.builder(
new HttpHost("localhost", 9200))
.setHttpClientConfigCallback(new HttpClientConfigCallback() {
@Override
public HttpAsyncClientBuilder customizeHttpClient(
HttpAsyncClientBuilder httpClientBuilder) {
return httpClientBuilder.setDefaultIOReactorConfig(
IOReactorConfig.custom()
.setIoThreadCount(1)
.build());
}
});