Redis Hash 的 HSET、HGET、HMSET、HMGET 性能测试

时间:2023-12-27 14:35:01

【压测环境】

操作系统: Ubuntu 14.04 LTS

Linux版本: 3.13.0-24-generic x86_64 GNU/Linux

处理器: 4核的 AMD Athlon(tm) II X4 640 Processor @ 800MHz

机器内存:共 8GB,已使用 6GB,未使用 2GB,交换区 未使用

Redis版本:2.8.17

Redis内存:500MB

【压测结果】

压测原生的 Redis 性能(非Java客户端),结果如下:

hset 和 hget 都能在 4ms 之内完成,且每秒并发处理量都在 7.5万个请求之上;

hmset 和 hmget 一次操作两个数据,都能在 5ms 之内完成,且每秒并发处理量都在 7.1万个请求之上。

【参考资料】

Benchmarks​: See how fast Redis is in different platforms. (本文档很有价值,建议详细阅读!!!)

【详细压测数据】

bert@MS-7641-14102010:/usr/apps/redis/bin$ ./redis-benchmark -r 500000 -n 500000 hset myhash rand_int rand_int rand_int

====== hset myhash rand_int rand_int rand_int ======

500000 requests completed in 6.66 seconds

50 parallel clients

3 bytes payload

keep alive: 1

99.80% <= 1 milliseconds

99.96% <= 2 milliseconds

99.99% <= 3 milliseconds

100.00% <= 3 milliseconds

75108.91 requests per second

bert@MS-7641-14102010:/usr/apps/redis/bin$ ./redis-benchmark -r 500000 -n 500000 hget myhash rand_int rand_int

====== hget myhash rand_int rand_int ======

500000 requests completed in 6.62 seconds

50 parallel clients

3 bytes payload

keep alive: 1

99.88% <= 1 milliseconds

99.99% <= 3 milliseconds

100.00% <= 4 milliseconds

100.00% <= 5 milliseconds

100.00% <= 5 milliseconds

75471.70 requests per second

bert@MS-7641-14102010:/usr/apps/redis/bin$ ./redis-benchmark -r 500000 -n 500000 hmset myhash rand_int rand_int rand_int rand_int

====== hmset myhash rand_int rand_int rand_int rand_int ======

500000 requests completed in 7.04 seconds

50 parallel clients

3 bytes payload

keep alive: 1

97.18% <= 1 milliseconds

99.89% <= 2 milliseconds

99.96% <= 3 milliseconds

99.99% <= 5 milliseconds

100.00% <= 5 milliseconds

71063.11 requests per second

bert@MS-7641-14102010:/usr/apps/redis/bin$ ./redis-benchmark -r 500000 -n 500000 hmget myhash rand_int rand_int rand_int

====== hmget myhash rand_int rand_int rand_int ======

500000 requests completed in 6.82 seconds

50 parallel clients

3 bytes payload

keep alive: 1

99.70% <= 1 milliseconds

99.97% <= 2 milliseconds

99.98% <= 3 milliseconds

99.99% <= 4 milliseconds

100.00% <= 4 milliseconds

73335.29 requests per second