Reputation: 53
Is there a maximum number of DatabaseClient
that can be created for an instance of Google Cloud Spanner?
Will the number of DatabaseClient
affect to the performance?
Upvotes: 0
Views: 322
Reputation: 8099
DatabaseClients are cached, so for identical database ids Spanner#getDatabaseClient
returns the same instance of DatabaseClient
.
Internally DatabaseClient
opens multiple gRPC channels and maintains the session pool. This is something that can be configured with SpannerOptions#setNumChannels and SpannerOptions#setSessionPoolOptions.
The default number of open channels is optimized for low latency requests and works well in most cases. If you are sending high latency requests increasing number of channels potentially can lead to better throughput.
Upvotes: 2