# Opening TransportClient connection per Index

**URL:** <https://discuss.elastic.co/t/opening-transportclient-connection-per-index/18506>\
**Category:** Elasticsearch\
**Created:** [July 7, 2014, 3:45pm UTC](https://discuss.elastic.co/t/opening-transportclient-connection-per-index/18506 "2014-07-07T15:45:55Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![AsyncAwait](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/asyncawait/32/1346_2.png) [@AsyncAwait](https://discuss.elastic.co/u/AsyncAwait)\
**Post date:** [July 7, 2014, 3:45pm UTC](https://discuss.elastic.co/t/opening-transportclient-connection-per-index/18506/1 "2014-07-07T15:45:55Z")

</div>

I have a use case in which i want to create per index per account (assume  
an account represents an user), all data belong to that user will be kept  
in that index. My question is - what if we create connection per index and  
keep it alive during the user session. So this means for 100 active users,  
there will be 100 connections from TransportClient to ES Cluster. I don't  
have a reason why I have 100 instances of TransportClient has to be  
initialized and kept in memory. Not sure if a singleton would unnecessarily  
bring thread locks.

Any help is greatly appreciated.

Thanks

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/ce54bd4b-1c11-429a-8998-76482f051375%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/ce54bd4b-1c11-429a-8998-76482f051375%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![jprante](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jprante/32/44941_2.png) [@jprante](https://discuss.elastic.co/u/jprante)\
**Post date:** [July 7, 2014, 6:09pm UTC](https://discuss.elastic.co/t/opening-transportclient-connection-per-index/18506/2 "2014-07-07T18:09:59Z")

</div>

You can enlarge thread pools in TransportClient, also Netty worker threads.  
User session states should be managed in the front-end service (reverse  
proxy or Java middleware e.g.) so it is still ok to use a singleton  
TransportClient since it is stateless. It handles requests and the  
corresponding responses.

If 100 users are active at the same time, resources might get low, so you  
should think about ramping up a line of front-end services on more than one  
machine to balance the front-end load.

Jörg

On Mon, Jul 7, 2014 at 5:45 PM, AsyncAwait [vadivtk@gmail.com](mailto:vadivtk@gmail.com) wrote:

> I have a use case in which i want to create per index per account (assume  
> an account represents an user), all data belong to that user will be kept  
> in that index. My question is - what if we create connection per index and  
> keep it alive during the user session. So this means for 100 active users,  
> there will be 100 connections from TransportClient to ES Cluster. I don't  
> have a reason why I have 100 instances of TransportClient has to be  
> initialized and kept in memory. Not sure if a singleton would unnecessarily  
> bring thread locks.
> 
> Any help is greatly appreciated.
> 
> Thanks
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/ce54bd4b-1c11-429a-8998-76482f051375%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/ce54bd4b-1c11-429a-8998-76482f051375%40googlegroups.com)  
> [https://groups.google.com/d/msgid/elasticsearch/ce54bd4b-1c11-429a-8998-76482f051375%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/ce54bd4b-1c11-429a-8998-76482f051375%40googlegroups.com?utm_medium=email&utm_source=footer)  
> .  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAKdsXoEjt3qCUWD\_5rxv84XL8BYNMzy2dKsfsfr8j-017cNbow%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAKdsXoEjt3qCUWD_5rxv84XL8BYNMzy2dKsfsfr8j-017cNbow%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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, 1:17am UTC](https://discuss.elastic.co/t/opening-transportclient-connection-per-index/18506/3 "2017-07-06T01:17:30Z")

</div>


