[
https://issues.apache.org/jira/browse/HTTPCLIENT-2180?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17422247#comment-17422247
]
Anurag Agarwal commented on HTTPCLIENT-2180:
--------------------------------------------
[~michael-o] I did think about using HEAD / CONNECT as method.
CONNECT -> doesn't work the http client itself throws an exception that this
method is not allowed (not aware of the reason why)
HEAD -> does work but it still will defeat the purpose, I will explain how:
So when you make a head request a new connection will be created but on second
request the same connection will be reused.
So you need to make both of these calls in parallel to make 2 different
connections. As the latency of the HEAD method is going to be lesser than the
latency of the actual GET / POST request, there will be more chances of
connection usages.
If I need my connection manager to be pre-warmed up with 100 connections, I
need these 100 requests to be concurrently triggered at a single point of time.
If any request is complete before the 100th request is triggered then the
connection will be re-used and I won't get 100 connection. Another possible
solution to this was to tell in header, how much time the server has to wait to
return the HEAD but it would unnecessarily complicate things and at max will be
only valid for our internal services. It will fail if we are calling external
services.
The use-case for this request is pretty simple, our container is able to serve
more than 3k req / sec when it is fully warmed up.
But at the start of the application it has to make connections to all the
micro-services and external services which can be a bit time consuming. This
would lead to request pile up and in worst case scenario the server would go in
OOM state. Thus if the connections are already established, we can expect the
application to work as if it was running from past few hours.
> Pre-init minimum number of connections
> --------------------------------------
>
> Key: HTTPCLIENT-2180
> URL: https://issues.apache.org/jira/browse/HTTPCLIENT-2180
> Project: HttpComponents HttpClient
> Issue Type: New Feature
> Components: HttpClient (async), HttpClient (classic)
> Reporter: Anurag Agarwal
> Priority: Minor
> Labels: volunteers-wanted
> Fix For: Future
>
>
> Most of the applications suffer from a problem of cold start where we don't
> have connections created at the start of the application and thus the first
> few requests suffer by making a lot of connections.
> During deployment this can even pile up a lot of not completed request and
> may lead to losses.
> One suggestion I had in mind is to create few connections before the
> application has begun from the intended endpoints.
> Also sometimes the nautre of your traffic can be spiky in which scenario
> opening and closing a lot of connections also doesn't make sense.
>
> These can be solved with either or both of the suggestions:
> # Have a minConnectionPerHost policy in connection pool which won't let
> connection pool for a host to go below this number or make a new connection
> when it does. At the start of the http client these minimum connections will
> be created to the end services.
> # Provide an easy mechanism for use to create connections via
> ConnectionManager. Currently in PoolingAsyncConnectionManager one must give
> ConnectionInitiator which make it difficult to directly use the connection
> manager to create connections.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]