Hash every series to three ingesters
The cluster's front door hashes each series' full label set onto a ring and writes every sample to the same three ingesters, succeeding once two confirm, so losing one ingester loses nothing and no popular metric lands on one machine — at the price of every query asking all ingesters.
Now that remote-write sends every sample to a cluster, the next question is what the cluster does with a sample so no single machine is overloaded or lost.
Scene 10
Hash every series to three ingesters
- Watch
- Try it
- Predict
- Capture
What happens to a sample when it enters a scalable metrics cluster? Remote-write hands the cluster a batch, and something has to decide which machine keeps it. Watch one series go through: the front door checks it against the limits, hashes it onto the ring to pick its machines, and sends it to three of them. Two confirmations are enough to call the write done — the third arrives a moment later.
Highlighted lines are the ones running in the diagram right now.
def push(tenant, batch):for series in batch:if bad_labels(series) or too_old(series):reject(series, 400) # never storedelif over_rate_limit(tenant):reject(series, 429) # tenant too fastelse:if shard_by_metric_name:key = fnv32a(tenant, series.name)else:key = fnv32a(tenant, series.labels)replicate(key, series)
def replicate(key, series):owners = ring.owners(key, n=copies)quorum = 2 if copies == 3 else 1acks, fails = 0, 0for ingester in send_parallel(owners, series):if ingester.confirmed:acks += 1else:fails += 1 # dead or too slowif acks >= quorum:return OK # a third can be latereturn ERROR # 500 to remote-write
def select(tenant, matchers):if shard_by_metric_name and has_name(matchers):key = fnv32a(tenant, name_of(matchers))targets = ring.owners(key, n=copies)else:targets = all_ingesterssamples = []for ingester in send_parallel(targets, matchers):samples += ingester.recent_samples(matchers)return dedupe(samples)
Where this sits in Metrics / Monitoring System
Scene 10 of 18, in the Scale out act — Remote-write, ingesters, dedup, blocks, split queries.. The cluster's front door hashes each series' full label set onto a ring and writes to three ingesters, succeeding once two confirm — no popular metric lands on one machine, but every query asks them all.
Up next. Now that the cluster keeps three safe copies of whatever it receives, the next question is what happens when the scrapers themselves are redundant and send every sample twice.
All 18 scenes in Metrics / Monitoring System · Every curriculum