惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

量子位
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
F
Fortinet All Blogs
博客园 - 聂微东
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Hugging Face - Blog
Hugging Face - Blog
V
Visual Studio Blog
小众软件
小众软件
有赞技术团队
有赞技术团队
雷峰网
雷峰网
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
AWS News Blog
AWS News Blog
C
Cisco Blogs
美团技术团队
T
Threat Research - Cisco Blogs
C
CERT Recently Published Vulnerability Notes
人人都是产品经理
人人都是产品经理
宝玉的分享
宝玉的分享
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
酷 壳 – CoolShell
酷 壳 – CoolShell
Stack Overflow Blog
Stack Overflow Blog
W
WeLiveSecurity
D
DataBreaches.Net
博客园 - 司徒正美
Blog — PlanetScale
Blog — PlanetScale
IT之家
IT之家
云风的 BLOG
云风的 BLOG
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Simon Willison's Weblog
Simon Willison's Weblog
Google DeepMind News
Google DeepMind News
T
The Blog of Author Tim Ferriss
Know Your Adversary
Know Your Adversary
NISL@THU
NISL@THU
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
The Cloudflare Blog
Vercel News
Vercel News
月光博客
月光博客
T
Tailwind CSS Blog
H
Help Net Security
aimingoo的专栏
aimingoo的专栏
P
Proofpoint News Feed
Application and Cybersecurity Blog
Application and Cybersecurity Blog
Spread Privacy
Spread Privacy
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Cisco Talos Blog
Cisco Talos Blog
Microsoft Security Blog
Microsoft Security Blog
V
V2EX
WordPress大学
WordPress大学
Cyberwarzone
Cyberwarzone
Recent Announcements
Recent Announcements

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant Common SOC 2 Failures (Real World) Stop Vibe-Checking Your AI App: A Practical Guide to Evals How to Use SonarQube and SonarScanner Locally to Level Up Your Code Quality Your Next To-Do App Is Dead — I Replaced Mine with an OpenClaw AI Sign a Nostr event in 60 lines of Python using coincurve — no nostr-sdk, no nbxplorer, no rust toolchain ITGC Audit Explained Like You’re in Big 4 Patch Tuesday abril 2026: Microsoft parcha 163 vulnerabilidades y un zero-day en SharePoint Stop scraping everything: a better way to track competitor price changes Listing on MCPize + the Official MCP Registry while routing payments OUTSIDE the marketplace — how I kept 100% of my x402 revenue Building an AI-Powered Risk Intelligence System Using Serverless Architecture Why We Ripped Function Overloading Out of Our AI Toolchain Testing AI-Generated Code: How to Actually Know If It Works SaaS Churn Is Killing Your Business. Here Is What to Do About It (Without a Support Team) The Speed of AI Is No Longer Linear - And Self-Improving Models Are Why How to Implement RBAC for MCP Tools: A Practical Guide for Engineering Teams From Standard Quote to Persuasive Proposal: AI Automation for Arborists I built a CLI that scaffolds complete multi-tenant SaaS apps Axios CVE-2025–62718: The Silent SSRF Bug That Could Be Hiding in Your Node.js App Right Now The dashboard that ended our friendship Data Pipelines Explained Simply (and How to Build Them with Python) The Hidden Cost of AI Systems Nobody Talks About. undefined vs undeclared, and how typeof behaves Switching from file-based jobs to NATS/Kafka in Rust without changing code io_uring Adventures: Rust Servers That Love Syscalls Why Agentic AI is Killing the Traditional Database The POUR principles of web accessibility for developers and designers Quantum Neural Network 3D — A Deep Dive into Interactive WebGL Visualization How To Install Caveman In Codex On macOS And Windows Automation Pipeline Reliability: Why Your Workflow Breaks When Nobody Is Watching I Built an 'Open World' AI Coding Agent — It Works From ANY Folder From Freelancing to Product: A Tech Service Company's SaaS Transformation China's AI Giants: Adding Tencent Hunyuan & ByteDance Doubao to AI University (74 Providers) On the Vibe Coders and Their Lies clerk: Auto-Summarize Your Claude Code Sessions AI Weekly — 2026/04/10–04/17 | The Model Lockdown Is Here, but the Toolchain Is the Real Battleground AI 週報 — 2026/04/10–2026/04/17 模型封鎖潮來了,但工具鏈才是真戰場 Maybe this is how Open-Source apps are born... 🚀 Fine-Tune LLMs with LoRA and QLoRA: 2026 Guide tRPC v11 + Next.js App Router: End-to-End Type Safety Without the Boilerplate ShadCN UI in 2026: Why I Stopped Installing Component Libraries and Started Owning My Components SaaS Billing in React Server Components: Stripe + Supabase Without a Single `useEffect` Join our DEV Weekend Challenge — $1,000 in Prizes Across TEN winners! Submissions Due April 20 at 6:59 AM UTC. Implementing FSRS Spaced Repetition in Flutter + Supabase — Adding Memory Science to an AI Learning App "I Texted My Localhost From the Train — Claude Code Fixed the Bug Before I Got Home" I Built a Sales Prep AI and It Went Deeper Than Expected Design to Code #2: One JSON, Eleven Outputs Solving the 100M-Row Problem: A Summary Table Pattern for High-Volume Push Notification Logs Flutter Web With Wasm: What Actually Changes For Developers I Built 50 Royalty-Free Soundtracks for My Side Project in a Weekend Using AI Music Generation The Vibe Coding Security Checklist: 7 Things to Check Before You Ship Stop Letting Googlebot Guess Fix Your React App's SEO Right Desconstruindo o Streaming do LinkedIn: Como Criar um Engine de Extração de Vídeo de Alta Performance com HLS e FFmpeg (EDA Part-1) EDA (Exploratory Data Analysis) Explained With Real Life — Why Looking at Your Data Is the Most Important Step in Machine Learning Brand Relationship Management at Scale: Our 4-Touch Outreach System for 200+ Brands Why String.fromEnvironment() Might Return an Empty String in Dart JGuardrails 1.0.0 — Hardening Java LLM Apps Against Jailbreaks, Toxicity, and Prompt Injection Plan and Schedule a Full Week of Threads Content From One Claude Conversation Coding Cat Oran Ep3, Five Tables Changed Everything Updated: BFF Pattern I'm done watching freelancers get buried by 200 proposals. So I'm building the alternative. This is my first post BFS Algorithm in Java Step by Step Tutorial with Examples Tracking LLM Pricing Monthly: An Open Dataset for 22 AI Models How We Measure Content ROI on a Comparison Site: Revenue Attribution Without Perfect Data Introducing Nova AI Ops: The AI-Native Operating System for SRE Teams I built a free desktop video downloader for Windows — Grabbit How Talkie OCR Helps Vision-Impaired & Dyslexic Users Read the World Around Them VRCFaceTracking安装和iPhone面捕配置教程,有bug Even CrowdStrike Can't See Your Agents The Automation Gold Rush: What n8n Workflows and Claude Are Opening Up for Developers Right Now
System Design - 23. Bloom Filters: How Chrome Checks Billions of Malicious URLs Using Almost No Memory
Rajkiran · 2026-06-14 · via DEV Community

