Part 7 · Blueprint 43
Time-Series Database Engine (Prometheus / InfluxDB / Gorilla)
12 min reading · Sources · Editorial review pending
Unbounded label combinations can exhaust index memory even when each sample is small.
Page details
Published date · Last edited:
Draft edition. Editorial review and supplementary reading recommendations are still being completed.
Format: Architecture walkthrough. Prerequisites: the beginner bootcamp. Chapter prerequisites: Indexes & Storage Engines: B-Trees vs. LSM Trees, Message Queues & Event Streams: Kafka vs. RabbitMQ, Observability, Distributed Tracing & Error Budget SLOs.
Sixty-second mental model
Problem: Unbounded label combinations can exhaust index memory even when each sample is small.
Use: Budget series cardinality separately from sample compression.
Design boundary: Ingest/query timestamped metric series with bounded label cardinality, retention and alert evaluation. A series identity is its metric and label set, not merely a metric name.
Layer 1 · Intuition
Hypothetical scenario: Northwind is designing time-series storage. Maya represents product requirements, Dev implementation and Priya reliability. The team must agree what one sample means and which component owns the series identity.
Think of a dated measurement log indexed by sensor labels. Separate the requester from series identity, then identify the retained evidence needed after failure.
- Authority
- The entitled state owner.
- Invariant
- A rule preserved across concurrency and failures.
- Cardinality
- The number of distinct values or combinations in a defined set. Analogy: How many different labels need separate storage bins.
Architecture and worked reasoning
Design boundary: Ingest/query timestamped metric series with bounded label cardinality, retention and alert evaluation. A series identity is its metric and label set, not merely a metric name.
Responsibilities on the request path
Workload and limiting resource
Hypothetical 500 hosts × 40 metrics × 10 label combinations = 200,000 series. At one sample/15 seconds, ingestion is about 13,333.33 samples/s. At 16 raw bytes/sample, daily sample bytes are 200,000 × 5,760 × 16 = 18.432 GB before compression/indexes/replication.
Keep the units attached to each intermediate result. The assumptions above describe a hypothetical exercise, not observed vendor capacity. A real capacity decision also needs a measured service curve, skew, recovery traffic and an explicit admission policy for overload.
Mutation or publication path
- Validate timestamps and label policy.
- Append samples to the selected series.
- Compact and expire blocks under the retention contract.
Observation and recovery path
- Select series by indexed label predicates.
- Read bounded time ranges and aggregate.
- Evaluate alert state with missing/stale sample policy.
Failure that changes the decision
Hypothetical scenario: An unbounded request identifier is introduced as a label. New series accumulate per request and defeat the planned cardinality budget.
Attempt this decision before reading the explanation
Does reducing scrape frequency solve an unbounded-label problem?
It reduces samples per series, not the number of distinct series created by unique labels. Control identity dimensions and route high-cardinality detail elsewhere.
Supporting mechanism analysis
Hypothetical scenario: Northwind. Maya represents product, Dev implementation and Priya reliability. The following workflow develops the underlying mechanism.
Hypothetical scenario. Northwind’s dashboard is green after excess work is rejected, but Maya still sees buyers waiting for reservation confirmation. Dev points to a fast HTTP response chart. Priya asks whether it counts acceptance, completed payment or the result presented to the buyer.
Define the outcome being measured and the evidence that can explain a bad result. Carry the joint latency-and-freshness rule into telemetry, preserving failures and missing observations under the declared policy. The chosen objective arithmetic is hypothetical, not achieved availability.
The successful populations can differ. Identify their intersection and keep the denominator aligned with the declared customer outcome.
The original two-hundred-attempt exercise had one hundred eighty attempts satisfying both presentation time and price-evidence age. Counting fast responses separately from fresh responses could conceal the ten attempts that failed each part. The useful numerator counts the joint acceptable outcome, and the denominator includes every attempt eligible under the declared rule.
Record request start, accepted or rejected outcome, elapsed client boundary and source-evidence age for the same attempt. Server spans can explain queueing or a product lookup without proving that the visitor received the selected result. An error-only or slow-only trace sample is useful for diagnosis but cannot be treated as an unbiased rate sample.
Hypothetical scenario. Northwind exports one request counter with four normalized route values, three outcome values and two deployment regions. If every combination occurs for each of five instances, the selected series count is 4 × 3 × 2 × 5 = 120. A route value means a template such as /items/{id}, not every literal item address.
Prometheus’s instrumentation guidance explains that label combinations create additional time series and advises care with high-cardinality dimensions. Keep the bounded route/outcome/region counter for aggregate decisions. Put selected tenant and operation identities in access-controlled traces or another investigation store with an explicit retention policy. A random request identifier would continually create new label combinations rather than a stable tenant cohort.
Hypothetical failure scenario. An alert evaluates the fraction of failed responses. A routing error prevents callers from reaching the service, so the service records neither successes nor failures. The alert remains quiet because its data does not represent the failed user requests.
Incident review should preserve the uncertainty. Compare routing changes, arrival counts, operation state and collector health. An empty trace search is evidence that no matching trace was found in that store under that query, not proof that no request or effect occurred.
“The error budget specifies a universal launch freeze.” The arithmetic derives a budget; an operating policy defines the response, exceptions and recovery criteria.
Use telemetry to support explicit decisions: detect user harm, identify a constrained resource, reconcile an uncertain operation or compare a change. State what evidence would change the current explanation. Collect enough context to investigate without copying sensitive request bodies into every log.
These request-based examples depend on a declared eligibility rule and complete enough outcome accounting. Sampled traces cannot prove the absence of an operation. Retention, privacy, collector failures and clock uncertainty limit telemetry, while authorization evidence needs its own durable record.
Layer 3 · Internals
A time series is identified by a metric name and label set; samples then add timestamped values. If a hypothetical deployment has 500 hosts, 20 endpoints and four status classes, the complete Cartesian label space is 500 × 20 × 4 = 40,000 potential series. Adding a user dimension with 100,000 values raises that upper-bound space to 4,000,000,000 combinations. Actual occupancy depends on which combinations occur, but the multiplication explains why an innocent-looking label can dominate memory.
Compression of nearby timestamps and values reduces sample bytes without removing index and series-identity costs. A write path commonly maintains an active mutable region and later persists immutable time ranges; compaction and retention must handle out-of-order or late samples under a declared policy. Downsampling changes query semantics: a stored average cannot reconstruct every percentile or arbitrary later grouping. Budget active series, ingestion rate and retained sample volume separately. A low byte-per-sample estimate is not a complete memory plan.
Trade-offs and limits
| Approach | Provides | Requires |
|---|---|---|
| Raw retained samples | Preserves flexible later analysis. | Storage and cardinality increase with retained identities. |
| Downsampled aggregates | Reduces recurring query work and retained volume. | Some later percentiles or grouping questions cannot be reconstructed. |
Recovery decision
Hypothetical scenario: An unbounded request identifier is introduced as a label. New series accumulate per request and defeat the planned cardinality budget.
It reduces samples per series, not the number of distinct series created by unique labels. Control identity dimensions and route high-cardinality detail elsewhere.
Write your design before revealing the review
Does reducing scrape frequency solve an unbounded-label problem?
Drafts and self-review are stored only in this browser. They are separate from reading completion.
Compare your decision
It reduces samples per series, not the number of distinct series created by unique labels. Control identity dimensions and route high-cardinality detail elsewhere.
An unbounded request identifier is introduced as a label. New series accumulate per request and defeat the planned cardinality budget.
Check your understanding
Does reducing scrape frequency solve an unbounded-label problem?
It reduces samples per series, not the number of distinct series created by unique labels. Control identity dimensions and route high-cardinality detail elsewhere.
How would you recover from this failure: An unbounded request identifier is introduced as a label. New series accumulate per request and defeat the planned cardinality budget.
Start with the exact boundary that failed. Validate timestamps and label policy. Append samples to the selected series. Compact and expire blocks under the retention contract. Then recover evidence through the observation path: Select series by indexed label predicates. Read bounded time ranges and aggregate. Evaluate alert state with missing/stale sample policy. Preserve the distinction between a confirmed state change and an unavailable response.
Which assumption in the worked calculation would a burst or concentrated tenant invalidate first?
Hypothetical 500 hosts × 40 metrics × 10 label combinations = 200,000 series. At one sample/15 seconds, ingestion is about 13,333.33 samples/s. At 16 raw bytes/sample, daily sample bytes are 200,000 × 5,760 × 16 = 18.432 GB before compression/indexes/replication. Recompute the affected resource rather than multiplying unrelated storage and network budgets by the same factor. Ingest/query timestamped metric series with bounded label cardinality, retention and alert evaluation. A series identity is its metric and label set, not merely a metric name.
Which component in this topology could be removed from a smaller first deployment?
Metric ingest, Series index, Time blocks, Range query name responsibilities, not a requirement for separate processes. Co-locate responsibilities when their transaction, trust and capacity boundaries permit it. Validate timestamps and label policy.
What evidence must a caller have before relying on the observation path?
Select series by indexed label predicates. Read bounded time ranges and aggregate. Evaluate alert state with missing/stale sample policy. It reduces samples per series, not the number of distinct series created by unique labels. Control identity dimensions and route high-cardinality detail elsewhere.
45-minute interview rubric
- 00–05: scope sample and series identity.
- 05–12: identify the limiting resource and derive the domain workload above, retaining units and assumptions.
- 12–28: draw series identity, numbered writes and reads.
- 28–40: challenge recovery: Budget series cardinality separately from sample compression.
- 40–45: defend series_id placement, observations and remaining assumptions.
Go deeper
- Storage | Prometheus · Primary document · prometheus.io. Budget series cardinality separately from sample compression. Verified 2026-10-26.
- Sampling | OpenTelemetry · Primary document · opentelemetry.io. Budget series cardinality separately from sample compression. Verified 2026-10-26.
- Instrumentation | Prometheus · Primary document · prometheus.io. Budget series cardinality separately from sample compression. Verified 2026-10-26.
- Trace Context · Primary document · www.w3.org. Budget series cardinality separately from sample compression. Verified 2026-10-26.
Decision log
Budget series cardinality separately from sample compression.
Preserve sample identity and series identity ownership.
Revisit changed workload, observations or recovery objectives.