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 Shawn Heisey <so...@elyograg.org> on 2011/11/06 19:37:11 UTC

SolrJ - threading, http clients, connection managers

In my long-running build system that uses SolrJ, I have been looking 
into reusing HttpClient and connection managers.  This snippet is the 
latest iteration of my initialization code for an individual core, based 
on what I've been able to figure out with Google:

   _mgr = new MultiThreadedHttpConnectionManager();
   _mgr.getParams().setTcpNoDelay(true);
   _client = new HttpClient();
   _solrServer = new CommonsHttpSolrServer(serverBaseUrl, _client);
   _solrCore = new CommonsHttpSolrServer(coreBaseUrl, _client);

I am not reusing these objects, so there are copies every one of my core 
objects, of which I have 28.  Half of those are build cores that only 
get used during a full rebuild, leaving 14 of them that get used regularly.

Three questions:  1) Is it safe to reuse a single _mgr and _client 
across all 28 cores?  The cores are not all on the same machine.  2) 
Would you recommend any other explicit options to make it more efficient 
in terms of memory and/or speed?

I think the answer to question 1 is yes, just looking for absolute 
confirmation.

Thanks,
Shawn


Re: SolrJ - threading, http clients, connection managers

Posted by pravesh <su...@yahoo.com>.
>1) Is it safe to reuse a single _mgr and _client
across all 28 cores?

both are thread-safe API as per HttpClient specs. You shld go ahead with
this.

Regds
Pravesh

--
View this message in context: http://lucene.472066.n3.nabble.com/SolrJ-threading-http-clients-connection-managers-tp3485012p3486436.html
Sent from the Solr - User mailing list archive at Nabble.com.