Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在使用带有异步回调的http-kit客户端。
我想知道是否有办法对并发传出 http 请求的数量设置限制,以便回调的等待状态不会导致 Out-Of-Memory 异常。
我问是因为,至少在理论上,可能有太多并发的、不完整的请求会消耗内存。由于内存是有限的资源(考虑在Docker等容器中运行),这可能是一个问题。
我知道增加可用 RAM 是一种选择,但我想知道是否可以设置相关限制。
现在没有。鉴于您想以异步方式使用它,我认为您将无法使用任何库,您需要自行开发。也许你可以从Throttler或类似的东西上获得灵感。