CyberSource / CyberSource/cybersource-rest-client-java
ApiClient throttles requests in async mode
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- Java
- Estrellas
- 29
- Forks
- 50
- Merge medio
- 28 min
- PR fusionados (30 d)
- 1
Descripción
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.
Guía de contribución
No hay ninguna guía de contribución indexada para este repositorio
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Línea de trabajo
El issue identifica el builder de ApiClient y la configuración de su cliente HTTP OkHttp como los principales puntos de entrada. Primero inspecciona cómo se construyen los clientes asíncronos y cómo se pueden proporcionar los ajustes de Dispatcher; después determina cuál de los enfoques de configuración propuestos es el previsto. Se considera completado cuando las solicitudes asíncronas ya no están limitadas por las cinco solicitudes simultáneas por host predeterminadas de OkHttp.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- java
- Área
- api
- Tipo de issue
- Error
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Estado de actividad
- Estancado
- Claridad
- Necesita aclaración
- Aptitud para principiantes
- 25/100