Tarantool development patches archive
 help / color / mirror / Atom feed
From: Kirill Yukhin <kyukhin@tarantool.org>
To: tarantool-patches@freelists.org
Cc: totktonada.ru@gmail.com, Ilya Konyukhov <runsfor@gmail.com>
Subject: [tarantool-patches] Re: [PATCH] Pass max_total_connections parameter to httpclient
Date: Tue, 14 May 2019 17:24:46 +0300	[thread overview]
Message-ID: <20190514142446.gbe4uulwshdwt2p3@tarantool.org> (raw)
In-Reply-To: <20190417145139.59554-1-runsfor@gmail.com>

Hello,

On 17 Apr 17:51, Ilya Konyukhov wrote:
> There are some usecases when current http client may leak sockets (due
> TIME_WAIT timeout). The reason is that the `max_connection` option of
> tarantool's http client (actually is a binding for CURLMOPT_MAXCONNECTS
> option in libcurl) may not be enough for some situations.
> 
> This option sets up a size of connection cache, which curl maintains
> during its lifetime. When this cache is full (i.e. all connections are
> waiting for a response from a server), newly created request would
> create a new connection to handle it. In that case right after old
> connection got response, curl has to close that connection to keep up an
> appropriate number of connections in cache. That results in a new socket
> in TIME_WAIT state (for 60 seconds by default).
> 
> This is actually easy to calculate. Imagine we have http client with
> default 8 maximum connections in cache. Also lets say we have 16384
> sockets available in the system. We need to make requests to external
> system which responses in 100ms in average. So, if we start making
> request every 11ms (100/9), every finished request will be followed by
> curl closing that socket (switches to TIME_WAIT). Result is about 90
> wasted sockets per second and additional overhead for socket creation
> for each new request.
> 
> Also if we do more than 274 requests per second, we will likely to be
> out of available sockets in 1 minute.
> 
> The solution is to add another binding for max_total_connections option,
> which will let curl hold new requests, before old ones have finished.
> It also adds more control over sockets resources.

I've checked your patch into 1.10, 2.1 and master.

--
Regards, Kirill Yukhin

      parent reply	other threads:[~2019-05-14 14:24 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-17 14:51 [tarantool-patches] " Ilya Konyukhov
2019-04-22  2:38 ` [tarantool-patches] " Alexander Turenko
2019-05-06 13:20   ` Илья Конюхов
2019-05-08 15:09     ` Alexander Turenko
2019-05-12 14:16       ` Alexander Turenko
2019-05-14 14:24 ` Kirill Yukhin [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190514142446.gbe4uulwshdwt2p3@tarantool.org \
    --to=kyukhin@tarantool.org \
    --cc=runsfor@gmail.com \
    --cc=tarantool-patches@freelists.org \
    --cc=totktonada.ru@gmail.com \
    --subject='[tarantool-patches] Re: [PATCH] Pass max_total_connections parameter to httpclient' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox