Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

ApiClient throttles requests in async mode

Aperta
#167 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
25/100
Tipo di issue
Bug
Chiarezza
Da chiarire
Stato di attività
Ferma
Stack tecnologico
java
Ambito
api

Direzione di ricerca

L’issue identifica il builder di ApiClient e la configurazione del relativo client HTTP OkHttp come principali punti di ingresso. Per prima cosa esamina come vengono costruiti i client asincroni e come è possibile fornire le impostazioni di Dispatcher, quindi determina quale degli approcci di configurazione proposti è quello previsto. Il lavoro è completato quando le richieste asincrone non sono più limitate alle cinque richieste simultanee per host predefinite di OkHttp.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
Java
Stelle
29
Fork
50
Merge medio
28m
PR unite (30g)
1

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di CyberSource/cybersource-rest-client-java

Tutte le issue di CyberSource/cybersource-rest-client-java

Issue simili

Altre issue su Java

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.