# When using Node.js cluster, how to pass ES client instance from master to worker?

**URL:** <https://discuss.elastic.co/t/when-using-node-js-cluster-how-to-pass-es-client-instance-from-master-to-worker/54059>\
**Category:** Elasticsearch\
**Created:** [June 27, 2016, 4:49pm UTC](https://discuss.elastic.co/t/when-using-node-js-cluster-how-to-pass-es-client-instance-from-master-to-worker/54059 "2016-06-27T16:49:02Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![zhangke](https://avatars.discourse-cdn.com/v4/letter/z/839c29/32.png) [@zhangke](https://discuss.elastic.co/u/zhangke)\
**Post date:** [June 27, 2016, 4:49pm UTC](https://discuss.elastic.co/t/when-using-node-js-cluster-how-to-pass-es-client-instance-from-master-to-worker/54059/1 "2016-06-27T16:49:02Z")

</div>

When I use cluster module of Node.js to start multiple threads to do ES query, a problem occurs that the ES client instance can't be passed from master to workers.

In the function **worker.send(message[, sendHandle][, callback])** of cluster module, **message** object will be serialized using JSON.stringify() internally. In this way, the ES client object will be destroyed when passing through **message** object.

Is there any way to share ES client instance between master and workers?

Thanks for your help.

---

<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 5, 2017, 10:40pm UTC](https://discuss.elastic.co/t/when-using-node-js-cluster-how-to-pass-es-client-instance-from-master-to-worker/54059/2 "2017-07-05T22:40:08Z")

</div>

Closed on July 5, 2017, 10:40pm UTC