Covers: Probabilistic Data Structures, False Positives vs False Negatives, Counting Bloom Filters, Tuning, Real Implementations


A Question With a Surprising Answer

How does Chrome check, on every single page load, whether the URL you're visiting is on a list of millions of known malicious websites — without sending your browsing history to Google for every page you visit, and without downloading a multi-gigabyte database to your phone?

The answer is a data structure so simple it can be explained in one sentence, yet so powerful it underpins systems at Google, Cassandra, Akamai, and nearly every large-scale database: the Bloom Filter.


The Core Idea: A Probabilistic "Maybe"

A normal data structure (a hash set, a database) answers "is X in this collection?" with a definitive yes or no.

A Bloom Filter answers with:

  • "Definitely NOT in the set" (100% certain)
  • "Possibly in the set" (might be a false positive)
Bloom Filter says "NOT in set"  → guaranteed correct, 100% of the time
Bloom Filter says "MAYBE in set" → could be wrong (false positive)

Bloom Filter NEVER says:
"Definitely IS in set" with the implication of certainty
"NOT in set" when it actually IS in set (no false negatives, ever)

This asymmetry — no false negatives, but possible false positives — is the entire trick, and it's precisely calibrated to be useful.


How It Works: Bit Arrays and Hash Functions

A Bloom Filter is a bit array of size m (initially all zeros) plus k independent hash functions.

Adding an Item

Bit array (m=16): [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]

Add "malware.com":
  hash1("malware.com") % 16 = 2  → set bit 2 to 1
  hash2("malware.com") % 16 = 7  → set bit 7 to 1
  hash3("malware.com") % 16 = 11 → set bit 11 to 1

Bit array: [0,0,1,0,0,0,0,1,0,0,0,1,0,0,0,0]
                ↑           ↑     ↑
              bit 2       bit 7  bit 11

Checking an Item

Check "malware.com" (already added):
  hash1("malware.com") % 16 = 2  → bit 2 is 1 ✓
  hash2("malware.com") % 16 = 7  → bit 7 is 1 ✓
  hash3("malware.com") % 16 = 11 → bit 11 is 1 ✓
  ALL bits set → "MAYBE in set" (correctly — it IS in the set)

Check "safe-site.com" (never added):
  hash1("safe-site.com") % 16 = 3  → bit 3 is 0 ✗
  ANY bit is 0 → "DEFINITELY NOT in set" (correct — it's not!)

Check "another-site.com" (never added, but...):
  hash1("another-site.com") % 16 = 2  → bit 2 is 1 (set by malware.com)
  hash2("another-site.com") % 16 = 11 → bit 11 is 1 (set by malware.com)
  hash3("another-site.com") % 16 = 7  → bit 7 is 1 (set by malware.com)
  ALL bits happen to be 1 → "MAYBE in set" 
  → FALSE POSITIVE! "another-site.com" was never added, but its hash 
    positions happen to overlap with bits set by "malware.com"

Why no false negatives are possible: If an item was added, ALL its bits were set to 1 by definition. Checking those same bits later will always find them set to 1 (bits are never unset in a basic Bloom Filter). So a real member can never be reported as "not in set."

Why false positives are possible: Multiple items' hash functions can map to overlapping bit positions. An item that was never added might, by coincidence, have all its bit positions already set to 1 by other items.


Why Tiny Memory Footprint Is the Whole Point

Here's the number that makes Bloom Filters remarkable:

To store 1 million URLs with a 1% false positive rate:
  A hash set storing actual URL strings: ~50-100 MB (depends on URL length)
  A Bloom Filter: ~1.2 MB

To store 1 BILLION URLs with a 1% false positive rate:
  Hash set: ~50-100 GB
  Bloom Filter: ~1.2 GB

The Bloom Filter doesn't store the actual data — just bits representing "something hashed here." This is why Chrome can ship a Bloom Filter representing Google's entire Safe Browsing malicious URL list as a small download, updated periodically, checked entirely locally — no network call needed for the common case (the URL is safe).

Chrome's flow:
  1. User visits a URL
  2. Check LOCAL Bloom Filter: "is this URL possibly malicious?"
  3a. Bloom Filter says "definitely not" → proceed immediately, 
      NO network call (the vast majority of URLs)
  3b. Bloom Filter says "maybe" → NOW make a network call to Google's 
      full database to confirm (rare — only for the small % of false 
      positives plus actual malicious URLs)

The Bloom Filter acts as a fast local pre-filter — eliminating ~99%+ of cases from ever needing a network round trip, while never missing an actual malicious URL.


Tuning the False Positive Rate

Two parameters control accuracy: the size of the bit array (m) and the number of hash functions (k).

The formula (intuition, not memorization-required for interviews):

False positive rate ≈ (1 - e^(-kn/m))^k

Where:
  n = number of items inserted
  m = size of bit array
  k = number of hash functions

The practical trade-off:

More bits per item (larger m relative to n):
  → Lower false positive rate
  → More memory used

Optimal k (number of hash functions):
  k ≈ (m/n) × ln(2)
  → Too few hash functions: insufficient bit coverage, higher false positives
  → Too many hash functions: bit array fills up too fast, higher false positives
  → There's a sweet spot

Practical numbers (commonly cited):

~10 bits per item, 7 hash functions → ~1% false positive rate
~15 bits per item, 10 hash functions → ~0.1% false positive rate

The interview-ready statement: "Bloom filters trade memory for accuracy — you choose your acceptable false positive rate upfront, and that determines how many bits per item you need. Doubling the bits roughly squares the accuracy improvement (10x fewer false positives for roughly 50% more bits, in the practical range)."


Counting Bloom Filters: Adding Deletion

A basic Bloom Filter has a problem: you can't delete an item. Bits are shared between items (that's the whole mechanism) — unsetting a bit to "remove" one item might break the membership check for other items whose hashes also touched that bit.

