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();

  

Configure HttpClient correctly的更多相关文章

  1. HttpClient(4.3.5) - HTTP Authentication

    HttpClient provides full support for authentication schemes defined by the HTTP standard specificati ...

  2. 【ASP.NET Web API教程】3.2 通过.NET客户端调用Web API(C#)

    原文:[ASP.NET Web API教程]3.2 通过.NET客户端调用Web API(C#) 注:本文是[ASP.NET Web API系列教程]的一部分,如果您是第一次看本博客文章,请先看前面的 ...

  3. httpcomponents-client-4.4.x

    Chapter 1. Fundamentals Prev     Next Chapter 1. Fundamentals 1.1. Request execution The most essent ...

  4. httpcomponents-client-ga(4.5)

    http://hc.apache.org/httpcomponents-client-ga/tutorial/html/   Chapter 1. Fundamentals Prev     Next ...

  5. httpcomponents-client-4.3.x DOC

    Chapter 1. Fundamentals Prev     Next Chapter 1. Fundamentals 1.1. Request execution The most essent ...

  6. 通过.NET客户端调用Web API(C#)

    3.2 Calling a Web API From a .NET Client (C#) 3.2 通过.NET客户端调用Web API(C#) 本文引自:http://www.asp.net/web ...

  7. Nginx - SSI Module

    SSI, for Server Side Includes, is actually a sort of server-side programming language interpreted by ...

  8. Jetty开发指导:HTTP Client

    介绍 Jetty HTTP client模块提供易用的API.工具类和一个高性能.异步的实现来运行HTTP和HTTPS请求. Jetty HTTP client模块要求Java版本号1.7或者更高,J ...

  9. 翻译一篇关于jedis的文章

    翻译 自 http://www.baeldung.com/jedis-java-redis-client-libraryIntro to Jedis – the Java Redis Client L ...

随机推荐

  1. 老李分享:接电话之uiautomator 2

    case解释 首先要了解进入uiwatcher方法中的机制,是在你某个控件找不到的情况下会进入.但是你得保证进入以后处理完来电界面以后,这条case得保证正确,那么说明回来以后这个控件要能找到.刚开始 ...

  2. 老李推荐:第5章7节《MonkeyRunner源码剖析》Monkey原理分析-启动运行: 循环获取并执行事件 - runMonkeyCycles

    老李推荐:第5章7节<MonkeyRunner源码剖析>Monkey原理分析-启动运行: 循环获取并执行事件 - runMonkeyCycles   poptest是国内唯一一家培养测试开 ...

  3. ATM取款小项目

    项目要求: 1.用户需要从控制台输入账号密码,账号或者密码不正确报异常 2.每日取款的金额有限制(100,30000),否则报异常 3.每次取款都要有记录,并在下一次取款时显示出来 思路: 1.先在& ...

  4. Java排序算法之插入排序

    基本过程: 每次将待排元素和已经排序好的序列进行比较,按照大小顺序插入进去,重新构造一个新的有序序列. 插入排序算法有种递归的思想在里面,它由N-1趟排序组成.初始时,只考虑数组下标0处的元素,只有一 ...

  5. Linux 安装SVN服务器 (转)

    一. SVN 简介 Subversion(SVN) 是一个开源的版本控制系統, 也就是说 Subversion 管理着随时间改变的数据. 这些数据放置在一个中央资料档案库 (repository) 中 ...

  6. vue获取dom元素内容

    通过ref来获取dom元素 在vue官网上对ref的解释 ref 被用来给元素或子组件注册引用信息.引用信息将会注册在父组件的 $refs 对象上.如果在普通的 DOM 元素上使用,引用指向的就是 D ...

  7. 【one day one linux】find 用法详解小记

    find命令的功能很强大,查找文件的选项很多,所以这是一个很实用并且很常用的linux命令.但是他有个缺点就是搜索的时候比较慢的.而与之相对的有一个locate命令. find的命令格式 find   ...

  8. 对java面向对象的初识

    我其实一直想写点东西练练自己文笔,今天写下这篇技术类型的文章也没有一个好的格式和章法,但万事开头难,那么就从面向对象开始. 我们大部分人都知道互联网软件的存在,时刻影响了我们的现实生活,那么面向对象的 ...

  9. 跨语言时区处理与Epoch

    国际化通用程序或标准协议通常都涉及到时区问题,比如最近项目用到的OIDC(OpenID Connect). OIDC基于OAuth2协议,其id_token中包含了exp来表达该Token的过期时间, ...

  10. JS模式--装饰者模式(用AOP动态改变函数的参数)

    Function.prototype.before = function (beforefn) { var _self = this; return function () { beforefn.ap ...