haskell-github-trust / ekg-core

Library for tracking system metrics
BSD 3-Clause "New" or "Revised" License
40 stars 39 forks source link

[Feature Request] Distributions should track percentiles #11

Open MaxGabriel opened 8 years ago

MaxGabriel commented 8 years ago

A nice feature of StatsD's timers is that they track percentiles, in addition to things that Distribution already tracks like the min, max, mean, etc. Having e.g. 99th and 95th percentile data is useful when you know the mean could be biased by outliers. For example:

@tibbe had this to say about the implementation:

Context on why the Distribution metric works as it does: statsd takes the approach of computing percentiles by storing every single data point. This doesn't scale well (e.g. we don't do it this way at Google for that reason). Since I wrote ekg with the Google use case in mind I didn't want to copy this limitation into ekg. The best way I know how to do this is by storing histograms (not the theoretically best approach, but the best engineering approach) and computing approximate percentiles from that. I planned to implement that, but never got around to it. It might be possible to make ekg work with the statsd approach, but it would require reworking the internals (e.g. so that each metric update results in a callback, from which we could send a packet to statsd).

jpfuentes2 commented 8 years ago

Edited: Ignore me! I see there's already a client you've written.

It might be possible to make ekg work with the statsd approach, but it would require reworking the internals (e.g. so that each metric update results in a callback, from which we could send a packet to statsd).

Were you thinking of just implementing the callback and no StatsD client?

The best way I know how to do this is by storing histograms (not the theoretically best approach, but the best engineering approach) and computing approximate percentiles from that.

Have you seen HdrHistogram? It's a preferred alternative to an ordinary histogram since it avoids coordinated omission.

tibbe commented 8 years ago

Have you seen HdrHistogram? It's a preferred alternative to an ordinary histogram since it avoids coordinated omission.

I have. Unfortunately I believe they suffer from the same problem as most "theoretically better than a histogram" approaches, namely that you cannot merge two HdrHistograms created on different machines. Being able to gather statistics separately and then compute global quantiles is a really important property.

jpfuentes2 commented 8 years ago

Being able to gather statistics separately and then compute global quantiles is a really important property.

Absolutely agree here as well. I've seen both approaches used in tandem to good effect.

Thanks!