CyberSource / CyberSource/cybersource-rest-client-java

ApiClient throttles requests in async mode

オープン
#167 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

主要言語
Java
スター
29
フォーク
50
平均マージ
28分
マージ済み PR(30日)
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.

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

issue では、ApiClient builder とその OkHttp HTTP クライアント設定が主なエントリーポイントとして特定されています。まず、非同期クライアントがどのように構築されるか、また Dispatcher 設定をどのように渡せるかを確認し、その後、提案された設定方法のうちどれが意図されたものかを判断してください。完了条件は、非同期リクエストが OkHttp のデフォルトのホストあたり同時 5 リクエストという制限を受けなくなることです。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
java
領域
api
issue の種類
バグ
難易度
5/5
見積もり時間
1週間以上
活発さ
停滞
明瞭さ
説明が足りない
初心者へのやさしさ
25/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。