Poolsize for java client

Versions (relevant - OpenSearch/Dashboard/Server OS/Browser):

Describe the issue:
We have OpenSearch Client API in python to accept pool_maxsize=500 while creating OpenSerchClient, Same how to provide for JAVA client ??When we ran JAVA Vs Python we see QPS(770/sec) is very python in python with pool_maxsize=500 as same is not available in JAVA it is very poor (150/sec) . We are exploring from JAVA how to set or any alternate equivalent to pool_maxsize property?


Relevant Logs or Screenshots:

@shaiktas the OpenSearchClient in default configuration uses Apache HttpClient 4, where you could configure PoolingNHttpClientConnectionManager with pool settings that you need:

        final RestClient restClient = RestClient.builder(new HttpHost("localhost", 9200, "https")).
                setHttpClientConfigCallback(new RestClientBuilder.HttpClientConfigCallback() {
                    public HttpAsyncClientBuilder customizeHttpClient(HttpAsyncClientBuilder httpClientBuilder) {
                        final PoolingNHttpClientConnectionManager manager = ...;
                        return httpClientBuilder.setConnectionManager(manager);
        final Transport transport = new RestClientTransport(restClient, new JacksonJsonpMapper());
        final OpenSearchClient client = new OpenSearchClient(transport);

Thanks @reta for your response. I am trying to refer knn samples.

In “org.opensearch.client.samples.knn.KnnBasics” component we are creating Client using simpleClient.create() which is using http client5 API’s .

 final var connectionManager = PoolingAsyncClientConnectionManagerBuilder.create().setTlsStrategy(tlsStrategy).build();

                return httpClientBuilder.setDefaultCredentialsProvider(credentialsProvider).setConnectionManager(connectionManager);

In PoolingAsyncClientConnectionManagerBuilder, there are 2 variable defined, is this 2 controlling poolsize as i dont see any poolsize directly?

   private int maxConnTotal;
    private int maxConnPerRoute;

I tried using 1000,500 for above configs, but did not see any different with respect to Query per seconds and Average took time. We are trying to conduct test for a specific duration and capturing QPC and Avg Took time, With python we got very good QPS with poolsize=500, but with JavaClient it is only 180. Hence trying to understand what causing java this poor QPS? Can this be improve with any configs?

May need some profiling to understand what is the bottleneck, it may not be the pool actually.

@reta can you please point one java example how to perform a search with knn index?

My goal is to execute search query for a given duration concurrently in multithreading environment

@shaiktas please check opensearch-java/guides/plugins/knn.md at main · opensearch-project/opensearch-java · GitHub, there is a guide for KNN plugin usage, thank you