The Desi Architect
Notes / Docker Sandboxes / Bloom Filter Cache Penetration Shield
Docker Sandboxes · Tier 2: Data & Scale · Lab 31

Bloom Filter Cache Penetration Shield

Send 500 lookups for products that do not exist at a cached catalogue. Without protection every one reaches Postgres. Put a Bloom filter in front, built from a Redis bit array, and none do. Then shrink the filter and measure the false positives against the formula.

Time30 minutes
StackRedis 7Ports 16398, 15444
MemoryAbout 80 MB
Before thisLab 06Redis Basics
Verified runWindows, Mac, LinuxBash and PowerShell
  1. 1PrepareWhat you will learn
  2. 2PredictGuess before you run
  3. 3RunStep by step
  4. 4ObserveWhat you should see
  5. 5Break itChange one thing
  6. 6Clean upLeave nothing running
On this page
  1. 00 / What You Will Learn
  2. 01 / Why It Matters
  3. 02 / What We Are Building
  4. 03 / Words You Need
  5. 04 / Predict First
  6. 05 / Step by Step
  7. 06 / What You Should See
  8. 07 / Look Inside
  9. 08 / Break It, Fix It
  10. 09 / In Real Projects
  11. 10 / Interview Corner
  12. 11 / Clean Up

00 /What You Will Learn

By the end you will be able to
  • Explain cache penetration and why a cache cannot help against it.
  • Explain a Bloom filter: "definitely not" or "maybe", never a false negative.
  • Use negative caching for what the filter lets through.
  • Read a table of filter size against false positive rate.

Before you start

Finish Lab 06 (Redis Basics) first. You should know SETBIT and GETBIT in outline. Docker Desktop and Python 3 are needed.