Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Should we always reuse one client #188

Closed
dixingxing0 opened this issue May 19, 2022 · 2 comments
Closed

Should we always reuse one client #188

dixingxing0 opened this issue May 19, 2022 · 2 comments

Comments

@dixingxing0
Copy link

dixingxing0 commented May 19, 2022

I recently looked at my colleague's code, he used an connection pool to maintain over handreds gohbase clients.
After a little dig into gohbase code, it seems like gohbase client support concurrency.
So i want to know, what is the best practice, should we reuse one client or maintain an client pool.

@dethi
Copy link
Collaborator

dethi commented May 19, 2022

Yes, gohbase is concurrency safe. Reusing one client is the recommended way for multiple reason:

  • less connections to regionservers
  • less lookup to the meta table (since there is one cache per client)
  • better batching of RPCs. The client automatically batches RPCs per regionserver (default value https://github.com/tsuna/gohbase/blob/master/client.go#L25-L26) even if the client doesn't expose the batching mechanism. The recommended way right now is to start for example 100 goroutines doing .Put at the same time, they will all get batched automatically together (because the RS will reach the max queue size or the flush interval) and the reply will be handled to each call individually.

It's possible that to obtain a specific throughput, one may need a pool of clients, but I wouldn't expect that number to be in the hundreds. If you have some target req/s, it could be interesting to benchmark. We haven't benchmarked gohbase in a long time.

@dixingxing0
Copy link
Author

Thanks @dethi, i will close this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants