先检查redis的慢日志,slowlog get 5,如果有慢日志,使用keys和keys*的去匹配,我们要进行改正代码。推荐使用scan来代替keys 4.如果优化了redis命令,cpu还是下不来,我们可以使用redis的官方建议,排查下,使用以下命令
latency doctor
结果如下
Deleting, expiring or evicting (because of maxmemory policy) large objects is a blocking operation. If you have very large objects that ar e often deleted, expired, or evicted, try to fragment those objects into multiple smaller objects.
I detected a non zero amount of anonymous huge pages used by your process. This creates very serious latency events in different condition s, especially when Redis is persisting on disk. To disable THP support use the command ‘echo never > /sys/kernel/mm/transparent_hugepage/ena bled’, make sure to also add it into /etc/rc.local so that the command will be executed again after a reboot. Note that even if you have alr eady disabled THP, you still need to restart the Redis process to get rid of the huge pages already created.