phoenix-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gabriel Reid <gabriel.r...@gmail.com>
Subject Re: Whether or not multi-thread share the single PhoenixConnection object?
Date Tue, 13 Jan 2015 09:50:43 GMT
Hi David,

The PhoenixConnection class is not thread-safe, and shouldn't be
shared over multiple threads. I think that this is probably the case
with quite a few other JDBC drivers as well, so it's generally safer
to use a JDBC connection pool if you want to use connections in
multiple threads.

If I remember correctly, a single HConnection is used (and shared) by
multiple PhoenixConnection objects that have been instantiated from
the same Driver instance, so there shouldn't be any performance
overhead to using a single Phoenix connection per thread.

- Gabriel


On Tue, Jan 13, 2015 at 10:31 AM, David chen <c77_cn@163.com> wrote:
> My application will base on Phoenix, and response the multi-user query. I
> plan to create a thread pool that its per thread will correspond to a user
> query. But i don't sure whether or not multi-thread in the pool should share
> the single PhoenixConnection object?
> I remember that HBase community advice that the multi-thread should share
> the single HConnection object as much as possible.
> Any ideas can be appreciated!

Mime
View raw message