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

Add wait statistics to pools #7

Merged
merged 1 commit into from
Mar 1, 2019
Merged

Add wait statistics to pools #7

merged 1 commit into from
Mar 1, 2019

Conversation

stevenh
Copy link

@stevenh stevenh commented Mar 1, 2019

Add WaitCount and WaitDuration stats to pool stats to enable tracking of the delays introduced by waiting for connections from the pool.

This uses the same properties as database/sql so its familiar to users.

Addresses: gomodule#403

redis/pool.go Outdated
active int // the number of open connections in the pool
ch chan struct{} // limits open connections when p.Wait is true
idle idleList // idle connections
waitCount int64 // Total number of connections waited for.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For consistency sake: Total -> total

redis/pool.go Outdated
ch chan struct{} // limits open connections when p.Wait is true
idle idleList // idle connections
waitCount int64 // Total number of connections waited for.
waitDuration time.Duration // Total time waited for new connections.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For consistency sake: Total -> total

d.check_all(message, p, dialed, open, inuse, 0, 0)
}

func (d *poolDialer) check_all(message string, p *redis.Pool, dialed, open, inuse int, waitCountMax int64, waitDurationMax time.Duration) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check_all -> checkAll


// wait indicates if we believe it will block so its not 100% accurate
// however for stats it should be good enough.
wait := len(p.ch) == 0

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inherently racey but if you want to just get wait stats when you think the channel will block, not sure there is any other way.

Is there any reason you can't do the wait stat calculation all the time? It'll be ~0 in non-blocking cases so maybe not much use?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would just break the count as every request would flagged as waited.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeh thats not ideal

Add WaitCount and WaitDuration stats to pool stats to enable tracking of the delays introduced by waiting for connections from the pool.

This uses the same properties as database/sql so its familiar to users.

Addresses: gomodule#403
@stevenh stevenh merged commit 4dd596e into master Mar 1, 2019
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

Successfully merging this pull request may close these issues.

2 participants