Redis occupies an increasingly important position in distributed applications. With just tens of thousands of lines of code, a high-performance data storage service is implemented.
Check the redis source code and find that redis will time out under certain circumstances, as follows:
1. Network. Redis processing is closely related to the network. If the network is interrupted, redis timeout is likely to occur. If this situation occurs, you should first check the network bandwidth information of the redis machine to determine whether there is an interruption.
2. Memory. All redis data is stored in memory. When the physical memory is not enough, Linux OS will use swap memory, causing memory swapping. At this time, if there is a redis call command, a redis timeout will occur. Here you can adjust the /proc/sys/vm/swappiness parameter to set the amount of physical memory used before swapping.
Maximum cache setting
Example: maxmemory 100mb
Unit: mb, gb.
The default is 0, and the maximum cache is not specified. If new data is added and exceeds the maximum memory, redis will crash, so it needs to be set.
After setting maxmemory, the cache data recycling policy must be set accordingly.
The above is the detailed content of How much data can redis cache at most?. For more information, please follow other related articles on the PHP Chinese website!