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. iOS StoreKit

    简述: 本文讲解iOS系统框架StoreKit中的SKStoreProductViewController与SKStoreReviewController这两个Controller. SKStoreP ...

  2. html实现 页面禁止右键 禁止复制 禁止图片拖动 禁止复制和剪切

    众所周知,一般的屏蔽的方法是用JS来编写的脚本,但是也可以直接通过修改网页属性的方法来屏蔽右键 禁止复制. 禁止右键 oncontextmenu="return false" 禁止 ...

  3. 关于C++中的前置声明(附程序运行图)

    实验于华中农业大学逸夫楼2017.3.10 在编写C++程序的时候,偶尔需要用到前置声明(Forward declaration).下面的程序中,带注释的那行就是类B的前置说明.这是必须的,因为类A中 ...

  4. __init__.py

    python中的Module是比较重要的概念.常见的情况是,事先写好一个.py文 件,在另一个文件中需要import时,将事先写好的.py文件拷贝 到当前目录,或者是在sys.path中增加事先写好的 ...

  5. Java事物基础总结

    1.什么是事物? 事物是逻辑上的的一种操作,这个操作过程中的每一个元素要么全部成功,要么全部失败.例如,银行转账过程视为一个事物,转出过程和转入过程要求全部成功或全部失败,通过提交事物或者回滚事物实现 ...

  6. 【mysql】关于InnoDB表text blob大字段的优化

    最近在数据库优化的时候,看到一些表在设计上使用了text或者blob的字段,单表的存储空间已经达到了近100G,这种情况再去改变和优化就非常难了 一.简介 为了清楚大字段对性能的影响,我们必须要知道i ...

  7. mac双系统用磁盘工具合并windows分区后,开机还会 出现win分区

    如何删除开机硬盘的选择项 打开终端,输入sudo mount -t msdos /dev/disk0s1 /mnt 在Finer中会出现EFI盘,删除其中的Apple文件以外的文件即可(Apple千万 ...

  8. html 数字不转行问题

    代码如下 <div style="width:20px;height:20px"> 111111111111111111111111111111111111111111 ...

  9. JS取消浏览器文本选中的方法

    一 .问题的出现 今天在使用Easy-UI 的messager.alert()方法时候出现浏览器文本被选中,不知道其中是什么原因,如下图所示. 二 .解决思路 我最后的思路时在弹出消息框的同时,取消浏 ...

  10. mysql数据库开启日志

    旧版 #开启慢查询 slow_query_log # (超过2秒的SQL语法记录起来,设短一点来记录除错也是一种方法.) long_query_time = 2 log-slow-queries=D: ...