You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by vicky desai <vi...@germinait.com> on 2014/07/25 11:48:04 UTC
Facing issue while implementing connection pooling with solr
0 down vote favorite
I have this requirement where I want to limit the number of concurrent calls
to solr say 50. So I am trying to implement connection pooling in HTTP
client which is then used in solr object HttpSolrServer. Please find the
code below
HttpClient httpclient = new DefaultHttpClient();
httpclient.getParams().setParameter(
HttpClientUtil.PROP_MAX_CONNECTIONS_PER_HOST, 50);
httpclient.getParams().setParameter(
HttpClientUtil.PROP_MAX_CONNECTIONS, 50);
HttpSolrServer httpSolrServer = new HttpSolrServer(
"solr url",httpclient);
SolrQuery solrQuery = new SolrQuery("*:*");
for (int i = 0; i < 100000000; i++) {
long numFound = httpSolrServer.query(solrQuery).getResults()
.getNumFound();
System.out.println(numFound);
}`
I was expecting only 50 connections to be created from my application to
solr and then probably experience some slowness until the older connections
are freed. However at every regular interval a new connection is created
despite there are waiting connections at solr end and those connections are
never used again.
Example Output
tcp 0 0 192.168.0.241:22 192.168.0.109:54120 ESTABLISHED
tcp 0 0 ::ffff:192.168.0.241:8190 ::ffff:192.168.0.109:47382 TIME_WAIT
tcp 0 0 ::ffff:192.168.0.241:8190 ::ffff:192.168.0.109:47383 ESTABLISHED
tcp 0 0 ::ffff:192.168.0.241:8190 ::ffff:192.168.0.109:47371 TIME_WAIT
tcp 0 0 ::ffff:192.168.0.241:8190 ::ffff:192.168.0.109:47381 TIME_WAIT
where 109 is the ip where I am running my application and 241 is ip where
solr is run. In this case ffff:192.168.0.109:47382 will never be used again
and it is finally terminated by solr
Am i going wrong somewhere. Any help will be highly appreciated
--
View this message in context: http://lucene.472066.n3.nabble.com/Facing-issue-while-implementing-connection-pooling-with-solr-tp4149176.html
Sent from the Solr - User mailing list archive at Nabble.com.