Histogram Bucket Design for Latency Metrics: 2026 Guide
TL;DR: Histogram buckets determine how accurately your monitoring system reports percentiles like p50, p95, and p99. Default bucket configurations in Prometheus and OpenTelemetry are generic and frequently produce misleading latency numbers. The fix is to profile your actual latency distribution, use exponential spacing as a foundation, and add explicit boundaries at your SLO thresholds. Aim for 10 to 15 buckets, and make sure your upper bound covers 2 to 3 times your maximum expected latency.
What Is a Histogram Bucket?
A histogram divides a range of observed values into segments called buckets and counts how many observations fall into each one. In metrics systems like Prometheus and OpenTelemetry, histograms don’t store every individual measurement. Instead, they store counts at fixed boundaries, then estimate percentiles by interpolating between those boundaries.
Prometheus-style histograms are cumulative. Each bucket with a given upper bound (labeled le for “less than or equal”) contains the count of all observations at or below that value. A single histogram metric produces three time series:
<name>_bucket{le="<bound>"}for each cumulative count<name>_sumfor the total of all observed values<name>_countfor how many observations were recorded
For example, a histogram tracking HTTP response latency with 10 buckets generates 12 time series (10 buckets plus sum and count). If you’re new to metrics types and instrumentation, understanding this structure is essential before choosing boundaries.
The Prometheus client ships with these default bucket boundaries (in seconds): {0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10}. OpenTelemetry’s SDK provides 15 default explicit bounds ranging from 0 to 10,000. These defaults are designed to work for “generic” use cases, which means they work poorly for most specific ones.
Why Bucket Design Matters
Histogram bucket design for latency metrics is the single biggest factor in whether your percentile calculations are accurate or misleading. The boundaries you choose determine where the monitoring system has resolution and where it’s blind.
A practitioner article from Mercari Engineering gives the clearest illustration of how this goes wrong. Their team used default buckets at 125ms, 250ms, and 500ms. The true p50 latency was around 240ms, with most requests clustered between 230ms and 245ms. But the monitoring system reported p50 as 187ms. Worse, when a developer added an operation that increased latency by roughly 30ms, the dashboard showed a completely different number rather than a proportional shift. The true change was 30ms, but the dashboard made it look like something entirely different.
This happens because of how histogram_quantile() works. It uses linear interpolation between bucket boundaries to estimate where a given percentile falls. If most of your data lands in a single wide bucket, the interpolation has no way to distinguish between values at the low edge and the high edge of that bucket.
The ClickHouse engineering team quantified this problem directly: interpolation inside a bucket can misreport p99 by the full bucket width. In one worked example, a true p99 of 2.4 seconds was reported as 1.25 seconds. That kind of error is not a rounding issue. It’s a measurement failure.
Measure before you configure. See a working histogram setup from code to dashboard in minutes.
Bucket Spacing Strategies
Three main approaches exist for spacing histogram bucket boundaries. Each makes different trade-offs between resolution, coverage, and simplicity.
Linear Spacing
Linear buckets use equal-width intervals (for example, every 50ms from 0 to 500ms). This is rarely the right choice for latency. Latency distributions are skewed, with most values clustered at the low end and a long tail of slow requests. Linear spacing wastes resolution on the tail where you don’t need millisecond precision and lacks resolution at the low end where small differences matter most.
The one scenario where linear spacing works: a metric with a narrow, known range and roughly uniform distribution. That almost never describes latency.
Exponential Spacing
Exponential buckets provide high resolution at low values and progressively coarser resolution at higher values. This matches both how latency distributions actually look and how humans perceive latency. The difference between 10ms and 20ms matters far more than the difference between 1,000ms and 1,010ms.
Logarithmic spacing is ideal when the metric spans several orders of magnitude, which is typical for response times that range from sub-millisecond to multi-second. This is why OpenTelemetry’s exponential histograms use this approach by default.
SLO-Aligned Spacing
The most practical strategy for histogram bucket design for latency metrics is to place boundaries at the thresholds that matter for your service level objectives. If your SLO targets p50 at 100ms and p99 at 500ms, you need bucket edges near those values. If the p99 falls in a wide bucket spanning 500ms to 1,000ms, the interpolation might be off by hundreds of milliseconds.
The recommended approach is a hybrid. Use exponential spacing as your foundation, then add explicit boundaries at your SLO thresholds. This gives you natural resolution across the distribution plus accuracy at the exact points where you make decisions.
For a web service with SLOs at 100ms (p50) and 500ms (p99), a practical bucket set might look like:
[0.01, 0.025, 0.05, 0.1, 0.15, 0.25, 0.5, 0.75, 1.0, 2.5, 5.0, 10.0]
Notice the extra density around 100ms and 500ms, with exponential growth elsewhere.
How Many Buckets?
Industry consensus lands on 10 to 15 buckets for most latency histograms. Some sources recommend starting with 8 to 10 and adding more only if specific ranges need finer resolution. The wider the buckets, the less accurate the percentile estimate, but the smaller the memory footprint.
The trade-off is cardinality. Each bucket generates a separate time series. A histogram with 10 buckets and 5 label attributes creates 50 time series per unique attribute combination. If you instrument 100 endpoints, that’s 5,000+ series from a single metric. This is where label naming and cardinality strategies become critical.
GitLab’s experience is a cautionary tale. Their Redis latency metric produced 10,980 bucket time series, causing significant cardinality problems. Their team ultimately moved toward using the minimum number of buckets needed to calculate an apdex score: just two or three boundaries (the satisfied threshold, the tolerable threshold, and le="+Inf").
This doesn’t mean you should always use three buckets. It means you should be honest about what you’re actually using the histogram for. If the goal is apdex scoring, two or three buckets suffice. If the goal is accurate p50/p95/p99 estimation, you need 10 to 15 placed with care.
Common Mistakes in Histogram Bucket Configuration
Using defaults without profiling
Multiple practitioners across forums and engineering blogs call out the same trap. The Prometheus Python client’s 15 default buckets and OTel’s defaults are designed for generic use. If all observations for a latency metric lie between 260ms and 280ms, the default buckets are a terrible choice because only one or two buckets cover that entire range.
A GitHub PR from the Jentic project demonstrated this directly. Their MeterProvider with no Views used OTel default buckets (0, 5, 10, 25, 50, 75, 100ms and up). Below 25ms this was too coarse to see broker overhead of approximately 12 to 17ms per call, so p50 and p99 from histogram_quantile were meaningless for the broker’s actual cost. Their fix was making boundaries configurable via a latency_buckets_ms setting.
Always profile your actual latency distribution before committing to buckets. Run your service under realistic load, collect raw latency values, and look at the distribution before choosing boundaries. For more on avoiding these pitfalls, see metrics instrumentation best practices.
Missing the +Inf tail coverage rule
If the upper bound of your histogram is too low, any values beyond that range get grouped into the final +Inf bucket, hiding long-tail behavior entirely. If the largest explicit bucket is 5 seconds and a 15-second timeout occurs, it’s lumped into the same category as a 5.1-second response. You can’t distinguish a mild slowdown from a catastrophic timeout.
The rule of thumb: your largest explicit bucket should cover at least 2 to 3 times the maximum expected latency under normal conditions.
Skewed placement toward low values
A related mistake is concentrating all buckets below your SLO threshold and leaving nothing above it. You need resolution in the tail to understand how bad things get when they go wrong. A few buckets above your p99 target give you visibility into failure modes.
Removing buckets after deployment
Changing bucket boundaries breaks existing queries and alerts that reference specific le values. Treat bucket configurations as part of your schema, plan them carefully, and be aware that changes require query migration. For a broader view on schema decisions, designing metric schemas covers the planning process.
Explicit Buckets vs. Exponential Histograms
Explicit bucket histograms
This is the traditional model. You define exact bucket boundaries, and each observation is counted into the appropriate cumulative bucket. The advantage is full control and universal backend support. The disadvantage is that you have to get the boundaries right upfront, and changing them later is painful.
OpenTelemetry exponential histograms
To solve the bucket planning problem, OpenTelemetry introduced exponential histograms (called native histograms in Prometheus since v3.8.0). Instead of fixed boundaries, they calculate bucket edges using an exponential growth function. Each consecutive bucket is larger than the previous one, ensuring a constant relative error for every bucket.
The key advantage: exponential histograms dynamically adapt to your data, giving accurate percentile estimates at query time with guaranteed error bounds. No pre-defining buckets, no lossy conversions.
The OTel project’s design analysis specifies 160 buckets by default, covering a 1ms to 100s latency range with less than 5% relative error. That’s far more resolution than most explicit configurations provide, without requiring any manual tuning.
The trade-off is adoption. Explicit bucket histograms have stable support across all observability platforms. Exponential histograms are still seeing varying levels of support across backends and visualization tools. If your stack supports them, they’re the better default. If you’re unsure, explicit buckets with SLO-aligned spacing remain the safe choice.
Histograms in Serverless and Edge Environments
Short-lived handlers in serverless and edge environments add a specific constraint to histogram bucket design for latency metrics: every bucket increases the payload size that must be flushed before the handler terminates.
In a Cloudflare Worker or Vercel edge function, there’s no persistent process to accumulate metrics over time. Each invocation records observations and must flush them (typically via ctx.waitUntil() or after()) before the runtime kills the handler. A histogram with 15 buckets and 3 label dimensions produces dozens of data points per flush. Multiply that by request volume, and payload size becomes a real concern.
This is where API-first metrics ingestion, rather than the Prometheus scrape model, becomes essential. Instead of waiting for a scraper to pull data from a long-running process, the handler pushes its metrics batch directly. Strategies for buffering and flushing in serverless code can reduce overhead significantly.
For edge functions, consider whether you need full histogram resolution on every metric. Some teams use histograms only for their most critical latency path and simple counters for everything else. If you’re instrumenting Cloudflare Workers, keeping bucket count low (8 to 10) for edge-emitted histograms is a practical compromise.
Building on serverless? Compare Distlang Metrics plans to find the right fit for your histogram ingestion volume.
Iterative Refinement: A Real-World Example
GitLab’s SRE team provides an instructive case study in how histogram bucket design for latency metrics evolves over time.
In the first iteration of their Redis latency metric, the team made an effort not to add too many buckets. But they later realized that to have useful Redis latency monitoring, they needed to focus the histogram buckets on slower requests. Specifically, they removed the 0.001s bucket. While many Redis calls complete in under a millisecond, knowing that wasn’t useful for monitoring or alerting. At the tail end, they added 0.1s and 0.5s buckets to capture the slow calls that actually indicated problems.
This is the pattern that works in practice:
- Start with a reasonable exponential set of 10 to 12 buckets.
- Run under production traffic for a few days.
- Check which buckets contain most observations and where gaps appear.
- Add boundaries near your SLO thresholds and remove boundaries that carry no useful information.
- Update queries and alerts to match the new boundaries.
The goal is not to get buckets perfect on the first try. It’s to instrument, observe, and refine.
Quick-Reference: Suggested Bucket Sets by Service Type
| Service Type | Suggested Buckets (seconds) | Notes |
|---|---|---|
| Low-latency API (< 100ms typical) | [0.005, 0.01, 0.025, 0.05, 0.075, 0.1, 0.25, 0.5, 1.0] |
Dense below 100ms; covers tail to 1s |
| Standard web application | [0.01, 0.05, 0.1, 0.25, 0.5, 1.0, 2.5, 5.0, 10.0] |
Balanced for typical request latency |
| Batch / background processing | [0.5, 1.0, 5.0, 10.0, 30.0, 60.0, 120.0, 300.0] |
Coarse, covers minutes-long jobs |
| Edge / serverless function | [0.005, 0.01, 0.05, 0.1, 0.25, 0.5, 1.0, 2.5] |
Compact (8 buckets) to minimize flush payload |
These are starting points. Always adjust based on profiling real traffic and aligning with your SLO thresholds.
Ready to instrument? Record counters and histograms with the Distlang JS client and go from code to dashboard quickly.
FAQ
How do I know if my histogram buckets are wrong?
The clearest signal is percentile values that don’t match reality. If your p99 seems suspiciously round (exactly matching a bucket boundary) or your p50 jumps erratically despite stable traffic, your bucket boundaries probably don’t have enough resolution in the range where your latency concentrates. Compare histogram_quantile() output against sampled raw latency values to verify.
Should I use the same buckets for every service?
No. Different services have different latency profiles. A Redis cache lookup and an external API call have completely different distributions. Using the same buckets for both means at least one will have poor resolution. Define bucket sets per service type or per latency profile, not globally.
How do exponential histograms reduce cardinality compared to explicit buckets?
Exponential histograms use a compact representation where bucket boundaries are calculated mathematically rather than stored as individual time series. The OTel default of 160 exponential buckets covers a wider range with better accuracy than 15 explicit buckets, but the wire format is more efficient because boundaries are implicit. The catch is that your backend must support the exponential histogram format.
What happens if I set my highest bucket too low?
All observations above your highest explicit bucket boundary get counted into the +Inf bucket. This means you lose all granularity in the tail. A 5.1-second response and a 60-second timeout look identical. Set your highest explicit boundary to at least 2 to 3 times your maximum expected latency under normal conditions.
Can I change bucket boundaries on an existing metric?
You can, but it has consequences. Any Grafana dashboards, alert rules, or recording rules that reference specific le values will break. Prometheus recording rules that pre-compute percentiles will produce incorrect results during the transition. Plan bucket changes as deliberate schema migrations, not casual configuration tweaks.
How many time series does a single histogram actually produce?
A histogram with N explicit buckets produces N+2 time series per unique label combination (N bucket series plus _sum and _count). If you have 12 buckets and 3 label dimensions with 50 unique combinations each, that’s 14 * 50 = 700 time series from one metric. This multiplication is why limiting both bucket count and label cardinality matters.
Are exponential histograms ready for production use?
Prometheus has supported native (exponential) histograms since v3.8.0, and OpenTelemetry SDKs include them. However, not all backends, visualization tools, and query languages fully support them yet. If your stack includes recent versions of Prometheus, Grafana, or a backend that explicitly supports the exponential format, they’re production-ready. Otherwise, stick with explicit buckets and plan to migrate when support arrives.
What’s the minimum viable histogram for SLO monitoring?
If you only need to know whether requests meet SLO thresholds (for apdex scoring, for example), you can get away with as few as 2 to 3 buckets: the satisfied threshold, the tolerable threshold, and +Inf. GitLab used this approach successfully. But if you need accurate percentile estimation for debugging, 10 to 15 buckets with SLO-aligned placement is the minimum that produces reliable results.