Counting Bloom Filters solve this by using small counters instead of single bits:

Basic Bloom Filter:        [0,0,1,0,0,0,0,1,0,0,0,1,0,0,0,0]
Counting Bloom Filter:     [0,0,2,0,0,0,0,1,0,0,0,3,0,0,0,0]
                                ↑               ↑
                          2 items hash here  3 items hash here

Adding an item: increment relevant counters
Removing an item: decrement relevant counters
  (if a counter reaches 0, that "bit" is effectively unset)

Checking membership: same as before — are all relevant 
counters > 0?

The cost: Counting Bloom Filters use more memory (typically 4 bits per counter instead of 1 bit) — but still dramatically less than storing actual items, while supporting deletion.


Real Implementation: Cassandra's SSTables

This is one of the most elegant uses of Bloom Filters in production databases, and directly relates to the LSM Tree structure we'll cover in Topic 25.

Cassandra stores data in immutable files called SSTables.
A single Cassandra node might have HUNDREDS of SSTable files on disk.

Without Bloom Filters:
  Looking up "user_12345" requires checking EVERY SSTable file 
  on disk — even if "user_12345" only exists in ONE of them.
  Each check = a disk read = slow (remember Day 1's latency numbers:
  SSD read ≈ 150μs, much slower than memory).

With Bloom Filters:
  Each SSTable has an associated Bloom Filter (kept in memory).
  Before reading an SSTable from disk, Cassandra checks its 
  Bloom Filter: "might 'user_12345' be in this SSTable?"

  - "Definitely not" (most SSTables) → skip this file entirely, 
    NO disk read
  - "Maybe" (the 1-2 SSTables that actually contain the key, plus 
    occasional false positives) → read this file from disk

The impact: A query that might have required checking 100 SSTable files on disk now typically checks 1-2 — because 98 of them are eliminated by an in-memory Bloom Filter check that costs microseconds. This is one of the primary reasons Cassandra achieves its famous write and read performance despite using an architecture (LSM trees) that would otherwise require many disk reads per query.


Real Implementation: Google Bigtable / CDN "One-Hit Wonder" Filtering

Akamai's CDN faces a specific problem: a huge fraction of content requested from origin servers is requested exactly once — a user clicks a link nobody else will click, requesting a resource that will never be requested again ("one-hit wonders").

Caching every requested item — including one-hit wonders — wastes cache space on content that will never produce a cache hit.

