Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get the count of pool

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

like image 633
Orange-Man Avatar asked Sep 24 '19 06:09

Orange-Man


1 Answers

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.

like image 158
Máté Avatar answered Sep 19 '22 14:09

Máté