I’m using HTTPoison and Hackney pools:
:hackney_pool.child_spec(:start, [checkout_timeout: ..., max_connections: 100]),
:hackney_pool.child_spec(:trigger, [checkout_timeout: ..., max_connections: 100]),
:hackney_pool.child_spec(:result, [checkout_timeout: ..., max_connections: 100])
...
HTTPoison.get('...', [...], [
...,
hackney: [pool: :start]
])
Is there any way to сatch the number of running/queuing connections and monitor them in live? Thanks
You can use the get_stats/1 function on :hackney_pool
. This returns a proplist (keyword list in Elixir) with:
[ {:name, "pool_name"},
{:max, 100},
{:in_use_count, 19},
{:free_count, 81},
{:queue_count, 0}
]
Then you can use the Keyword.fetch/2 function to get the :in_use_count
value, which will tell you the active connection count. I'm not 100% sure on how you'd monitor it though.