Hot swap config value with redis-cli

To set maxmemory to 900mb (bits so 800*1024*1024) for redis 2.6 :

redis-cli CONFIG SET maxmemory  943718400

and to check :

redis-cli CONFIG GET maxmemory
1) "maxmemory"
2) "943718400"

Don’t forget to update the config file for the next restart !

Do a benchmark

For that there is the command redis-benchmark.

Use case with 100000 requests , 12 simultaneous commands et 50 clients on 127.0.0.1 (default) :

$ redis-benchmark -q -n 100000 -c 50 -P 12

Options (use man for all options) :

-q => Quiet. Just show query/sec values
-n => <requests> Total number of requests
-c => <clients>  Number of parallel connections (default 50)
-P => <numreq>        Pipeline <numreq> requests. Default 1
-h <hostname>      Server hostname (default 127.0.0.1)
-p <port>          Server port (default 6379)
-s <socket>        Server socket (overrides host and port)
-a <password>      Password for Redis Auth

Anothers examples :

 Run the benchmark with the default configuration against 127.0.0.1:6379:
   $ redis-benchmark
 Use 20 parallel clients, for a total of 100k requests, against 192.168.1.1:
   $ redis-benchmark -h 192.168.1.1 -p 6379 -n 100000 -c 20
 Fill 127.0.0.1:6379 with about 1 million keys only using the SET test:
   $ redis-benchmark -t set -n 1000000 -r 100000000
 Benchmark 127.0.0.1:6379 for a few commands producing CSV output:
   $ redis-benchmark -t ping,set,get -n 100000 --csv
 Benchmark a specific command line:
   $ redis-benchmark -r 10000 -n 10000 eval 'return redis.call("ping")' 0
 Fill a list with 10000 random elements:
   $ redis-benchmark -r 10000 -n 10000 lpush mylist __rand_int__

Optimize Redis performance

There are a lot of useful explanations in the pdf below:

Understanding-the-Top-5-Redis-Performance-Metrics.pdf

Track latency with redis latency monitor

http://redis.io/topics/latency-monitor

Delete multiple index :

redis-cli -h hostname -a password KEYS "prefix*"|xargs redis-cli -h hostname -a password DEL

Sample explaination of redis log

[2476] - process ID

dump.rdb - redis can persist data by snapshoting, dump.rdb is default file name http://redis.io/topics/persistence

0 slaves - redis can work in master-slave mode, 0 slaves informs you that there are no slave servers connected

1188312 bytes in use - total number of bytes allocated by Redis using its allocator

0 volatile - redis can set keys with expiration time, this is count of them

4 slots HT - current hash table size, initial table size is 4, once you will be adding more items hash table will grow

Source