The law of large numbers says that repeated random outcomes tend to approach their expected probability as the number of trials grows. In software, this supports probabilistic increment: replace many exact counter updates with fewer, weighted updates. section 6.11.1
Approximate like counts
For a popular post, choose N = 10. On each like, generate a random integer from 0 to 10; usually do nothing, but with probability 10%, increment the counter by 10. Across many likes, the counter approaches the true total while only about 1/N of requests query the database. section 6.11.1
The technique trades exactness for scalability:
- Reduces database contention and latency by avoiding most counter updates. section 6.11.1
- Fits popular posts whose counts tolerate approximation, but can produce odd results for posts with few likes. section 6.11.1
- Requires careful selection of N; N may increase dynamically as the like count grows. section 6.11.1
// /like/{post_id} handler
function like(postID string) {
if randomInt(N) == 0 {
increment(postID, N)
}
}
Shows the probabilistic like-handler implementation. section 6.11.1

