为什么 Apache HttpAsyncClient 每秒只发送 10 个请求。我配置错了吗?这是我启动 asyncClient 的方式:
PoolingNHttpClientConnectionManager connManager = null;
try {
if (client != null && client.isRunning()) {
client.close();
}
TrustStrategy acceptingTrustStrategy = (certificate, authType) -> true;
SSLContext sslContext = SSLContexts.custom()
.loadTrustMaterial(null, acceptingTrustStrategy).build();
SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(sslContext,
SSLConnectionSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
Registry<ConnectionSocketFactory> socketFactoryRegistry =
RegistryBuilder.<ConnectionSocketFactory> create().register("https", sslsf).build();
Registry<SchemeIOSessionStrategy> socketRegistry = RegistryBuilder.<SchemeIOSessionStrategy>create()
.register("http", NoopIOSessionStrategy.INSTANCE)
.register("https", new SSLIOSessionStrategy(sslContext, SSLConnectionSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER))
.build();
connManager = new PoolingNHttpClientConnectionManager(
new DefaultConnectingIOReactor( IOReactorConfig.custom()
.setConnectTimeout( connectionTimeout * 1000 ) //connectTimeout
.setSoTimeout( readTimeout * 1000 ) //readTimeout
.setIoThreadCount(10000)
.build() ), socketRegistry );
} catch (Exception e) {}
client = HttpAsyncClients.custom()
.setMaxConnPerRoute( maxConnsPerRoute )
.setConnectionManager( connManager )
.setMaxConnTotal( maxConnections )
.setKeepAliveStrategy( DefaultConnectionKeepAliveStrategy.INSTANCE )
.build();
client.start();
而且,这是我使用它的方式:
for(int i = 0; i < 100; i++) {
client.execute(request.getHttpPost(), null);
}
我怎样才能达到每秒更多的请求???