CyberSource / CyberSource/cybersource-rest-client-java
ApiClient throttles requests in async mode
还没有人认领这个 Issue。
- 主要语言
- Java
- 星标
- 29
- 派生
- 50
- 平均合并
- 28 分钟
- 30 天内合并 PR
- 1
描述
OkHttp by default only permits 5 connections to a given host in async mode. This means that in a high traffic scenario, we are capped to just 5 concurrent requests unless we manage a pool of ApiClients or create one per request, or ignore the async methods.
The number can be changed by configuring a dispatcher on the ApiClient builder to have a greater number of maxRequests and maxRequestsPerHost. I think there are a number of possible fixes:
- The max requests is set suitably high automatically (ideally unbounded for us)
- The max requests/max requests per host is configurable inside the merchant config
- The client can pass in an optional Function to configure the http client builder
We did a quick test with a local fork to set this higher and this helped it work for us, the change was just:
+ Dispatcher dispatcher = new Dispatcher();
+ dispatcher.setMaxRequests(500);
+ dispatcher.setMaxRequestsPerHost(500);
try {
httpClient = classHttpClient.newBuilder()
+ .dispatcher(dispatcher)
It looks like there is no significant negative impact to just setting this to Integer.MAX_VALUE - so that might be a reasonable option.
贡献指南
这个仓库没有索引到贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
该 issue 指出,ApiClient builder 及其 OkHttp HTTP client 配置是主要入口点。首先检查异步客户端的构造方式,以及如何提供 Dispatcher 设置,然后确定所提出的配置方案中哪一种是预期方案。完成的标准是,异步请求不再受 OkHttp 默认的每个 host 五个并发请求的限制。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- java
- 领域
- api
- Issue 类型
- 缺陷
- 难度
- 5/5
- 预计耗时
- 一周以上
- 活跃度
- 停滞
- 描述清晰度
- 需要澄清
- 新手友好度
- 25/100