Translate

Bloom Filters in System Design

Updated On : 05-10-2025

ब्लूम फिल्टर क्या है? (Bloom Filters in System Design)

परिचय: Bloom Filter क्या है?

सिस्टम डिजाइन (System Design) और डाटा स्ट्रक्चर (Data Structure) में, Bloom Filter एक probabilistic data structure है जो यह बताता है कि कोई एलिमेंट शायद set में है या नहीं है

यह space-efficient और fast होता है, लेकिन इसमें false positives आ सकते हैं (यानि यह कभी-कभी कह सकता है कि value मौजूद है जबकि असल में नहीं होती)।

Bloom Filter कैसे काम करता है?

एक Bloom Filter के core में bit array और multiple hash functions होते हैं।

  1. जब कोई item insert किया जाता है, तो उस पर कई hash functions apply होते हैं।
  2. हर hash output bit array में एक index पर map होता है।
  3. उन indices पर bits को 1 कर दिया जाता है।

जब membership check करते हैं, तो वही hash functions run होते हैं। यदि सभी mapped positions 1 हैं → element "शायद" मौजूद है। यदि कोई भी 0 है → element निश्चित रूप से नहीं है

Bloom Filter Example (उदाहरण)

मान लीजिए हमारे पास 3 hash functions हैं और bit array size 10 है। अगर हम "apple" insert करते हैं तो तीन indices 2, 5 और 7 पर bits 1 हो जाएंगी। अब अगर हम "apple" check करेंगे तो वही bits देखी जाएंगी।

अगर "mango" check किया और indices 2, 5, 7 पहले से 1 हैं → तो Bloom Filter कहेगा कि "शायद मौजूद है" जबकि असल में नहीं है।

Bloom Filters के Use Cases

  • Databases: Redis, Cassandra duplicate checks।
  • Web Caching: पहले check करना कि item cache में हो सकता है या नहीं।
  • Security: Malicious URLs filtering।
  • Networking: Peer-to-peer membership testing।

Bloom Filters के फायदे और सीमाएँ

फायदे

  • बहुत space-efficient।
  • Insert और check operations O(k) time में।
  • Scalable for large datasets।

सीमाएँ

  • False positives possible।
  • Delete करना आसान नहीं।

इंटरव्यू में Bloom Filters

कई बार system design interviews और competitive programming में पूछा जाता है कि आप duplicate check कैसे करेंगे?

यहाँ Bloom Filter का जिक्र करना strong impression डाल सकता है। 👉 Interviewers expect करते हैं कि आप इसके trade-offs और limitations explain करें।

निष्कर्ष

Bloom Filters एक probabilistic लेकिन powerful data structure है जो real-world large scale systems में memory और time बचाने के लिए बहुत उपयोग होता है।

History: Bloom Filter को 1970 में Burton Howard Bloom ने introduce किया था। आज यह Google BigTable, Apache Cassandra, और Redis जैसे real systems में use होता है।

सोचिए एक बहुत बड़ा checklist है जिसमें हर item पर multiple marks लगते हैं। अगर सारे marks मौजूद हैं → शायद item है, अगर कोई mark missing है → item पक्का नहीं है।

Redis Example: Redis में Bloom Filter module use होता है ताकि duplicate URLs quickly check हो सकें।

👉 एक candidate ने system design interview में Bloom Filter का जिक्र किया और interviewer instantly impressed हुआ क्योंकि उसने trade-offs भी समझाए।

False Positive Probability Formula: (1 - e^(-kn/m))^k जहाँ n = items, m = bit array size, k = hash functions।

Bloom Filter vs HashSet vs Counting Bloom Filter

FeatureBloom FilterHashSetCounting Bloom Filter
MemoryVery lowHighModerate
False PositivesYesNoYes (lower)
Delete SupportNoYesYes

FAQ: Bloom Filters

1. ब्लूम फिल्टर क्या है?

एक probabilistic data structure जो membership testing करता है।

2. क्या Bloom Filter हमेशा accurate होता है?

नहीं, इसमें false positives आ सकते हैं।

3. Bloom Filters कहाँ use होते हैं?

Databases, caching, security filters, और networking में।

4. क्या Bloom Filter से delete किया जा सकता है?

Basic Bloom Filter delete support नहीं देता, लेकिन Counting Bloom Filter देता है।

5. Interview में Bloom Filter क्यों पूछा जाता है?

क्योंकि यह space-efficient solution है और trade-off understanding check करता है।

📌 Further reading

🧑‍💻 About the Author

Anurag Rai एक टेक ब्लॉगर और नेटवर्किंग विशेषज्ञ हैं जो Accounting, AI, Game, इंटरनेट सुरक्षा और डिजिटल तकनीक पर गहराई से लिखते हैं।

Post a Comment

Blogger

Your Comment Will be Show after Approval , Thanks

Ads

 
↑ Top