分析httpasyncclient的异步请求


    org.apache.httpcomponents
    httpasyncclient
    4.1.1

本人用该jar生成了两个发送http工具的类,分别是 sync和async的请求。并加上如下参数:

static {
    System.setProperty("http.maxConnections","100");
    System.setProperty("http.keepAlive", "true");
    //创建http客户端
    HTTP_GET_CLIENT = HttpClients.custom()
            .useSystemProperties()
            .setRetryHandler(new DefaultHttpRequestRetryHandler(3,true))
            .build();
    HTTP_POST_CLIENT = HttpClients.custom()
            .build();
    //初始化HTTP请求配置
    REQUEST_CONFIG = RequestConfig.custom()
            .setContentCompressionEnabled(true)
            .setSocketTimeout(3000)
            .setAuthenticationEnabled(true)
            .setConnectionRequestTimeout(3000)
            .setConnectTimeout(3000).build();
}

 

使得qps从同步默认参数的800提升到现在的sync达到2600+,async达到2000+

你可能感兴趣的:(JAVA技术)