How to deal with the error RedisException: OOM command not allowed when used memory > ‘maxmemory’ in WordPress?

Original link: -deal-with/


When I woke up in the morning, I wanted to log in to my blog and record my inspiration, but I suddenly found that I couldn’t log in to the WordPress backend.

Logged in to the VPS backend and found that I didn’t have the problem I used to have – the hard drive was full. So I went back to the web page to log in again. After careful research, I found that my login should be successful, but after the login was completed, I jumped back again. According to this situation, I guessed that there may be a problem with the login state.

So I tried switching to the incognito mode of Safari and Chrome to log in, but it still didn’t solve the problem. Therefore, the problem caused by the client can be ruled out.

find the problem

The next step is to look at the server-side problem. Log in to the server, find the WordPress log, check the recent logs, and suddenly see an Exception among the many Notices:

 RedisException: OOM command not allowed when used memory > 'maxmemory'

When I saw this error, I suddenly understood where the problem was.

My WordPress uses Redis as the cache, and the cache space I have configured in the past is 128M. Seeing the error, it is obviously because the memory space used by Redis is greater than 128M, and I did not configure the eviction mechanism in the past (the default is noeviction ), resulting in direct OOM exploded.

And my login state also uses Redis, there is no way to insert a new key into the cache, and the login fails naturally.

Solve the problem

Once the problem is identified, the next step is to fix it.

Solving the problem is not complicated. Adjusting the memory space size for Redis and configuring the eviction mechanism can solve this problem.

 maxmemory 221000000maxmemory-policy allkeys-lru

After setting the Redis eviction mechanism to allkeys-lru and setting the memory to 200M, restart Redis, and sure enough, my WordPress can log in normally.

refer to

allkeys-lru means to remove the least recently used (least recently used) Key.

For more algorithms, please refer to Key Evicution

This article is reprinted from: -deal-with/
This site is for inclusion only, and the copyright belongs to the original author.

Leave a Comment