You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@solr.apache.org by mtn search <se...@gmail.com> on 2023/05/30 17:13:11 UTC
SolrJ client question
Hello,
What is the guidance regarding when to reuse versus when to recreate a
SolrJ client?
Specifically, the app in question is a provisioning app that will
periodically create collections/aliases for a client. The calls to SolrJ
might be hours to sometimes days apart. Querying/Indexing is handled by
another app.
My initial thought is to create a client as needed rather than to reuse due
to the gap in time between usage. Feedback?
Thanks,
Matt
Re: SolrJ client question
Posted by mtn search <se...@gmail.com>.
Thanks Shawn and Eric!
On Tue, May 30, 2023 at 2:57 PM Eric Pugh <ep...@opensourceconnections.com>
wrote:
> I think that creating it when you run it and closing it will be just
> fine. As Shawn said, it’ll be “well under a second” ;-)./
>
> > On May 30, 2023, at 2:01 PM, Shawn Heisey <el...@elyograg.org> wrote:
> >
> > On 5/30/23 11:13, mtn search wrote:
> >> My initial thought is to create a client as needed rather than to reuse
> due
> >> to the gap in time between usage. Feedback?
> >
> > My general advice would be to create a client when the program starts
> and close it when the program ends. The clients are designed for long term
> thread-safe usage.
> >
> > Recent SolrJ clients use a Jetty HttpClient, which runs threads of its
> own. But those threads should be idle if there are no requests underway.
> >
> > I do not know how long it takes to spin up a new client. Whatever the
> timespan is, you may or may not consider it to be trivial. Most likely it
> happens in well under a second.
> >
> > Thanks,
> > Shawn
>
> _______________________
> Eric Pugh | Founder & CEO | OpenSource Connections, LLC | 434.466.1467 |
> http://www.opensourceconnections.com <
> http://www.opensourceconnections.com/> | My Free/Busy <
> http://tinyurl.com/eric-cal>
> Co-Author: Apache Solr Enterprise Search Server, 3rd Ed <
> https://www.packtpub.com/big-data-and-business-intelligence/apache-solr-enterprise-search-server-third-edition-raw>
>
> This e-mail and all contents, including attachments, is considered to be
> Company Confidential unless explicitly stated otherwise, regardless of
> whether attachments are marked as such.
>
>
Re: SolrJ client question
Posted by Eric Pugh <ep...@opensourceconnections.com>.
I think that creating it when you run it and closing it will be just fine. As Shawn said, it’ll be “well under a second” ;-)./
> On May 30, 2023, at 2:01 PM, Shawn Heisey <el...@elyograg.org> wrote:
>
> On 5/30/23 11:13, mtn search wrote:
>> My initial thought is to create a client as needed rather than to reuse due
>> to the gap in time between usage. Feedback?
>
> My general advice would be to create a client when the program starts and close it when the program ends. The clients are designed for long term thread-safe usage.
>
> Recent SolrJ clients use a Jetty HttpClient, which runs threads of its own. But those threads should be idle if there are no requests underway.
>
> I do not know how long it takes to spin up a new client. Whatever the timespan is, you may or may not consider it to be trivial. Most likely it happens in well under a second.
>
> Thanks,
> Shawn
_______________________
Eric Pugh | Founder & CEO | OpenSource Connections, LLC | 434.466.1467 | http://www.opensourceconnections.com <http://www.opensourceconnections.com/> | My Free/Busy <http://tinyurl.com/eric-cal>
Co-Author: Apache Solr Enterprise Search Server, 3rd Ed <https://www.packtpub.com/big-data-and-business-intelligence/apache-solr-enterprise-search-server-third-edition-raw>
This e-mail and all contents, including attachments, is considered to be Company Confidential unless explicitly stated otherwise, regardless of whether attachments are marked as such.
Re: SolrJ client question
Posted by Shawn Heisey <el...@elyograg.org>.
On 5/30/23 11:13, mtn search wrote:
> My initial thought is to create a client as needed rather than to reuse due
> to the gap in time between usage. Feedback?
My general advice would be to create a client when the program starts
and close it when the program ends. The clients are designed for long
term thread-safe usage.
Recent SolrJ clients use a Jetty HttpClient, which runs threads of its
own. But those threads should be idle if there are no requests underway.
I do not know how long it takes to spin up a new client. Whatever the
timespan is, you may or may not consider it to be trivial. Most likely
it happens in well under a second.
Thanks,
Shawn