Java Library - best practice

Brian Roach roach at basho.com
Tue May 27 23:23:09 EDT 2014


Henning,

Yes, the Java client is designed to be used across multiple threads.
Instantiate it once and share it.

As you noted, there's options in the configuration for tuning the
internal connection pool. The client maintains a pool of connections
to the Riak node so that multi-threaded applications aren't creating a
new connection every time an operation is performed.

Thanks,
- Roach

On Mon, May 26, 2014 at 4:44 AM, Henning Verbeek <hankipanky at gmail.com> wrote:
> I'd like to get some advice how best to handle clients in a
> multi-threaded Java application. Riak is 1.4.8, java client library is
> 1.4.4, using the protocol buffers clients.
>
> I'm referring specifically to
> http://basho.github.io/riak-java-client/1.4.4/com/basho/riak/client/RiakFactory.html#newClient(com.basho.riak.client.raw.config.Configuration).
> Should I use one single instance of IRiakClient per JVM and share it
> between all threads that access Riak? Or should each thread obtain its
> own, new client instance when needed and terminate it again
> afterwards?
>
> If the PBConfiguration specifies a poolSize, is that being handled in
> the Factory?
>
> Thanks, Henning
>
> _______________________________________________
> riak-users mailing list
> riak-users at lists.basho.com
> http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com




More information about the riak-users mailing list