-
Notifications
You must be signed in to change notification settings - Fork 113
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
Connection contention #356
Comments
Hi @ltagliamonte , can you clarify if you're using v3 or v4? The way the Pool works in each is extremely different, so it's not possible to answer without knowing which we're talking about. |
Hello @mediocregopher I'm using v4 |
Nice, thanks. So in v4 this question is a bit tricky because there's potentially two places which could be blocking:
If you want to know how many non-shareable Actions are taking place within your Pool you could inspect it using a very simple interface: type poolWrapper struct {
radix.Client
nonShareableActionsGauge atomic.Uint64
}
func (pw *poolWrapper) Do(ctx context.Context, a radix.Action) error {
if !a.Properties().CanShareConn {
pw.nonShareableActionsGauge.Add(1)
defer pw.nonShareableActionsGauge.Add(-1)
// Or however you want to measure it
}
return pw.Client.Do(ctx, a)
}
// Spin up a go-routine to periodically log nonShareableActions
What you asked for, a log message like "Action is blocked because the Pool is too small" is unfortunately not something which is easily determined, because all Actions block for some amount of time. The only question is how long is acceptable. If you're using a metrics server like Prometheus then a wrapper like the above can be a great place to record action times on a histogram, and once the time it takes to Do an Action has gotten too high you increase the Pool size some more. If you're not using Prometheus you could use an in-memory histogram library to the same effect. One final note, which doesn't answer your question but might help, is to check out the |
I was doing a bit of perf tuning and by doubling the connection number my latencies got much better.
I understand that connections are shared and the more connections "the better" but I'd rather have a way to monitor contention on the connection (gorutines that wait for a connection from the pool) than do guess work especially when the size of my worker pool is parameterized.
Is there a way to expose connection contention? Maybe a log enabled via config?
Thanks a lot for the great project!
The text was updated successfully, but these errors were encountered: