Search code examples
google-cloud-bigtable

Bigtable NewClient - Global or per request?


For a Go API that uses Bigtable during each request, should NewClient be called once when the app starts and the same client be used for each request, or should NewClient be called for each request?


Solution

  • I am the product manager of Google Cloud Bigtable.

    You should reuse the client, because creating a new client is expensive (e.g., to set up authentication), and should not be recreated for each request.

    We'll update the documentation to be more clear on this topic.