# Is a client expensive in terms of creation?

**URL:** <https://discuss.elastic.co/t/is-a-client-expensive-in-terms-of-creation/3881>\
**Category:** Elasticsearch\
**Created:** [February 4, 2011, 12:05pm UTC](https://discuss.elastic.co/t/is-a-client-expensive-in-terms-of-creation/3881 "2011-02-04T12:05:40Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Enrique\_Medina\_Monte](https://avatars.discourse-cdn.com/v4/letter/e/4491bb/32.png) [@Enrique\_Medina\_Monte](https://discuss.elastic.co/u/Enrique_Medina_Monte)\
**Post date:** [February 4, 2011, 12:05pm UTC](https://discuss.elastic.co/t/is-a-client-expensive-in-terms-of-creation/3881/1 "2011-02-04T12:05:40Z")

</div>

Hi,

Being used to working with Hibernate, for instance, I know that I shouldn't  
be creating 'sessionFactory' instances happily, as they are quite expensive  
to create.

So my question applies now to clients in ES: are they expensive to  
create/destroy or, on the other hand, they are so light that I can  
create/destroy them as many times as I want in my application?

My application uses the Transport Client to send index/search requests to a  
remote ES server. And these requests' frequency can vary depending on  
products' catalogs availability, so it could be from several times a day to  
once a month for each catalog.

Thanks.

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [February 4, 2011, 12:07pm UTC](https://discuss.elastic.co/t/is-a-client-expensive-in-terms-of-creation/3881/2 "2011-02-04T12:07:26Z")

</div>

The client should be instantiated once and used throughout the lifecycle of the application. Similar to Hibernate SeassionFactory.  
On Friday, February 4, 2011 at 2:05 PM, Enrique Medina Montenegro wrote:

> Hi,
> 
> Being used to working with Hibernate, for instance, I know that I shouldn't be creating 'sessionFactory' instances happily, as they are quite expensive to create.
> 
> So my question applies now to clients in ES: are they expensive to create/destroy or, on the other hand, they are so light that I can create/destroy them as many times as I want in my application?
> 
> My application uses the Transport Client to send index/search requests to a remote ES server. And these requests' frequency can vary depending on products' catalogs availability, so it could be from several times a day to once a month for each catalog.
> 
> Thanks.

---

<div class="post-metadata">

**Author:** ![Enrique\_Medina\_Monte](https://avatars.discourse-cdn.com/v4/letter/e/4491bb/32.png) [@Enrique\_Medina\_Monte](https://discuss.elastic.co/u/Enrique_Medina_Monte)\
**Post date:** [February 4, 2011, 12:09pm UTC](https://discuss.elastic.co/t/is-a-client-expensive-in-terms-of-creation/3881/3 "2011-02-04T12:09:01Z")

</div>

Thanks a lot for the prompt response.

I pressume this applies to any type of client, no matter whether this is  
Transport, Node, Local, right?

On Fri, Feb 4, 2011 at 1:07 PM, Shay Banon [shay.banon@elasticsearch.com](mailto:shay.banon@elasticsearch.com)wrote:

> The client should be instantiated once and used throughout the lifecycle  
> of the application. Similar to Hibernate SeassionFactory.
> 
> On Friday, February 4, 2011 at 2:05 PM, Enrique Medina Montenegro wrote:
> 
> Hi,
> 
> Being used to working with Hibernate, for instance, I know that I shouldn't  
> be creating 'sessionFactory' instances happily, as they are quite expensive  
> to create.
> 
> So my question applies now to clients in ES: are they expensive to  
> create/destroy or, on the other hand, they are so light that I can  
> create/destroy them as many times as I want in my application?
> 
> My application uses the Transport Client to send index/search requests to a  
> remote ES server. And these requests' frequency can vary depending on  
> products' catalogs availability, so it could be from several times a day to  
> once a month for each catalog.
> 
> Thanks.

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [February 4, 2011, 12:09pm UTC](https://discuss.elastic.co/t/is-a-client-expensive-in-terms-of-creation/3881/4 "2011-02-04T12:09:54Z")

</div>

Yes.  
On Friday, February 4, 2011 at 2:09 PM, Enrique Medina Montenegro wrote:

> Thanks a lot for the prompt response.
> 
> I pressume this applies to any type of client, no matter whether this is Transport, Node, Local, right?
> 
> On Fri, Feb 4, 2011 at 1:07 PM, Shay Banon [shay.banon@elasticsearch.com](mailto:shay.banon@elasticsearch.com) wrote:
> 
> > The client should be instantiated once and used throughout the lifecycle of the application. Similar to Hibernate SeassionFactory.  
> > On Friday, February 4, 2011 at 2:05 PM, Enrique Medina Montenegro wrote:
> > 
> > > Hi,
> > > 
> > > Being used to working with Hibernate, for instance, I know that I shouldn't be creating 'sessionFactory' instances happily, as they are quite expensive to create.
> > > 
> > > So my question applies now to clients in ES: are they expensive to create/destroy or, on the other hand, they are so light that I can create/destroy them as many times as I want in my application?
> > > 
> > > My application uses the Transport Client to send index/search requests to a remote ES server. And these requests' frequency can vary depending on products' catalogs availability, so it could be from several times a day to once a month for each catalog.
> > > 
> > > Thanks.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 4:12am UTC](https://discuss.elastic.co/t/is-a-client-expensive-in-terms-of-creation/3881/5 "2017-07-06T04:12:36Z")

</div>


