---
title: "Redis Hash 的 HSET、HGET、HMSET、HMGET 性能测试"
author: "bert82503"
date: "2015-06-09T14:06:55Z"
tags: []
categories: ["互联网"]
slug: "redis-hash-hset-hget-hmset-hmget"
draft: false
lastmod: "2015-06-09T14:11:02Z"
id: 2218077
url: "https://bert82503.iteye.com/blog/2218077"
---

### 【压测环境】

操作系统： **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](http://redis.io/topics/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% &lt;= 1 milliseconds

99.96% &lt;= 2 milliseconds

99.99% &lt;= 3 milliseconds

100.00% &lt;= 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% &lt;= 1 milliseconds

99.99% &lt;= 3 milliseconds

100.00% &lt;= 4 milliseconds

100.00% &lt;= 5 milliseconds

100.00% &lt;= 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% &lt;= 1 milliseconds

99.89% &lt;= 2 milliseconds

99.96% &lt;= 3 milliseconds

99.99% &lt;= 5 milliseconds

100.00% &lt;= 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% &lt;= 1 milliseconds

99.97% &lt;= 2 milliseconds

99.98% &lt;= 3 milliseconds

99.99% &lt;= 4 milliseconds

100.00% &lt;= 4 milliseconds

73335.29 requests per second