Number of connections keep increasing for every search

(Vishnu Gt) #1
	String clusterName = GridContactManager.getClusterName(ClusterType.ElasticSearch, clusterID);
	String esHosts = LogConf.getESUnicastHosts(clusterID);
	String[] masterNodes = esHosts.split(StringUtil.COMMA);
	HttpHost[] hostsArr = new HttpHost[masterNodes.length];
	for (int i = 0; i < masterNodes.length; i++)
		String masterIp = masterNodes[i];
		HttpHost host = new HttpHost(masterIp, 9200, "http");//No I18N
		hostsArr[i] = host;
	RestClient restClient = RestClient.builder(hostsArr).build();
	return restClient;

When I check the number of requests periodically via netstat, the number of requests keeps increasing. I am initializing the restClient with the above code, and this code runs only once, so am not creating multiple RestClients. I use restClient.performRequest for all the search operations and also I am not closing the restClient anywhere.

Result of this netstat | grep "9200" | wc -l is as follows

After initializing the server - 7
After 50 searches - 103
After 100 searches - 202

For now, I am running this on my development machine with a single node.

(Adrien Grand) #2

You should create the client once and then reuse it all the time.

(Vishnu Gt) #3

Thanks @jpountz !!
My bad, I was creating multiple rest clients in another part of the code.

Although now I am running rest client, comparing it with node client, the results aren't up to the par.

I have two clusters with 6 data nodes each and a dedicated master node for each cluster. Both cluster's data size comes to around 10GB with approx 10 million records.

While searching, node client takes 7 seconds while rest client takes 17 seconds. At all the times, node client returns the results at least 5 seconds earlier than the rest client.
I am adding sniffer to both the clients as well.

Any optimization insights would be helpful.

(system) #4

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.