Hamza Saeed
Hamza Saeed

Reputation: 304

Is FLUSHALL ASYNC thread safe in Redis?

I am new in DevOps so kindly guide me if FLUSHALL ASYNC in Redis thread safe. Will it effect my server performance as Redis deletes the keys in background using a different thread without blocking the server? currently using: laravel P.S I want to use this command so that my server does not become unresponsive as it became earlier (For 10s and all the hits keep on adding up causing CPU starvation)

Upvotes: 2

Views: 2392

Answers (1)

LeoMurillo
LeoMurillo

Reputation: 6754

What FLUSHALL ASYNC does actually is to create a new empty set of hash tables for each database dictionary (each dictionary has two hash tables) and scheduling the old ones for lazy freeing.

It is thread-safe, but it will increase your CPU usage while the databases are being emptied in the background, and you can expect some performance degradation as well.

On an empty redis-server I loaded a couple of databases with 20M keys each:

>select 4
OK
[4]> debug populate 20000000 key 20
OK
(16.49s)
[4]> select 3
OK
[3]> debug populate 20000000 key 20
OK
(16.75s)
[3]> info memory
# Memory
used_memory:3739770656
used_memory_human:3.48G

Ran benchmark:

~$ redis-benchmark -c 5 -t set,lpush -q
SET: 30413.62 requests per second
LPUSH: 30553.01 requests per second

Same benchmark right after running FLUSHALL ASYNC (server deleting 40M keys in the background):

~$ redis-benchmark -c 5 -t set,lpush -q
SET: 26288.12 requests per second
LPUSH: 25367.83 requests per second

I see a ~15% degradation

Upvotes: 8

Related Questions