Business scenario:
1. Employee check-in
2.Product flash sale online
3.Online sign-up for school programs/courses
Bussiness solution&Technical solution
1.Analyze the business scenarios to identify operations with hig QPS and TPS. List all relevant database tables involved along with their data charateristics.
2.Using a primary/replica setup is optimal. We can configure either a single primary with multiple replicas or multiple primaries with multiple replicas. This architecture is beneficial for distributing query operations during periods of high traffic, effectively managing increased loads.
3.Monitor Redis for hotkeys regularly and trigger alerts when detected
4.Design a multi-level caching architecture during application development to reduce the likelihood of Redis hotkeys forming. For example: in-memory session cache (e.g., Spring Session), local cache, and Redis cache.
5.Avoid using similar keys in the application. Having a large number of similar keys can increase the probability of hash collisions and reduce the efficiency of batch operations, as each key must be processed individually. In particular, when key sizes vary, it may lead to non-contiguous memory allocation and cause memory fragmentation.
6.Preload hot data into Redis before the application starts to prevent cache avalanche caused by high concurrent requests or cache misses.