Redis-- avalanche cache, the cache penetration, warm cache, cache updates, cache downgrade

Redis caching mechanism is: when there is a query operation, will first query Redis, if Redis is not the key, it will go to query the database, and the query results written to the Redis, the next time when the query, it will directly queries from the Redis

Cache Avalanche: Due to the limited memory, we generally give a valid cache settings, if a large number of key redis at the same time fails, and these failures are at the same time a large number of key access, so these visits will go a database, and cause great pressure on the database

Avalanche caching solution: to expiration time plus a random value when the cache, which would greatly reduce the cache expire at the same time

Cache penetrate: the data is queried, does not exist in the redis not exist in the database, query result is null, we can not write to Redis, when there are one million concurrent queries this data due to the redis It does not exist, then all queries to the database, so the database will cause great pressure

Solution cache penetration: If you find data query does not exist, then we give the key assignments, assign an empty string "", due to the limited memory, setting a shorter expiration time of the empty string, so that when the occurrence of high concurrency, you can go directly to the cache redis

Cache warming: is our program ape, you can put high data access may visit again, redis loaded into the cache, so that when the project deployment, users can directly access to visit redis cached, reducing the pressure on the database access

Cache Update: When we update the data, we first update the data in the database, the data in the cache after a successful failure

Cache downgrade: When the traffic surge, the service problems (such as slow response times or no response) or non-core services affects the performance of core processes still need to ensure that the service is still available. The system may automatically downgrade critical data, the switch may be arranged to achieve artificial degraded, e.g., unstable just on some service timeout may downgrade its own line, another example, for special reasons, the data errors, the need for manual downgrade

Published 422 original articles · won praise 273 · views 70000 +

Guess you like

Origin blog.csdn.net/HeZhiYing_/article/details/104573788