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 Gembali Satish kumar <ge...@gmail.com> on 2018/08/30 08:13:44 UTC

Need Help on Solr Client connection Pooling

Hi Team,

Need some help on  Client connection object pooling
I am using SolrJ API to connect the Solr.

This below snippet I used to create the client object.

*SolrClient client = new HttpSolrClient.Builder(*
* SolrUtil.getSolrURL(tsConfigUtil.getClusterAdvertisedAddress(),
aInCollectionName)).build();*

after my job search done, I am closing my client.
*client.close();*

but from UI getting more requests to search the data
I think to create the *client object *on every request is costly is there
any way to pool the *SolrClient objects?*?
If there kindly share me the reference

Thanks and Regards,
Satish

Re: Need Help on Solr Client connection Pooling

Posted by Shawn Heisey <ap...@elyograg.org>.
On 8/30/2018 2:13 AM, Gembali Satish kumar wrote:
> *SolrClient client = new HttpSolrClient.Builder(*
> * SolrUtil.getSolrURL(tsConfigUtil.getClusterAdvertisedAddress(),
> aInCollectionName)).build();*
>
> after my job search done, I am closing my client.
> *client.close();*
>
> but from UI getting more requests to search the data
> I think to create the *client object *on every request is costly is there
> any way to pool the *SolrClient objects?*?
> If there kindly share me the reference

Yes, creating the client on every request is costly.

Supplementing what Shalin told you:

Exactly which version of SolrJ you're running can affect how many 
threads can use the object at the same time, unless you explicitly build 
it to handle more.  Newer versions set it up with lots of thread 
capability, but older versions just create the internal HttpClient 
object with defaults.  By default, HttpClient only allows two threads.

What version of SolrJ are you using?

Thanks,
Shawn


Re: Need Help on Solr Client connection Pooling

Posted by Shalin Shekhar Mangar <sh...@gmail.com>.
You should create a single HttpSolrClient and re-use for all requests. It
is thread safe and creates an Http connection pool internally (well Apache
HttpClient does).

On Thu, Aug 30, 2018 at 2:28 PM Gembali Satish kumar <
gembalisatishkumar@gmail.com> wrote:

> Hi Team,
>
> Need some help on  Client connection object pooling
> I am using SolrJ API to connect the Solr.
>
> This below snippet I used to create the client object.
>
> *SolrClient client = new HttpSolrClient.Builder(*
> * SolrUtil.getSolrURL(tsConfigUtil.getClusterAdvertisedAddress(),
> aInCollectionName)).build();*
>
> after my job search done, I am closing my client.
> *client.close();*
>
> but from UI getting more requests to search the data
> I think to create the *client object *on every request is costly is there
> any way to pool the *SolrClient objects?*?
> If there kindly share me the reference
>
> Thanks and Regards,
> Satish
>


-- 
Regards,
Shalin Shekhar Mangar.