Hi All,
We are using java TransportClient api to connect to elasticsearch cluster. We see a lot of unclosed tcp connections lying open for longer time, is there any connection pool setting that can limit this count?
Thanks
sunder
Hi All,
We are using java TransportClient api to connect to elasticsearch cluster. We see a lot of unclosed tcp connections lying open for longer time, is there any connection pool setting that can limit this count?
Thanks
sunder
The transport client is basically a mini elasticsearch node and uses the same pooling the nodes use to communicate with one another which works pretty well in my experience. Do you happen to be making a new TransportClient object very frequently?
Hi Nik,
Thanks for quick response.
No we are making a single TransportClient connection per jvm as an singleton, but we are running 2/3 jvm's per machine.
Thanks
sunder
Multiple JVMs per machine shouldn't cause any trouble.
How many connections is a lot? How are you measuring it?
Hi Nik,
We are checking count of established connection using the following command. Without any activity and just initializing the TransportClient at the startup and letting system rest for 8 hrs. Following is the count (4 jvm's)
netstat -an | grep 9300 | wc -l
224
With very less activity this count shoots[on one jvm] up to
netstat -anp | grep 9300 |wc -l
18732
Do you see any issue with settings? Following is the code snippet how we are initializing TransportClient
Settings settings = Settings.settingsBuilder()
.put("cluster.name", rb.getString("cluster.name")).build();
TransportClient transportClient =TransportClient.builder().settings(settings).build();
String transPortAddress = rb.getString("transport.address");
StringTokenizer st = new StringTokenizer(transPortAddress, ",");
while (st.hasMoreTokens()) {
String transPortAddr = st.nextToken();
logger.debug("transPortAddr ---{}", transPortAddr);
transportClient = transportClient.addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName(transPortAddr), 9300));
}
The above code is loaded as singleton on JVM startup. We are using the BulkProcessor API to do add/delete documents and search api(on transport client) to do document search
Thanks
sunder
© 2020. All Rights Reserved - Elasticsearch
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant logo are trademarks of the Apache Software Foundation in the United States and/or other countries.