zoukankan      html  css  js  c++  java
  • Configure HttpClient correctly

    References:

    [1] http://dev.bizo.com/2013/04/sensible-defaults-for-apache-httpclient.html

     We have hit an issue recently that the httpClient is too slow to send messages to the hosts. Finally, we found that we just use 

    CloseableHttpClient httpClient = HttpClients.custom().build();
    

    to create a default httpClient and not even configure it. We shoud have set at least MaxTotal and MaxPerRoute.

    MaxTotal is the maximum total number of connections in the pool. MaxPerRoute is the maximum number of connections to a particular host. If the client attempts to make a request and either of these maximums have been reached, then by default the client will block until a connection is free. Unfortunately the default for MaxTotal is 20 and the default MaxPerRoute is only 2.

    Finally we solved th issue by setting

    CloseableHttpClient httpClient = HttpClients.custom()
            .setMaxConnTotal(threadpoolSize) // threadpoolSize = 100
            .setMaxConnPerRoute(threadpoolSize)
            .build();
    

      

  • 相关阅读:
    玩转xss
    Anonim小白成长计划
    mssql注入与绕过
    了解mssql数据库
    2020年度学习规划
    access 注入
    bypasswaf 之报错注入
    bypasswaf之盲注
    sql注入常用函数与bypasswaf
    一篇关于数据库的另类操作
  • 原文地址:https://www.cnblogs.com/codingforum/p/6099173.html
Copyright © 2011-2022 走看看