How do you use redis-benchmark util to fill up a redis cluster memory?

Viewed 330

So basically I have a redis cluster deployed in AWS (Elasticache cluster mode) and I'm trying to run a util/test to have it's available memory utilization to fill up past a threshold to test my auto scaling. I've heard that the built in redis-benchmark util can be used to achieve this task but I'm struggling to get any success with it. Anyone have experience with this?

Goal: Use either redis-benchmark or similar util to write random keys/values to redis to fill up roughly 6gb of memory storage.

1 Answers

Instead of redis-benchmark you may use DEBUG POPULATE command of Redis to fill it with dummy data. But since DEBUG is a restricted command in AWS Elasticache Redis (as we discussed in the comments), another option could be using a lua script to fill it with dummy data.

I wrote the following lua snippet(i know not super clean and i am not super familiar)

for i = 1, 1000 do
    a[i] = "1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111"
end

for i = 1, 50000 do
    redis.call("RPUSH", i, unpack(a))
end

What it does is to fill the redis with multiple lists with multiple elements within it. It fill around ~4.6 GB data in couple of seconds. You may edit the parameters(second loop's upper bound) to re-run again.

I chose lists instead of sets or sorted sets to enable duplicate elements. Even though you re-run the script, it will push to the same lists again and again.

After you connected to your cluster via redis-cli, you may execute the following command on cli

eval "local a={}  for i=1,1000 do  a[i] = '1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111' end for i=1, 50000 do redis.call('RPUSH', i, unpack(a)) end" 0

You need to access to your redis cluster within the vpc. I've explained the concepts here before.

Related