# Best practice working with Client

**URL:** <https://discuss.elastic.co/t/best-practice-working-with-client/80351>\
**Category:** Elasticsearch\
**Created:** [March 28, 2017, 7:06pm UTC](https://discuss.elastic.co/t/best-practice-working-with-client/80351 "2017-03-28T19:06:31Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![cmastrantono](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cmastrantono/32/16813_2.png) [@cmastrantono](https://discuss.elastic.co/u/cmastrantono)\
**Post date:** [March 28, 2017, 7:06pm UTC](https://discuss.elastic.co/t/best-practice-working-with-client/80351/1 "2017-03-28T19:06:31Z")

</div>

Hi,

I'm wondering, in case we have to make an exhaustive use of ES, if it is better to create the Client (with TransportClient.builder) in every request or to have a kind of Factory, with a pool of Clients already initialized and ready to use.

In other words... of expensive is to create a Client on every request if we have a few (10-20) requests per second, always to the same index?

Thanks in advance!  
Cristian.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [March 28, 2017, 8:39pm UTC](https://discuss.elastic.co/t/best-practice-working-with-client/80351/2 "2017-03-28T20:39:40Z")

</div>

Singleton. Use a factory yes.

---

<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:** [March 31, 2017, 8:39pm UTC](https://discuss.elastic.co/t/best-practice-working-with-client/80351/3 "2017-03-31T20:39:50Z")

</div>

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.
