algolia/algoliasearch-client-java

Let users configure the Apache client the via the ApacheHttpRequester() constructor

aseure opened this issue · 0 comments

@Ant-hem and I recently investigated a performance bottleneck for a customer which led us to consider exposing the HttpAsyncClientBuilder use to set the ApacheHttpRequester.asyncHttpClient.

A first idea would be to deprecate the use of useSystemProxy.

Then, we'd like to create a new constructor for the ApacheHttpRequester with the following signature:

ApacheHttpRequester(@Nonnull ConfigBase config, @Nonnull HttpAsyncClientBuilder builder) {
    // ...
}

This way, users could completely override the default Apache HTTP client configuration, such as builder.setMaxConnPerRoute() and builder.setMaxConnPerRoute(). Side-note: we may also want to increased the default values for at least maxConnPerRoute from 2 (default value) to something that would make more sense for real-life situations, as explained in the Apache HTTP client documentation:

Screenshot 2020-03-13 at 11 48 39

For the record, our benchmarks showed that changing the maxConnPerRoute from 2 to 100, the number of req/s jumped from ~100 to ~1000, which makes me think we should also consider changing the default value for our default client as well.