5

我正在使用 HTTPoison 和 Hackney 池:

: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]
])

有什么方法可以捕捉运行/排队连接的数量并实时监控它们吗?谢谢

4

1 回答 1

7

可以在:hackney_pool. 这将返回一个proplist(Elixir 中的关键字列表),其中包含:

[ {:name, "pool_name"},
  {:max, 100},
  {:in_use_count,  19},
  {:free_count, 81},
  {:queue_count, 0}
]

然后您可以使用Keyword.fetch/2函数获取该:in_use_count值,它将告诉您活动连接数。我不是 100% 确定你会如何监控它。

于 2019-09-24T11:42:16.917 回答