When using redis in a project, we mainly consider it from two perspectives: performance and concurrency. Of course, redis also has other functions such as distributed locks, but if it is just for other functions such as distributed locks, there are other middleware (such as zookpeer, etc.) instead, and it is not necessary to use redis.
Therefore, this question is mainly answered from two perspectives: performance and concurrency. (Recommended learning: Redis video tutorial)
(1) Performance
As shown in the figure below, we encounter the need to execute in SQL that takes a particularly long time and whose results do not change frequently is particularly suitable for putting the running results into the cache. In this way, subsequent requests will be read from the cache, so that the request can be responded to quickly.
(2) Concurrency
As shown in the figure below, in the case of large concurrency, all requests directly access the database. There will be a connection exception in the database. At this time, you need to use redis to perform a buffering operation so that the request can access redis first instead of directly accessing the database.
For more Redis-related technical articles, please visit the Redis database usage tutorial column to learn!
The above is the detailed content of Why distribution must have redis. For more information, please follow other related articles on the PHP Chinese website!