Cache penetration
Last updated
Was this helpful?
Last updated
Was this helpful?
Cache penetration occurs when there is a cache miss, but the primary database also lacks the required data.
Within the business code, cache special values for empty entries
If each time attacker query different and non-existing keys, large space could be consumed and actual useful entries will be purged out of the storage.
Use case
Time complexity: O(1) read/write
Space complexity: Within 1 billion records (roughly 1.2GB memory)
The order of cache and bloomfilter could switch:
Cache first, bloomfilter second: Better performance for normal requests
Bloomfilter first, cache second: Better protection against attacks.
False positives
Solution: Use multiple hash algorithm to calculate multiple hash values
No support for delete
Solution: Store a counter for each entry
when a significant number of caches expire at the same time, which leads to a large number of requests that don't hit the cache and instead directly query the database. T
Jitter to expiration time
Rate limiting / Circuit breaker to DB