cache penetration : Usually the cache is based on key to find value, if the cache does not exist, then go to the db to find, if found, the Key->value write to the cache. However, for some of the data that does not exist in the cache each time to find, so every time to find in DB, DB can not find so can't write cache, so reciprocating, then lost the meaning of the cache.
WORKAROUND: The query is empty to db, but the cache expiration time of this data need to be set to a little bit; all possible data is hashed into a bitmap by the key, and the impossible data is filtered directly by the bitmap without querying db.
Cache failure (Cache avalanche): High concurrency, we also set the same expiration time for a large number of caches, causing a cache to fail at the same time, or the machine restart caused by the cache all the same time failure. This will allow a large number of requests to look at the db at the same time, causing great pressure on db.
Workaround: Control the number of threads reading DB, and randomly set the expiration time of the cache to avoid the simultaneous failure of large caches.
cache concurrency : high concurrency, multiple threads query to a cache failure (or the key does not cache), and go to DB to find and set the cache, caused by the pressure problem.
WORKAROUND: When the query to key is empty, lock, then check DB, update the cache, unlock.