How does the audience estimator return counts instantly while I type?
Purely a curiosity question! I was editing an audience today and noticed the live estimate updates basically as fast as I can type new conditions. I do this kind of thing for a living (data eng) and a naive scan over every profile for an arbitrary boolean condition should take way, way longer than that.
Is it precomputed aggregates? Sampling? Some sketch structure? I tried a few weird conditions to see if I could catch it approximating and the counts stayed plausible every time. Genuinely curious how this is built, would love a pointer if the team has written anything up about it
1 answer
You are in luck, the team wrote exactly the post you are asking for: "Counting the uncountable: 115 days of computation to seconds" on the engineering blog. The title is the answer to your intuition: the naive scan really would take that long, and the write-up walks through how they got it down to interactive speed.
Two things worth knowing as a user of the feature:
-
The live estimator is a design-time sizing aid. It exists so you can see whether a condition matches 40 people or 40 thousand before you commit to it. It is included from the Growth plan up.
-
It is not what runs in production. When the experience is live, audience membership is evaluated in real time per interaction, so the actual matching decision for each visitor is a fresh evaluation of the condition, not a lookup against the estimate.
So the estimate answers "how big is this audience roughly" and the runtime answers "is this specific visitor in it right now". Different machinery for different questions.