Akamai's approach using a Bloom Filter:
  1. First request for URL X → check Bloom Filter
  2. "Definitely not seen before" → DON'T cache it (probably a one-hit 
     wonder), but ADD it to the Bloom Filter
  3. Second request for the SAME URL X → check Bloom Filter
  4. "Maybe seen before" (it's now in the filter from step 2) 
     → THIS time, cache it — it's been requested twice, 
     likely to be requested again

This is a beautifully simple use of the false-positive-tolerant nature of Bloom Filters: occasionally caching a one-hit wonder due to a false positive is a minor inefficiency, but the overall cache hit rate improves significantly by not wasting cache slots on content unlikely to be re-requested.

Google Bigtable uses Bloom Filters similarly to Cassandra — to avoid unnecessary disk reads when checking if a row exists in a particular SSTable.


Bloom Filter vs Hash Set: When to Use Which

Hash Set Bloom Filter
Memory O(n) — stores actual items O(n) but tiny constant — just bits
False positives Never Possible (tunable rate)
False negatives Never Never
Deletion Yes No (unless Counting Bloom Filter)
Retrieve actual items Yes No — only membership testing

Use a Bloom Filter when:

  • You need to test "might X be in this huge set?"
  • Memory is constrained relative to the size of the set
  • Occasional false positives are acceptable (because they trigger a more expensive but authoritative check — disk read, network call, etc.)
  • You DON'T need to retrieve or enumerate the actual items — only test membership

Use a Hash Set when:

  • You need exact membership testing (no false positives tolerable)
  • You need to retrieve or iterate the actual stored items
  • Memory isn't a constraint relative to your dataset size

Interview Scenario: "Reduce Database Load with Bloom Filters"

Q: Your application frequently checks "does this username exist?" — and most checks are for usernames that DON'T exist (new signups checking availability). How would you optimize this?

"Most of these checks are for usernames that don't exist — every database query for a non-existent username is essentially wasted I/O. I'd maintain a Bloom Filter containing all existing usernames, kept in memory and updated whenever a new user signs up.

The check flow becomes: first check the Bloom Filter. If it says 'definitely not in set,' the username is available — no database query needed at all, this is instant. If it says 'maybe in set,' THEN query the database to confirm — this covers both real existing usernames and the rare false positives.

Given that the vast majority of availability checks during signup are for usernames that genuinely don't exist, this eliminates the majority of database reads for this endpoint — turning a database query into an in-memory bit-check for most requests.

One consideration: the Bloom Filter needs to be kept in sync as users sign up — I'd update it synchronously on user creation (cheap — just set a few bits) so it never has false negatives for newly created users."


Key Takeaways

  • A Bloom Filter answers "definitely not in set" (always correct) or "maybe in set" (possible false positive) — never a false negative.
  • It's a bit array + multiple hash functions. Adding sets bits; checking verifies all relevant bits are set.
  • Memory usage is a tiny constant per item — orders of magnitude smaller than storing actual data, regardless of how large the items themselves are.
  • Tuning: more bits per item and the right number of hash functions reduces the false positive rate — it's a tunable trade-off, not fixed.
  • Counting Bloom Filters use small counters instead of bits, enabling deletion at the cost of more memory.
  • Cassandra/Bigtable: Bloom Filters per SSTable eliminate most unnecessary disk reads — checking 1-2 files instead of 100.
  • Chrome Safe Browsing: a local Bloom Filter eliminates network calls for the vast majority of (safe) URLs.
  • Akamai CDN: Bloom Filters identify "one-hit wonders" to avoid wasting cache space on content unlikely to be requested again.

What's Next

Topic 24 covers Geospatial Indexing — how Uber finds nearby drivers among millions of moving vehicles in milliseconds, comparing Quadtrees, Google's S2, and Uber's own H3 hexagonal grid system.


Topic 23 of the System Design Mastery series.


Tags: system-design bloom-filters data-structures cassandra backend algorithms interview-prep