You are viewing a plain text version of this content. The canonical link for it is here.
Posted to httpclient-users@hc.apache.org by Братухин Никита Романович <Br...@sberbank.ru> on 2019/09/23 10:39:05 UTC

max total connections

Hey there, recently we have been using this beautiful lib for our internal microservices communication, but I have some question about max connection count.
What will happen when max count of connections will be used?
For example, if  PoolingHttpClientConnectionManager has maximum 200 of connections
cm.setMaxTotal(200);
and all of them are used, what will happen then client should execute another request, which will require 201 connection?
Will it throw error or will some of the active connections closed ( for example some LRU/LFU logic) ?
УВЕДОМЛЕНИЕ О КОНФИДЕНЦИАЛЬНОСТИ: Это электронное сообщение и любые документы, приложенные к нему, содержат конфиденциальную информацию. Настоящим уведомляем Вас о том, что если это сообщение не предназначено Вам, использование, копирование, распространение информации, содержащейся в настоящем сообщении, а также осуществление любых действий на основе этой информации, строго запрещено. Если Вы получили это сообщение по ошибке, пожалуйста, сообщите об этом отправителю по электронной почте и удалите это сообщение. CONFIDENTIALITY NOTICE: This email and any files attached to it are confidential. If you are not the intended recipient you are notified that using, copying, distributing or taking any action in reliance on the contents of this information is strictly prohibited. If you have received this email in error please notify the sender and delete this email.

Re: max total connections

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Mon, 2019-09-23 at 10:39 +0000, Братухин Никита Романович wrote:
> Hey there, recently we have been using this beautiful lib for our
> internal microservices communication, but I have some question about
> max connection count.
> What will happen when max count of connections will be used?
> For example, if  PoolingHttpClientConnectionManager has maximum 200
> of connections
> cm.setMaxTotal(200);
> and all of them are used, what will happen then client should execute
> another request, which will require 201 connection?

Доброго вам дня.

The thread executing the request will get blocked until a connection
becomes available in the pool or `connectionRequestTimeout` expires.


> Will it throw error or will some of the active connections closed (
> for example some LRU/LFU logic) ?

Several outcomes are possible:

1. If a persistent connection gets released back to the pool manager it
will be re-used and served to a pending connection lease request for
the same route.

2. If a closed connection for any route or a persistent connection for
a different route gets released back to the pool the pool manager will
discard the old connection and open a new connection for the next
pending connection request. 

3. `ConnectionPoolTimeoutException` is thrown if
the `connectionRequestTimeout` expires with no connection released back
to the pool manager.

Hope this helps

Oleg


> УВЕДОМЛЕНИЕ О КОНФИДЕНЦИАЛЬНОСТИ: Это электронное сообщение и любые
> документы, приложенные к нему, содержат конфиденциальную информацию.
> Настоящим уведомляем Вас о том, что если это сообщение не
> предназначено Вам, использование, копирование, распространение
> информации, содержащейся в настоящем сообщении, а также осуществление
> любых действий на основе этой информации, строго запрещено. Если Вы
> получили это сообщение по ошибке, пожалуйста, сообщите об этом
> отправителю по электронной почте и удалите это сообщение.
> CONFIDENTIALITY NOTICE: This email and any files attached to it are
> confidential. If you are not the intended recipient you are notified
> that using, copying, distributing or taking any action in reliance on
> the contents of this information is strictly prohibited. If you have
> received this email in error please notify the sender and delete this
> email.

---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org