# How to make PreBuiltXPackTransportClient reusable？

**URL:** <https://discuss.elastic.co/t/how-to-make-prebuiltxpacktransportclient-reusable/168767>\
**Category:** Elasticsearch\
**Created:** [February 18, 2019, 6:22am UTC](https://discuss.elastic.co/t/how-to-make-prebuiltxpacktransportclient-reusable/168767 "2019-02-18T06:22:31Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![iamazy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/iamazy/32/36501_2.png) [@iamazy](https://discuss.elastic.co/u/iamazy)\
**Post date:** [February 18, 2019, 6:22am UTC](https://discuss.elastic.co/t/how-to-make-prebuiltxpacktransportclient-reusable/168767/1 "2019-02-18T06:22:31Z")

</div>

Hello  
Create a PreBuiltXPackTransportClient object need username and password,so every logined person will has their own PreBuiltXPackTransportClient object，  
In order to make PreBuiltXPackTransportClient object reusable，I store them in a map，but if millions of people login in my system for searching，the map will take up more memory，and I don't known which PreBuiltXPackTransportClient object I should remove and clean .  
What should I do for this problem？

---

<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:** [February 18, 2019, 6:54am UTC](https://discuss.elastic.co/t/how-to-make-prebuiltxpacktransportclient-reusable/168767/2 "2019-02-18T06:54:56Z")

</div>

You should move to the REST client. It has a Request Option that is probably useful for that.

See [https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/java-rest-low-usage-requests.html#java-rest-low-usage-request-options](https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/java-rest-low-usage-requests.html#java-rest-low-usage-request-options)

---

<div class="post-metadata">

**Author:** ![iamazy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/iamazy/32/36501_2.png) [@iamazy](https://discuss.elastic.co/u/iamazy)\
**Post date:** [February 18, 2019, 10:27am UTC](https://discuss.elastic.co/t/how-to-make-prebuiltxpacktransportclient-reusable/168767/3 "2019-02-18T10:27:44Z")

</div>

Thanks dadoonet, I will try it

---

<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 18, 2019, 10:27am UTC](https://discuss.elastic.co/t/how-to-make-prebuiltxpacktransportclient-reusable/168767/4 "2019-03-18T10:27:48Z")

</div>

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