AlgoViz

Finding frequent endpoints with a sketch

medium 4 min

Use a frequency sketch alongside a candidate-key list when the task is to name busy endpoints.

Video lesson · Chapter 1 of 5

An operator knows checkout is busy

0:00 / 3:42

The sketch crossed 1,000. Should we throttle?

1:12Reel

Theory

Read or listen first. About 1 min.

What it is

A frequency sketch answers questions about keys you supply. To find busy endpoints, keep candidate names alongside it and check their estimates against the alert threshold.

Is the endpoint over the alert threshold?

Requests to /checkout in the same minute9009501000105010201,020 crosses 1,000. Check the exact events.
The endpoint’s estimated count is 1,020, above the threshold of 1,000. That makes it a candidate for verification.

Why it exists

An estimate near a cutoff can change an operational decision. Verifying the same key and time window against exact data avoids rate-limiting the wrong endpoint.

Words to know

Candidate key
An identity retained so that a frequency estimator can be queried for that specific item.

How it works

Step through the idea, or press Play.

Step 1 of 3

Track a candidate. Keep its endpoint name alongside the sketch.

Understand it

Worked example

Finding frequent endpoints with a sketch in practice

An endpoint threshold is 1,000 requests. A sketch estimate of 1,020 is enough to flag an endpoint for verification. Before enforcing a costly action, check an exact counter or a bounded event sample.

Related case

Three questions for a tiny memory budget

A telemetry service needs to skip pointless disk reads, estimate traffic for a known endpoint, and count unique devices across regions. Each question allows a different error.

One device crosses regions
A device visits two regionsDevice 9first visitRegion AemptyRegion BemptyCount distinct devices across regions

Estimate the union of observed identities.

Sources