Go Bigtable Client Questions

119 views
Skip to first unread message

Derek Perkins

unread,
Jul 23, 2015, 10:29:05 AM7/23/15
to Google Cloud Bigtable Discuss
While implementing the Go Bigtable package, I had a few questions that will affect how I structure it. My initial thought is to maintain a map[tableID]*bigtable.Table and use a single client at the instance level for the life of the instance (see below).
  1. Is a Bigtable client / table safe for concurrent access?
  2. What's the lifecycle of the client / table? Should I treat it like a MySQL connection and leave the connection open indefinitely?

var (
tables = map[string]*bigtable.Table{}
mu     = &sync.RWMutex{}
client *bigtable.Client
)


David Symonds

unread,
Jul 23, 2015, 5:30:26 PM7/23/15
to google-cloud-b...@googlegroups.com
On 24 July 2015 at 00:29, Derek Perkins <de...@derekperkins.com> wrote:

> Is a Bigtable client / table safe for concurrent access?

Once created, yes.

> What's the lifecycle of the client / table? Should I treat it like a MySQL
> connection and leave the connection open indefinitely?

Yes, you can (and probably should) leave the connection open for the
lifetime of your program if you're going to keep using it. It will
transparently redial when a connection breaks.

Derek Perkins

unread,
Jul 23, 2015, 7:39:10 PM7/23/15
to Google Cloud Bigtable Discuss, dsym...@golang.org
Great, thanks for clarifying that. Is there any issue with a single client being used to access multiple tables? Does every query use its own connection, or is the implementation more like MySQL connection pools so that short queries don't get caught waiting for larger ones?

David Symonds

unread,
Jul 23, 2015, 7:42:41 PM7/23/15
to Derek Perkins, Google Cloud Bigtable Discuss
It's probably fine to have a single client for multiple tables. It's
using gRPC and HTTP/2 under the hood, and one long query won't block
other queries from making progress.

Derek Perkins

unread,
Jul 23, 2015, 7:53:44 PM7/23/15
to Google Cloud Bigtable Discuss, dsym...@golang.org
Great, that's super helpful.
Reply all
Reply to author
Forward
0 new messages