edit-icon download-icon

Introduction of Redis-benchmark usage

Last Updated: Aug 08, 2017

Redis includes the following parameters for the redis-benchmark utility used to test the Redis service performance.

Parameters

  1. Usage: redis-benchmark [-h] [-p] [-c] [-n[-k]
  2. -h Server hostname (default 127.0.0.1)
  3. -p Server port (default 6379)
  4. -s Server socket (overrides host and port)
  5. -c Number of parallel connections (default 50)
  6. -n Total number of requests (default 10000)
  7. -d Data size of SET/GET value in bytes (default 2)
  8. -k 1=keep alive 0=reconnect (default 1)
  9. -r Use random keys for SET/GET/INCR, random values for SADD
  10. Using this option the benchmark will get/set keys
  11. in the form mykey_rand:000000012456 instead of constant
  12. keys. The argument determines the maximum
  13. number of values for the random number. For instance
  14. if set to 10 only rand:000000000000 - rand:000000000009
  15. range will be allowed.
  16. -P Pipelinerequests. Default 1 (no pipeline).
  17. -q Quiet. Just show query/sec values
  18. csv Output in CSV format
  19. -l Loop. Run the tests forever
  20. -t Only run the comma-separated list of tests. The test
  21. names are the same as those produced in the output.
  22. -I Idle mode. Open N idle connections.

Test command examples

  • redis-benchmark -h 192.168.1.201 -p 6379 -c 100 -n 100000

    The command is used to test the performance of the Redis server that uses the localhost, and Port 6379, in the event of 100 concurrent connections and 100,000 requests.

  • redis-benchmark -h 192.168.1.201 -p 6379 -q -d 100

    The command is used to test the performance of access to 100-byte packets.

  • redis-benchmark -t set,lpush -n 100000 -q

    The command is only used to test the performance of selected operations.

  • redis-benchmark -n 100000 -q script load “redis.call(‘set’,’foo’,’bar’)”

    The command is only used to test the performance of access to select numeric values.

    The error “writing to socket: connection timed out” is returned during an actual test.

    Enter netstat -an to check whether multiple ports exist. Restart the Redis instance to release connections. Then perform the test again.

Thank you! We've received your feedback.