Multiple hazelcast clients

172 views
Skip to first unread message

cka...@gmail.com

unread,
Jan 17, 2018, 8:27:01 AM1/17/18
to Hazelcast
Hi,

I have a 3 node hazelcast cluster running and have a singleton  client initialized like this - HazelcastClient.newHazelcastClient(clientConfig).

My question is - right now, i have only one hazelcast client initialized and all services use it . is it advised to eagerly create a number of hazelcast clients , put them in some threadpool and use in round robin fashion by services. will it increase my throughput and performance?  or is it that - hazelcast internally maintains a threadpool of connections to serve user requests , so i dont need to maintain such threadpool on my own.  I went through some of the source code, but could not find one.


Thanks
Chandra

Alparslan Avcı

unread,
Jan 17, 2018, 10:06:37 AM1/17/18
to Hazelcast
Hi Chandra,

You do not need to create a number of clients, since Hazelcast client itself is thread-safe and can handle multiple requests internally. You can use the single instance for multiple operations. 

Regards,
Alparslan

cka...@gmail.com

unread,
Jan 18, 2018, 3:33:49 AM1/18/18
to Hazelcast
Thanks for the reply Alparslan

One more question out of curiosity  - in which class does this multiple request handling logic is defined. can you give me a hint here. Lots of our critical services are now moving to hazelcast, so just wanted to make sure about what code is doing internally

Thanks
Chandra

Alparslan Avcı

unread,
Jan 18, 2018, 3:30:50 PM1/18/18
to Hazelcast
Hi Chandra,

Hazelcast Client is totally designed as thread-safe and handling multiple requests. Thus, you need to investigate nearly all the codes to see how it is designed. But as a hint, I can suggest you to have a look at `com.hazelcast.client.spi.impl.SmartClientInvocationService`, `com.hazelcast.client.spi.impl.AbstractClientInvocationService`, `com.hazelcast.client.connection.nio.ClientConnectionManagerImpl`, and `com.hazelcast.client.connection.nio.ClientConnection` classes.

You can access the source codes here: https://github.com/hazelcast/hazelcast

Regards,
Alparslan
Reply all
Reply to author
Forward
0 new messages