我正在使用 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]
])
Run Code Online (Sandbox Code Playgroud)
有什么方法可以匹配运行/排队连接的数量并实时监控它们?谢谢
您可以在 上使用get_stats/1函数:hackney_pool。这将返回一个proplist(Elixir 中的关键字列表),其中包含:
[ {:name, "pool_name"},
{:max, 100},
{:in_use_count, 19},
{:free_count, 81},
{:queue_count, 0}
]
Run Code Online (Sandbox Code Playgroud)
然后你可以使用Keyword.fetch/2函数来获取:in_use_count值,它会告诉你活动连接数。我不是 100% 确定你将如何监控它。
| 归档时间: |
|
| 查看次数: |
423 次 |
| 最近记录: |