Recently, we have been noticing CPU spikes on our production environment caused by redis which can be seen below:
To combat this issue, I have been restarting the redis server about twice a day :( which is obviously far from ideal. I'd like to identify the root cause.
Here are some things I have looked into so far:
1) Look into any anomalies in the redis log file. The following seems suspicious:
2) Researched nginx access logs to see if we are experiencing unusually high traffic. The answer is no.
3) New Relic revealed that the issue started on Nov 21st, 16` (about a month ago) but no code was released around that time.
Here are some details about our setup:
Redis server: Redis server v=2.8.17 sha=00000000:0 malloc=jemalloc-3.6.0 bits=64 build=64a9cf396cbcc4c7
PHP: 5.3.27
with fpm
Redis configuration:
daemonize yes pidfile /var/run/redis/redis.pid port 6379 timeout 0 tcp-keepalive 0 loglevel notice logfile /var/log/redis/redis.log syslog-enabled yes databases 16 save 900 1 save 300 10 save 60 10000 stop-writes-on-bgsave-error no rdbcompression yes rdbchecksum yes dbfilename redis.rdb dir /var/lib/redis/ slave-serve-stale-data yes slave-read-only yes repl-disable-tcp-nodelay no slave-priority 100 maxmemory 15GB appendonly no appendfsync everysec no-appendfsync-on-rewrite no auto-aof-rewrite-percentage 100 auto-aof-rewrite-min-size 64mb lua-time-limit 5000 slowlog-max-len 128 notify-keyspace-events "" hash-max-ziplist-entries 512 hash-max-ziplist-value 64 list-max-ziplist-entries 512 list-max-ziplist-value 64 set-max-intset-entries 512 zset-max-ziplist-entries 128 zset-max-ziplist-value 64 activerehashing yes client-output-buffer-limit normal 0 0 0 client-output-buffer-limit slave 256mb 64mb 60 client-output-buffer-limit pubsub 32mb 8mb 60 hz 10 aof-rewrite-incremental-fsync yes include /etc/redis/conf.d/local.conf
Framework: Magento 1.7.2 with Cm_Cache_Backend_Redis
Please let me know if given the above information there is anything I can do to mitigate the high cpu usage.
yam
command. Any idea what that is? The redis server process is typically named,redis-server
.yam
and sometimesredis-server
. I am wondering if you have any input as far as how exactly thisyam
command gets triggered. How would I get down to the bottom of this? Our server uses ssh keys for user login but I just confirmed our redis is accessible to the outside world by simply specifying the host. YIKES. That being said, how would someone with access to redis be able to configure it to run YAM?/opt/yam/yam
to see if it exists. If it does, you are likely compromised. Also check/root/.ssh/authorized_keys
and make sure only SSH keys that you know about are there. As for the vector of compromise, here is a proposed hackhttp://antirez.com/news/96
that can be used to download a script to your computer and run it periodically. You’ll also want to check each user's crontab and the global crontab to make sure yam does not appear there.