Redis : benchmark

Petit benchmark sur trois versions de Redis sur Fédora 17 64b :

Taille binaire 3.6 Mo 4.7 Mo 5.2 Mo
 requests per second \ Version 2.8.4 3.2.3 4.0.1
PING_INLINE 39682.54 45248.87 45871.56
PING_BULK 45871.56 44843.05 45248.87
SET 45662.10 45454.55 46082.95
GET 46511.63 44843.05 44642.86
INCR 46511.63 47393.37 46511.63
LPUSH 46082.95 46728.97 47846.89
LPOP 48076.92 46948.36 47393.37
SADD 47619.05 45871.56 46728.97
SPOP 46728.97 45454.55 45871.56
LPUSH 47846.89 45871.56 47619.05
LRANGE_100 24330.90 24390.24 24096.39
LRANGE_300 10351.97 10449.32 10416.67
LRANGE_500 7423.90 7451.56 7429.42
LRANGE_500 5865.10 5841.12 5820.72
MSET 36231.89 44843.05 44444.45

Il n’y a pas de grosse différence de performance sauf sur le MSET & PING_INLINE.

La configuration de l’OS et de Redis :

-Comment connaitre la configuration de l’OS ?

[root@]# cat /etc/sysctl.conf | grep -v "^$" | grep -v "^#"
net.ipv4.ip_forward = 0
net.ipv4.conf.default.rp_filter = 1
net.ipv4.conf.default.accept_source_route = 0
kernel.sysrq = 0
kernel.core_uses_pid = 1
net.bridge.bridge-nf-call-ip6tables = 0
net.bridge.bridge-nf-call-iptables = 0
net.bridge.bridge-nf-call-arptables = 0
vm.overcommit_memory = 1

-Comment connaitre la configuration de Redis ? (On peut aussi utiliser la commande INFO avec redis-cli )

[root@]# cat /etc/redis/6379.conf | grep -v "^$" | grep -v "^#"
daemonize yes
pidfile /var/run/redis_6379.pid
port 6379
timeout 0
tcp-keepalive 0
loglevel notice
logfile /var/log/redis_6379.log
databases 16
save 900 1
save 300 10
save 60 10000
stop-writes-on-bgsave-error yes
rdbcompression yes
rdbchecksum yes
dbfilename dump.rdb
dir /var/lib/redis/6379
slave-serve-stale-data yes
slave-read-only yes
repl-disable-tcp-nodelay no
slave-priority 100
appendonly no
appendfilename "appendonly.aof"
appendfsync everysec
no-appendfsync-on-rewrite no
auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mb
lua-time-limit 5000
slowlog-log-slower-than 10000
slowlog-max-len 128
notify-keyspace-events ""
hash-max-ziplist-entries 512
hash-max-ziplist-value 64
list-max-ziplist-entries 512
list-max-ziplist-value 64
set-max-intset-entries 512
zset-max-ziplist-entries 128
zset-max-ziplist-value 64
activerehashing yes
client-output-buffer-limit normal 0 0 0
client-output-buffer-limit slave 256mb 64mb 60
client-output-buffer-limit pubsub 32mb 8mb 60
hz 10
aof-rewrite-incremental-fsync yes

-Comment savoir quel RAID est sur le serveur ?

[root@]# lspci -vv | grep -i raid
02:0e.0 RAID bus controller: Dell PowerEdge Expandable RAID controller 5
        Subsystem: Dell PERC 5/i Integrated RAID Controller
        Kernel driver in use: megaraid_sas

-Comment savoir s’il y a un RAID soft ?

[root@]# cat /proc/mdstat
Personalities :
unused devices: 

-Comment connaitre la version du kernel ? (On peut aussi faire uname -a )

[root@]# cat /proc/version
Linux version 3.3.4-5.fc17.x86_64 (mockbuild@x86-14.phx2.fedoraproject.org) (gcc version 4.7.0 20120504 (Red Hat 4.7.0-4) (GCC) ) #1 SMP Mon May 7 17:29:34 UTC 2012

Les performances du serveur de test :

– Comment voir le nombre de processeur et la version ?

[root@]# cat /proc/cpuinfo | grep "model name"
model name      : Intel(R) Xeon(R) CPU           L5310  @ 1.60GHz
model name      : Intel(R) Xeon(R) CPU           L5310  @ 1.60GHz
model name      : Intel(R) Xeon(R) CPU           L5310  @ 1.60GHz
model name      : Intel(R) Xeon(R) CPU           L5310  @ 1.60GHz
[root@]# cat /proc/meminfo | head -4
MemTotal:        4045024 kB
MemFree:          125852 kB
Buffers:          193848 kB
Cached:          2981328 kB

– Comment tester le disque dur sous Linux ? ( le mieux est la commande dd)

[root@]# dd if=/dev/zero of=/root/testfile bs=1G count=1 oflag=dsync
1+0 records in
1+0 records out
1073741824 bytes (1.1 GB) copied, 17.1374 s, 62.7 MB/s
[root@]# dd if=/dev/zero of=/root/testfile bs=512 count=1000 oflag=dsync
1000+0 records in
1000+0 records out
512000 bytes (512 kB) copied, 6.37535 s, 80.3 kB/s
[root@]# dd if=/dev/zero of=/root/testfile bs=1G count=1 oflag=direct
1+0 records in
1+0 records out
1073741824 bytes (1.1 GB) copied, 17.4031 s, 61.7 MB/s

Le détail des résultats :

Version 2.8.4 :

[root@]# redis-cli
127.0.0.1:6379> INFO
# Server
redis_version:2.8.4
redis_git_sha1:00000000
redis_git_dirty:0
redis_build_id:45290db95ad5c1f7
redis_mode:standalone
os:Linux 3.3.4-5.fc17.x86_64 x86_64
arch_bits:64
multiplexing_api:epoll
gcc_version:4.7.2
process_id:1209
run_id:ba7c772f8e6db75fe69e1768ffd57f2330e931f0
tcp_port:6379
uptime_in_seconds:26091851
uptime_in_days:301
hz:10
lru_clock:1572737
config_file:/etc/redis/6379.conf
 
# Clients
connected_clients:15
client_longest_output_list:0
client_biggest_input_buf:0
blocked_clients:0
 
# Memory
used_memory:1102152
used_memory_human:1.05M
used_memory_rss:3121152
used_memory_peak:118655144
used_memory_peak_human:113.16M
used_memory_lua:33792
mem_fragmentation_ratio:2.83
mem_allocator:jemalloc-3.2.0
 
# Persistence
loading:0
rdb_changes_since_last_save:0
rdb_bgsave_in_progress:0
rdb_last_save_time:1489512608
rdb_last_bgsave_status:ok
rdb_last_bgsave_time_sec:0
rdb_current_bgsave_time_sec:-1
aof_enabled:0
aof_rewrite_in_progress:0
aof_rewrite_scheduled:0
aof_last_rewrite_time_sec:-1
aof_current_rewrite_time_sec:-1
aof_last_bgrewrite_status:ok
 
# Stats
total_connections_received:178
total_commands_processed:18286237
instantaneous_ops_per_sec:1
rejected_connections:0
sync_full:0
sync_partial_ok:0
sync_partial_err:0
expired_keys:0
evicted_keys:0
keyspace_hits:377307
keyspace_misses:8745933
pubsub_channels:1
pubsub_patterns:0
latest_fork_usec:3108
 
# Replication
role:master
connected_slaves:0
master_repl_offset:0
repl_backlog_active:0
repl_backlog_size:1048576
repl_backlog_first_byte_offset:0
repl_backlog_histlen:0
 
# CPU
used_cpu_sys:1975.65
used_cpu_user:3046.59
used_cpu_sys_children:2.06
used_cpu_user_children:19.21
 
# Keyspace
db0:keys=3,expires=0,avg_ttl=0
127.0.0.1:6379> QUIT
 
[root@]# redis-benchmark
====== PING_INLINE ======
  10000 requests completed in 0.25 seconds
  50 parallel clients
  3 bytes payload
  keep alive: 1
 
98.22% <= 1 milliseconds
98.25% <= 2 milliseconds
98.51% <= 3 milliseconds
98.52% <= 4 milliseconds
99.01% <= 5 milliseconds
99.02% <= 6 milliseconds
99.51% <= 19 milliseconds
99.61% <= 20 milliseconds
99.70% <= 21 milliseconds
99.77% <= 23 milliseconds
99.78% <= 24 milliseconds
99.83% <= 25 milliseconds
99.88% <= 26 milliseconds
99.93% <= 27 milliseconds
100.00% <= 27 milliseconds
39682.54 requests per second
 
====== PING_BULK ======
  10000 requests completed in 0.22 seconds
  50 parallel clients
  3 bytes payload
  keep alive: 1
 
99.77% <= 1 milliseconds
100.00% <= 1 milliseconds
45871.56 requests per second
 
====== SET ======
  10000 requests completed in 0.22 seconds
  50 parallel clients
  3 bytes payload
  keep alive: 1
 
98.79% <= 1 milliseconds
99.51% <= 6 milliseconds
99.52% <= 7 milliseconds
100.00% <= 7 milliseconds
45662.10 requests per second
 
====== GET ======
  10000 requests completed in 0.22 seconds
  50 parallel clients
  3 bytes payload
  keep alive: 1
 
99.99% <= 1 milliseconds
100.00% <= 1 milliseconds
46511.63 requests per second
 
====== INCR ======
  10000 requests completed in 0.22 seconds
  50 parallel clients
  3 bytes payload
  keep alive: 1
 
99.50% <= 1 milliseconds
99.51% <= 5 milliseconds
99.53% <= 6 milliseconds
100.00% <= 6 milliseconds
46511.63 requests per second
 
====== LPUSH ======
  10000 requests completed in 0.22 seconds
  50 parallel clients
  3 bytes payload
  keep alive: 1
 
97.58% <= 1 milliseconds
98.87% <= 2 milliseconds
99.01% <= 4 milliseconds
99.04% <= 5 milliseconds
99.51% <= 6 milliseconds
100.00% <= 6 milliseconds
46082.95 requests per second
 
====== LPOP ======
  10000 requests completed in 0.21 seconds
  50 parallel clients
  3 bytes payload
  keep alive: 1
 
100.00% <= 0 milliseconds
48076.92 requests per second
 
====== SADD ======
  10000 requests completed in 0.21 seconds
  50 parallel clients
  3 bytes payload
  keep alive: 1
 
100.00% <= 0 milliseconds
47619.05 requests per second
 
====== SPOP ======
  10000 requests completed in 0.21 seconds
  50 parallel clients
  3 bytes payload
  keep alive: 1
 
100.00% <= 0 milliseconds
46728.97 requests per second
 
====== LPUSH (needed to benchmark LRANGE) ======
  10000 requests completed in 0.21 seconds
  50 parallel clients
  3 bytes payload
  keep alive: 1
 
100.00% <= 0 milliseconds
47846.89 requests per second
 
====== LRANGE_100 (first 100 elements) ======
  10000 requests completed in 0.41 seconds
  50 parallel clients
  3 bytes payload
  keep alive: 1
 
26.94% <= 1 milliseconds
99.76% <= 2 milliseconds
100.00% <= 2 milliseconds
24330.90 requests per second
 
====== LRANGE_300 (first 300 elements) ======
  10000 requests completed in 0.97 seconds
  50 parallel clients
  3 bytes payload
  keep alive: 1
 
0.05% <= 1 milliseconds
7.37% <= 2 milliseconds
98.33% <= 3 milliseconds
99.39% <= 4 milliseconds
99.51% <= 8 milliseconds
99.66% <= 9 milliseconds
99.76% <= 10 milliseconds
99.85% <= 11 milliseconds
99.89% <= 12 milliseconds
100.00% <= 12 milliseconds
10351.97 requests per second
 
====== LRANGE_500 (first 450 elements) ======
  10000 requests completed in 1.35 seconds
  50 parallel clients
  3 bytes payload
  keep alive: 1
 
0.04% <= 1 milliseconds
0.18% <= 2 milliseconds
8.92% <= 3 milliseconds
96.10% <= 4 milliseconds
99.17% <= 5 milliseconds
99.76% <= 6 milliseconds
99.98% <= 7 milliseconds
100.00% <= 7 milliseconds
7423.90 requests per second
 
====== LRANGE_600 (first 600 elements) ======
  10000 requests completed in 1.71 seconds
  50 parallel clients
  3 bytes payload
  keep alive: 1
 
0.03% <= 1 milliseconds
0.10% <= 2 milliseconds
4.51% <= 3 milliseconds
42.36% <= 4 milliseconds
86.33% <= 5 milliseconds
99.66% <= 6 milliseconds
99.81% <= 7 milliseconds
99.92% <= 8 milliseconds
100.00% <= 8 milliseconds
5865.10 requests per second
 
====== MSET (10 keys) ======
  10000 requests completed in 0.28 seconds
  50 parallel clients
  3 bytes payload
  keep alive: 1
 
1.86% <= 1 milliseconds
98.38% <= 2 milliseconds
99.96% <= 3 milliseconds
100.00% <= 3 milliseconds
36231.89 requests per second
 

Version 3.2.3 :

[root@]# redis-cli
127.0.0.1:6379> INFO
# Server
redis_version:3.2.3
redis_git_sha1:00000000
redis_git_dirty:0
redis_build_id:c320b20d6ae2b69
redis_mode:standalone
os:Linux 3.3.4-5.fc17.x86_64 x86_64
arch_bits:64
multiplexing_api:epoll
gcc_version:4.7.2
process_id:31230
run_id:f162b054d0f8f4ff52411bdd363bca7e3af31f3d
tcp_port:6379
uptime_in_seconds:18
uptime_in_days:0
hz:10
lru_clock:11535732
executable:/root/redis-3.2.3/src/redis-server
config_file:/etc/redis/6379.conf
 
# Clients
connected_clients:15
client_longest_output_list:0
client_biggest_input_buf:0
blocked_clients:0
 
# Memory
used_memory:1114560
used_memory_human:1.06M
used_memory_rss:7720960
used_memory_rss_human:7.36M
used_memory_peak:1133608
used_memory_peak_human:1.08M
total_system_memory:4142104576
total_system_memory_human:3.86G
used_memory_lua:37888
used_memory_lua_human:37.00K
maxmemory:0
maxmemory_human:0B
maxmemory_policy:noeviction
mem_fragmentation_ratio:6.93
mem_allocator:jemalloc-4.0.3
 
# Persistence
loading:0
rdb_changes_since_last_save:0
rdb_bgsave_in_progress:0
rdb_last_save_time:1504707938
rdb_last_bgsave_status:ok
rdb_last_bgsave_time_sec:-1
rdb_current_bgsave_time_sec:-1
aof_enabled:0
aof_rewrite_in_progress:0
aof_rewrite_scheduled:0
aof_last_rewrite_time_sec:-1
aof_current_rewrite_time_sec:-1
aof_last_bgrewrite_status:ok
aof_last_write_status:ok
 
# Stats
total_connections_received:15
total_commands_processed:9
instantaneous_ops_per_sec:0
total_net_input_bytes:247
total_net_output_bytes:81
instantaneous_input_kbps:0.00
instantaneous_output_kbps:0.00
rejected_connections:0
sync_full:0
sync_partial_ok:0
sync_partial_err:0
expired_keys:0
evicted_keys:0
keyspace_hits:0
keyspace_misses:4
pubsub_channels:1
pubsub_patterns:0
latest_fork_usec:0
migrate_cached_sockets:0
 
# Replication
role:master
connected_slaves:0
master_repl_offset:0
repl_backlog_active:0
repl_backlog_size:1048576
repl_backlog_first_byte_offset:0
repl_backlog_histlen:0
 
# CPU
used_cpu_sys:0.01
used_cpu_user:0.00
used_cpu_sys_children:0.00
used_cpu_user_children:0.00
 
# Cluster
cluster_enabled:0
 
# Keyspace
127.0.0.1:6379> QUIT
 
[root@]# redis-benchmark
====== PING_INLINE ======
  10000 requests completed in 0.22 seconds
  50 parallel clients
  3 bytes payload
  keep alive: 1
 
99.67% <= 1 milliseconds
100.00% <= 1 milliseconds
45248.87 requests per second
 
====== PING_BULK ======
  10000 requests completed in 0.22 seconds
  50 parallel clients
  3 bytes payload
  keep alive: 1
 
99.99% <= 1 milliseconds
100.00% <= 1 milliseconds
44843.05 requests per second
 
====== SET ======
  10000 requests completed in 0.22 seconds
  50 parallel clients
  3 bytes payload
  keep alive: 1
 
100.00% <= 0 milliseconds
45454.55 requests per second
 
====== GET ======
  10000 requests completed in 0.22 seconds
  50 parallel clients
  3 bytes payload
  keep alive: 1
 
100.00% <= 0 milliseconds
44843.05 requests per second
 
====== INCR ======
  10000 requests completed in 0.21 seconds
  50 parallel clients
  3 bytes payload
  keep alive: 1
 
98.46% <= 1 milliseconds
99.99% <= 2 milliseconds
100.00% <= 2 milliseconds
47393.37 requests per second
 
====== LPUSH ======
  10000 requests completed in 0.21 seconds
  50 parallel clients
  3 bytes payload
  keep alive: 1
 
99.90% <= 1 milliseconds
100.00% <= 1 milliseconds
46728.97 requests per second
 
====== LPOP ======
  10000 requests completed in 0.21 seconds
  50 parallel clients
  3 bytes payload
  keep alive: 1
 
99.55% <= 1 milliseconds
100.00% <= 1 milliseconds
46948.36 requests per second
 
====== SADD ======
  10000 requests completed in 0.22 seconds
  50 parallel clients
  3 bytes payload
  keep alive: 1
 
100.00% <= 0 milliseconds
45871.56 requests per second
 
====== SPOP ======
  10000 requests completed in 0.22 seconds
  50 parallel clients
  3 bytes payload
  keep alive: 1
 
100.00% <= 0 milliseconds
45454.55 requests per second
 
====== LPUSH (needed to benchmark LRANGE) ======
  10000 requests completed in 0.22 seconds
  50 parallel clients
  3 bytes payload
  keep alive: 1
 
99.97% <= 1 milliseconds
100.00% <= 1 milliseconds
45871.56 requests per second
 
====== LRANGE_100 (first 100 elements) ======
  10000 requests completed in 0.41 seconds
  50 parallel clients
  3 bytes payload
  keep alive: 1
 
3.55% <= 1 milliseconds
99.91% <= 2 milliseconds
100.00% <= 2 milliseconds
24390.24 requests per second
 
====== LRANGE_300 (first 300 elements) ======
  10000 requests completed in 0.96 seconds
  50 parallel clients
  3 bytes payload
  keep alive: 1
 
0.08% <= 1 milliseconds
1.86% <= 2 milliseconds
96.65% <= 3 milliseconds
98.61% <= 4 milliseconds
99.64% <= 5 milliseconds
99.97% <= 6 milliseconds
100.00% <= 7 milliseconds
10449.32 requests per second
 
====== LRANGE_500 (first 450 elements) ======
  10000 requests completed in 1.34 seconds
  50 parallel clients
  3 bytes payload
  keep alive: 1
 
0.04% <= 1 milliseconds
0.19% <= 2 milliseconds
4.46% <= 3 milliseconds
96.98% <= 4 milliseconds
98.78% <= 5 milliseconds
99.41% <= 6 milliseconds
99.65% <= 7 milliseconds
99.93% <= 8 milliseconds
100.00% <= 9 milliseconds
7451.56 requests per second
 
====== LRANGE_600 (first 600 elements) ======
  10000 requests completed in 1.71 seconds
  50 parallel clients
  3 bytes payload
  keep alive: 1
 
0.03% <= 1 milliseconds
0.12% <= 2 milliseconds
0.37% <= 3 milliseconds
28.68% <= 4 milliseconds
96.14% <= 5 milliseconds
98.78% <= 6 milliseconds
99.49% <= 7 milliseconds
99.71% <= 8 milliseconds
99.76% <= 9 milliseconds
99.85% <= 10 milliseconds
99.96% <= 11 milliseconds
100.00% <= 11 milliseconds
5841.12 requests per second
 
====== MSET (10 keys) ======
  10000 requests completed in 0.22 seconds
  50 parallel clients
  3 bytes payload
  keep alive: 1
 
67.64% <= 1 milliseconds
100.00% <= 1 milliseconds
44843.05 requests per second

Version 4.0.1 :

[root@]# redis-cli
127.0.0.1:6379> INFO
# Server
redis_version:4.0.1
redis_git_sha1:00000000
redis_git_dirty:0
redis_build_id:ca3621a3fee56a0d
redis_mode:standalone
os:Linux 3.3.4-5.fc17.x86_64 x86_64
arch_bits:64
multiplexing_api:epoll
atomicvar_api:atomic-builtin
gcc_version:4.7.2
process_id:11685
run_id:4ca00d89a0cc428adfc03d94f9f20912fe9bd1c6
tcp_port:6379
uptime_in_seconds:14
uptime_in_days:0
hz:10
lru_clock:11533316
executable:/root/redis-4.0.1/src/redis-server
config_file:/etc/redis/6379.conf
 
# Clients
connected_clients:15
client_longest_output_list:0
client_biggest_input_buf:0
blocked_clients:0
 
# Memory
used_memory:1172264
used_memory_human:1.12M
used_memory_rss:7815168
used_memory_rss_human:7.45M
used_memory_peak:1191048
used_memory_peak_human:1.14M
used_memory_peak_perc:98.42%
used_memory_overhead:1051642
used_memory_startup:765672
used_memory_dataset:120622
used_memory_dataset_perc:29.67%
total_system_memory:4142104576
total_system_memory_human:3.86G
used_memory_lua:37888
used_memory_lua_human:37.00K
maxmemory:0
maxmemory_human:0B
maxmemory_policy:noeviction
mem_fragmentation_ratio:6.67
mem_allocator:jemalloc-4.0.3
active_defrag_running:0
lazyfree_pending_objects:0
 
# Persistence
loading:0
rdb_changes_since_last_save:0
rdb_bgsave_in_progress:0
rdb_last_save_time:1504705526
rdb_last_bgsave_status:ok
rdb_last_bgsave_time_sec:-1
rdb_current_bgsave_time_sec:-1
rdb_last_cow_size:0
aof_enabled:0
aof_rewrite_in_progress:0
aof_rewrite_scheduled:0
aof_last_rewrite_time_sec:-1
aof_current_rewrite_time_sec:-1
aof_last_bgrewrite_status:ok
aof_last_write_status:ok
aof_last_cow_size:0
 
# Stats
total_connections_received:15
total_commands_processed:9
instantaneous_ops_per_sec:1
total_net_input_bytes:247
total_net_output_bytes:81
instantaneous_input_kbps:0.03
instantaneous_output_kbps:0.01
rejected_connections:0
sync_full:0
sync_partial_ok:0
sync_partial_err:0
expired_keys:0
evicted_keys:0
keyspace_hits:0
keyspace_misses:4
pubsub_channels:1
pubsub_patterns:0
latest_fork_usec:0
migrate_cached_sockets:0
slave_expires_tracked_keys:0
active_defrag_hits:0
active_defrag_misses:0
active_defrag_key_hits:0
active_defrag_key_misses:0
 
# Replication
role:master
connected_slaves:0
master_replid:13be9dae57dab6c444a85ac7739850be9e6f37d2
master_replid2:0000000000000000000000000000000000000000
master_repl_offset:0
second_repl_offset:-1
repl_backlog_active:0
repl_backlog_size:1048576
repl_backlog_first_byte_offset:0
repl_backlog_histlen:0
 
# CPU
used_cpu_sys:0.01
used_cpu_user:0.01
used_cpu_sys_children:0.00
used_cpu_user_children:0.00
 
# Cluster
cluster_enabled:0
 
# Keyspace
db0:keys=6,expires=0,avg_ttl=0
127.0.0.1:6379> QUIT
 
[root@]# redis-benchmark
====== PING_INLINE ======
  10000 requests completed in 0.22 seconds
  50 parallel clients
  3 bytes payload
  keep alive: 1
 
99.59% <= 1 milliseconds
100.00% <= 1 milliseconds
45871.56 requests per second
 
====== PING_BULK ======
  10000 requests completed in 0.22 seconds
  50 parallel clients
  3 bytes payload
  keep alive: 1
 
99.99% <= 1 milliseconds
100.00% <= 1 milliseconds
45248.87 requests per second
 
====== SET ======
  10000 requests completed in 0.22 seconds
  50 parallel clients
  3 bytes payload
  keep alive: 1
 
99.94% <= 1 milliseconds
100.00% <= 1 milliseconds
46082.95 requests per second
 
====== GET ======
  10000 requests completed in 0.22 seconds
  50 parallel clients
  3 bytes payload
  keep alive: 1
 
99.50% <= 2 milliseconds
99.51% <= 3 milliseconds
99.70% <= 4 milliseconds
99.97% <= 5 milliseconds
100.00% <= 5 milliseconds
44642.86 requests per second
 
====== INCR ======
  10000 requests completed in 0.22 seconds
  50 parallel clients
  3 bytes payload
  keep alive: 1
 
99.26% <= 1 milliseconds
100.00% <= 1 milliseconds
46511.63 requests per second
 
====== LPUSH ======
  10000 requests completed in 0.21 seconds
  50 parallel clients
  3 bytes payload
  keep alive: 1
 
99.90% <= 1 milliseconds
100.00% <= 1 milliseconds
47846.89 requests per second
 
====== LPOP ======
  10000 requests completed in 0.21 seconds
  50 parallel clients
  3 bytes payload
  keep alive: 1
 
99.57% <= 1 milliseconds
100.00% <= 1 milliseconds
47393.37 requests per second
 
====== SADD ======
  10000 requests completed in 0.21 seconds
  50 parallel clients
  3 bytes payload
  keep alive: 1
 
99.98% <= 1 milliseconds
100.00% <= 1 milliseconds
46728.97 requests per second
 
====== SPOP ======
  10000 requests completed in 0.22 seconds
  50 parallel clients
  3 bytes payload
  keep alive: 1
 
100.00% <= 0 milliseconds
45871.56 requests per second
 
====== LPUSH (needed to benchmark LRANGE) ======
  10000 requests completed in 0.21 seconds
  50 parallel clients
  3 bytes payload
  keep alive: 1
 
99.88% <= 1 milliseconds
100.00% <= 1 milliseconds
47619.05 requests per second
 
====== LRANGE_100 (first 100 elements) ======
  10000 requests completed in 0.41 seconds
  50 parallel clients
  3 bytes payload
  keep alive: 1
 
0.61% <= 1 milliseconds
99.89% <= 2 milliseconds
100.00% <= 2 milliseconds
24096.39 requests per second
 
====== LRANGE_300 (first 300 elements) ======
  10000 requests completed in 0.96 seconds
  50 parallel clients
  3 bytes payload
  keep alive: 1
 
0.05% <= 1 milliseconds
1.17% <= 2 milliseconds
97.45% <= 3 milliseconds
99.28% <= 4 milliseconds
99.82% <= 5 milliseconds
100.00% <= 5 milliseconds
10416.67 requests per second
 
====== LRANGE_500 (first 450 elements) ======
  10000 requests completed in 1.35 seconds
  50 parallel clients
  3 bytes payload
  keep alive: 1
 
0.04% <= 1 milliseconds
0.15% <= 2 milliseconds
6.92% <= 3 milliseconds
98.37% <= 4 milliseconds
99.38% <= 5 milliseconds
99.68% <= 6 milliseconds
99.78% <= 7 milliseconds
99.91% <= 8 milliseconds
100.00% <= 8 milliseconds
7429.42 requests per second
 
====== LRANGE_600 (first 600 elements) ======
  10000 requests completed in 1.72 seconds
  50 parallel clients
  3 bytes payload
  keep alive: 1
 
0.03% <= 1 milliseconds
0.11% <= 2 milliseconds
0.37% <= 3 milliseconds
25.16% <= 4 milliseconds
95.65% <= 5 milliseconds
98.34% <= 6 milliseconds
99.26% <= 7 milliseconds
99.58% <= 8 milliseconds
99.70% <= 9 milliseconds
99.81% <= 10 milliseconds
99.91% <= 11 milliseconds
99.99% <= 12 milliseconds
100.00% <= 12 milliseconds
5820.72 requests per second
 
====== MSET (10 keys) ======
  10000 requests completed in 0.22 seconds
  50 parallel clients
  3 bytes payload
  keep alive: 1
 
65.47% <= 1 milliseconds
100.00% <= 1 milliseconds
44444.45 requests per second

Redis : Configuration et performance sous Fédora & Redhat

Je fais un petit article pour mettre mes configurations de Redis (de l’anglais REmote DIctionary Server qui peut-être traduit par « serveur de dictionnaire distant ») sous Linux, afin de partager et aussi de corriger si nécessaire. Redis est développé en C AINSI comme tous les bons logiciels, il fait partie des NoSQL ( https://fr.wikipedia.org/wiki/NoSQL ). Les plus intéressant à connaitre sont : REDIS, MongoDB ( https://www.mongodb.com/fr ) , CouchDB ( http://couchdb.apache.org ) .

Le site officiel de Redis est : https://redis.io , la dernière version stable est la 4.0.1 (Jul 24 CEST 2017). La Release Note est disponible : https://raw.githubusercontent.com/antirez/redis/4.0/00-RELEASENOTES . La version que j’utilise est la 2.8.4 (13 Jan CEST 2014). La Release Note est disponible : https://raw.githubusercontent.com/antirez/redis/2.8/00-RELEASENOTES . Sur Twitter il faut suivre : @redisfeed .

Configuration et performance sous Redhat 7.2 (64b) :

Voici donc ma configuration de Redis sous Redhat 7.2 :

[root@]# cat /etc/redhat-release
Red Hat Enterprise Linux Server release 7.2 (Maipo)

Ensuite la configuration du service :

[root@]# cat /etc/systemd/system/multi-user.target.wants/redis.service

[Unit]
Description=A persistent key-value database
After=network.target
[Service]
Type=forking
User=root
Group=root
PIDFile=/var/run/redis_6379.pid
ExecStart=/usr/local/bin/redis-server /etc/redis/6379.conf
ExecStop=/usr/local/bin/redis-cli shutdown
LimitCORE=infinity
Restart=always
RestartSec=50
TimeoutStartSec=30

[Install]
WantedBy=multi-user.target

La configuration de Redis :

[root@]# cat /etc/redis/6379.conf

aof-rewrite-incremental-fsync yes
daemonize yes
pidfile /var/run/redis_6379.pid
port 6379
maxclients 6000
timeout 0
tcp-keepalive 0
loglevel notice
logfile /var/log/redis_6379.log
databases 16
save 900 1
save 300 10
save 60 10000
stop-writes-on-bgsave-error yes
rdbcompression yes
rdbchecksum yes
dbfilename dump.rdb
dir /var/lib/redis/6379
slave-serve-stale-data yes
slave-read-only yes
repl-disable-tcp-nodelay no
slave-priority 100
appendonly no
appendfilename "appendonly.aof"
appendfsync everysec
no-appendfsync-on-rewrite no
auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mb
lua-time-limit 5000
slowlog-log-slower-than 10000
slowlog-max-len 128
notify-keyspace-events ""
hash-max-ziplist-entries 512
hash-max-ziplist-value 64
list-max-ziplist-entries 512
list-max-ziplist-value 64
set-max-intset-entries 512
zset-max-ziplist-entries 128
zset-max-ziplist-value 64
activerehashing yes
client-output-buffer-limit normal 0 0 0
client-output-buffer-limit slave 256mb 64mb 60
client-output-buffer-limit pubsub 32mb 8mb 60
hz 10
aof-rewrite-incremental-fsync yes

La configuration de sysctl.conf ( l’OS ) :

[root@]# cat /etc/sysctl.conf

net.ipv4.ip_forward = 0
vm.overcommit_memory = 1
net.ipv4.tcp_timestamps = 1
net.ipv4.tcp_tw_reuse = 1
net.netfilter.nf_conntrack_max = 1048576
net.ipv4.tcp_max_tw_buckets = 2000000
net.ipv4.conf.default.rp_filter = 1
net.ipv4.conf.default.accept_source_route = 0
kernel.sysrq = 0
kernel.core_uses_pid = 1
fs.file-max = 100000
net.ipv4.ip_local_port_range = 1025 65535
net.ipv4.tcp_syncookies = 1
vm.swappiness = 10
net.core.rmem_max = 16777216
net.core.wmem_max = 16777216
net.core.rmem_default = 16777216
net.core.wmem_default = 16777216
net.core.optmem_max = 40960
net.ipv4.tcp_rmem = 4096 87380 16777216
net.ipv4.tcp_wmem = 4096 65536 16777216
net.ipv4.tcp_slow_start_after_idle = 0
net.ipv4.tcp_fin_timeout = 10
net.ipv4.tcp_max_syn_backlog = 999999999
net.core.netdev_max_backlog = 25000
net.core.rmem_max = 16777216
net.core.wmem_max = 16777216

Voici la version de Redis que j’utilise: 2.8.4

                _._
          _.-``__ ''-._
      _.-``    `.  `_.  ''-._           Redis 2.8.4 (00000000/0) 64 bit
  .-`` .-```.  ```\/    _.,_ ''-._
(    '      ,       .-`  | `,    )     Running in stand alone mode
|`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379
|    `-._   `._    /     _.-'    |     PID: 28796
  `-._    `-._  `-./  _.-'    _.-'
|`-._`-._    `-.__.-'    _.-'_.-'|
|    `-._`-._        _.-'_.-'    |           http://redis.io
  `-._    `-._`-.__.-'_.-'    _.-'
|`-._`-._    `-.__.-'    _.-'_.-'|
|    `-._`-._        _.-'_.-'    |
  `-._    `-._`-.__.-'_.-'    _.-'
      `-._    `-.__.-'    _.-'
          `-._        _.-'
              `-.__.-'


[28796] 06 Sep 09:26:49.382 # Server started, Redis version 2.8.4
[28796] 06 Sep 09:26:49.386 * DB loaded from disk: 0.005 seconds
[28796] 06 Sep 09:26:49.386 * The server is now ready to accept connections on port 6379

Les performances de Redis dépendent des processeurs, du nombre de processeur, de la RAM, de la vitesse d’écriture sur le disque dur, de l’OS, de la configuration de Redis, de la configuration de l’OS.

[root@]# cat /proc/cpuinfo | grep "model name"
model name      : Intel(R) Xeon(R) CPU E5-2620 v4 @ 2.10GHz
[root@]# cat /proc/meminfo | head -4
MemTotal:        3785880 kB
MemFree:         3541916 kB
Buffers:               0 kB
Cached:           101008 kB
[root@]# dd if=/dev/zero of=tempfile bs=1M count=1024
1024+0 records in
1024+0 records out
1073741824 bytes (1.1 GB) copied, 0.678386 s, 1.6 GB/s

L’outil de benchmark de redis indique donc :

[root@]# redis-benchmark
====== PING_INLINE ======
10000 requests completed in 0.12 seconds
50 parallel clients
3 bytes payload
keep alive: 1

99.51% <= 2 milliseconds
100.00% <= 2 milliseconds
86206.90 requests per second

====== PING_BULK ======
10000 requests completed in 0.09 seconds
50 parallel clients
3 bytes payload
keep alive: 1

99.51% <= 1 milliseconds
100.00% <= 1 milliseconds
106382.98 requests per second

====== SET ======
10000 requests completed in 0.10 seconds
50 parallel clients
3 bytes payload
keep alive: 1

99.51% <= 1 milliseconds
100.00% <= 1 milliseconds
103092.78 requests per second

====== GET ======
10000 requests completed in 0.09 seconds
50 parallel clients
3 bytes payload
keep alive: 1

99.51% <= 1 milliseconds
100.00% <= 1 milliseconds
106382.98 requests per second

====== INCR ======
10000 requests completed in 0.10 seconds
50 parallel clients
3 bytes payload
keep alive: 1

99.51% <= 1 milliseconds
100.00% <= 1 milliseconds
103092.78 requests per second

====== LPUSH ======
10000 requests completed in 0.09 seconds
50 parallel clients
3 bytes payload
keep alive: 1

99.51% <= 1 milliseconds
100.00% <= 1 milliseconds
106382.98 requests per second

====== LPOP ======
10000 requests completed in 0.10 seconds
50 parallel clients
3 bytes payload
keep alive: 1

99.51% <= 1 milliseconds
100.00% <= 1 milliseconds
99009.90 requests per second

====== SADD ======
10000 requests completed in 0.09 seconds
50 parallel clients
3 bytes payload
keep alive: 1

99.51% <= 1 milliseconds
100.00% <= 1 milliseconds
105263.16 requests per second

====== SPOP ======
10000 requests completed in 0.10 seconds
50 parallel clients
3 bytes payload
keep alive: 1

99.51% <= 1 milliseconds
100.00% <= 1 milliseconds
101010.10 requests per second

====== LPUSH (needed to benchmark LRANGE) ======
10000 requests completed in 0.09 seconds
50 parallel clients
3 bytes payload
keep alive: 1

99.51% <= 1 milliseconds
100.00% <= 1 milliseconds
107526.88 requests per second

====== LRANGE_100 (first 100 elements) ======
10000 requests completed in 0.22 seconds
50 parallel clients
3 bytes payload
keep alive: 1

96.40% <= 1 milliseconds
99.99% <= 2 milliseconds
100.00% <= 2 milliseconds
44444.45 requests per second

====== LRANGE_300 (first 300 elements) ======
10000 requests completed in 0.54 seconds
50 parallel clients
3 bytes payload
keep alive: 1

2.04% <= 1 milliseconds
66.86% <= 2 milliseconds
99.63% <= 3 milliseconds
100.00% <= 3 milliseconds
18518.52 requests per second

====== LRANGE_500 (first 450 elements) ======
10000 requests completed in 0.81 seconds
50 parallel clients
3 bytes payload
keep alive: 1

0.01% <= 1 milliseconds
27.58% <= 2 milliseconds
68.13% <= 3 milliseconds
96.15% <= 4 milliseconds
99.91% <= 5 milliseconds
100.00% <= 5 milliseconds
12406.95 requests per second

====== LRANGE_600 (first 600 elements) ======
10000 requests completed in 1.02 seconds
50 parallel clients
3 bytes payload
keep alive: 1

0.01% <= 1 milliseconds
12.17% <= 2 milliseconds
42.39% <= 3 milliseconds
73.16% <= 4 milliseconds
97.02% <= 5 milliseconds
99.87% <= 6 milliseconds
100.00% <= 6 milliseconds
9765.62 requests per second

====== MSET (10 keys) ======
10000 requests completed in 0.13 seconds
50 parallel clients
3 bytes payload
keep alive: 1

99.51% <= 1 milliseconds
100.00% <= 1 milliseconds
76923.08 requests per second

Configuration et performance sous Fédora 17 (64b) :

Voici donc les mêmes informations sur Fédora 17 :

[root@]# cat /etc/redhat-release
Fedora release 17 (Beefy Miracle)

Configuration du service ( à noter le Type qui est « simple », et le ExecStop qui est un simple « kill »:

[root@]# cat /usr/lib/systemd/system/redis_6379.service
[Unit]
Description=A persistent key-value database
After=network.target

[Service]
Type=simple
User=root
Group=root
Environment=TERM=linux
Environment=LANG= LANGUAGE= LC_CTYPE= LC_NUMERIC= LC_TIME= LC_COLLATE= LC_MONETARY= LC_MESSAGES= LC_PAPER= LC_NAME= LC_ADDRESS= LC_TELEPHONE= LC_MEASUREMENT= LC_IDENTIFICATION=
WorkingDirectory=/tmp/
RootDirectoryStartOnly=yes

PIDFile=/var/run/redis_6379.pid
ExecStart=/usr/local/bin/redis-server /etc/redis/6379.conf --loglevel verbose
ExecStop=/bin/kill -15 $MAINPID
LimitCORE=infinity
Restart=always
RestartSec=50

[Install]
WantedBy=multi-user.target

Configuration de Redis :

[root@]# cat /etc/redis/6379.conf | grep -v "^#"  | grep -v "^$"
daemonize yes
pidfile /var/run/redis_6379.pid
port 6379
timeout 0
tcp-keepalive 0
loglevel notice
logfile /var/log/redis_6379.log
databases 16
stop-writes-on-bgsave-error yes
rdbcompression yes
rdbchecksum yes
dbfilename dump.rdb
dir /var/lib/redis/6379
slave-serve-stale-data yes
slave-read-only yes
repl-disable-tcp-nodelay no
slave-priority 100
appendonly no
appendfilename "appendonly.aof"
appendfsync everysec
no-appendfsync-on-rewrite no
auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mb
lua-time-limit 5000
slowlog-log-slower-than 10000
slowlog-max-len 128
notify-keyspace-events ""
hash-max-ziplist-entries 512
hash-max-ziplist-value 64
list-max-ziplist-entries 512
list-max-ziplist-value 64
set-max-intset-entries 512
zset-max-ziplist-entries 128
zset-max-ziplist-value 64
activerehashing yes
client-output-buffer-limit normal 0 0 0
client-output-buffer-limit slave 256mb 64mb 60
client-output-buffer-limit pubsub 32mb 8mb 60
hz 10
aof-rewrite-incremental-fsync yes

Configuration de l’OS :

[root@]# cat /etc/sysctl.conf | grep -v "^#"  | grep -v "^$"
net.ipv4.ip_forward = 0
net.ipv4.conf.default.rp_filter = 1
net.ipv4.conf.default.accept_source_route = 0
kernel.sysrq = 0
kernel.core_uses_pid = 1
net.bridge.bridge-nf-call-ip6tables = 0
net.bridge.bridge-nf-call-iptables = 0
net.bridge.bridge-nf-call-arptables = 0
kernel.shmmax = 134217728
vm.swappiness = 10
vm.overcommit_memory = 1
vm.dirty_background_ratio = 5
vm.dirty_ratio = 50
net.ipv4.tcp_tw_reuse = 1
net.ipv4.ip_local_port_range = "20000 65535"
net.ipv4.tcp_keepalive_time = 300
net.ipv4.tcp_keepalive_probes = 5
net.ipv4.tcp_keepalive_intvl = 15
net.core.somaxconn = 65535
net.core.netdev_max_backlog = 4096
net.ipv4.tcp_max_syn_backlog = 1024
net.core.rmem_default = 16777216
net.core.wmem_default = 16777216
net.core.rmem_max = 8388608
net.core.wmem_max = 8388608
net.ipv4.tcp_timestamps = 1
net.ipv4.tcp_tw_recycle = 1
kernel.sched_migration_cost_ns = 5000000
kernel.sched_autogroup_enabled = 0

Mémoire :

[root@ ]# cat /proc/meminfo | head -4
MemTotal:        2051388 kB
MemFree:           64672 kB
Buffers:            5140 kB
Cached:          1483944 kB

Nombre de processeur et modèle :

[root@]# cat /proc/cpuinfo | grep "model name"
model name      : Intel(R) Xeon(R) CPU E5-2620 v4 @ 2.10GHz
model name      : Intel(R) Xeon(R) CPU E5-2620 v4 @ 2.10GHz
model name      : Intel(R) Xeon(R) CPU E5-2620 v4 @ 2.10GHz
model name      : Intel(R) Xeon(R) CPU E5-2620 v4 @ 2.10GHz

Performance du disque dur :

[root@]# dd if=/dev/zero of=tempfile bs=1M count=1024
1024+0 records in
1024+0 records out
1073741824 bytes (1.1 GB) copied, 1.24509 s, 862 MB/s

Les performances :

[root@]# redis-benchmark
====== PING_INLINE ======
  10000 requests completed in 0.07 seconds
  50 parallel clients
  3 bytes payload
  keep alive: 1

100.00% <= 0 milliseconds
135135.14 requests per second
====== PING_BULK ======
  10000 requests completed in 0.07 seconds
  50 parallel clients
  3 bytes payload
  keep alive: 1

100.00% <= 0 milliseconds
140845.06 requests per second
====== SET ======
  10000 requests completed in 0.07 seconds
  50 parallel clients
  3 bytes payload
  keep alive: 1

100.00% <= 0 milliseconds
142857.14 requests per second
====== GET ======
  10000 requests completed in 0.08 seconds
  50 parallel clients
  3 bytes payload
  keep alive: 1

99.73% <= 1 milliseconds
100.00% <= 1 milliseconds
131578.95 requests per second

====== INCR ======
  10000 requests completed in 0.09 seconds
  50 parallel clients
  3 bytes payload
  keep alive: 1

99.91% <= 1 milliseconds
100.00% <= 1 milliseconds
114942.53 requests per second
====== LPUSH ======
  10000 requests completed in 0.07 seconds
  50 parallel clients
  3 bytes payload
  keep alive: 1

99.98% <= 1 milliseconds
100.00% <= 1 milliseconds
147058.81 requests per second
====== LPOP ======
  10000 requests completed in 0.09 seconds
  50 parallel clients
  3 bytes payload
  keep alive: 1

99.99% <= 1 milliseconds
100.00% <= 1 milliseconds
117647.05 requests per second
====== SADD ======
  10000 requests completed in 0.07 seconds
  50 parallel clients
  3 bytes payload
  keep alive: 1

100.00% <= 0 milliseconds
142857.14 requests per second
====== SPOP ======
  10000 requests completed in 0.07 seconds
  50 parallel clients
  3 bytes payload
  keep alive: 1

100.00% <= 0 milliseconds
142857.14 requests per second
====== LPUSH (needed to benchmark LRANGE) ======
  10000 requests completed in 0.07 seconds
  50 parallel clients
  3 bytes payload
  keep alive: 1

100.00% <= 0 milliseconds
144927.55 requests per second
====== LRANGE_100 (first 100 elements) ======
  10000 requests completed in 0.17 seconds
  50 parallel clients
  3 bytes payload
  keep alive: 1

98.87% <= 1 milliseconds
100.00% <= 1 milliseconds
59523.81 requests per second
====== LRANGE_300 (first 300 elements) ======
  10000 requests completed in 0.47 seconds
  50 parallel clients
  3 bytes payload
  keep alive: 1

14.92% <= 1 milliseconds
99.27% <= 2 milliseconds
100.00% <= 2 milliseconds
21413.28 requests per second
====== LRANGE_500 (first 450 elements) ======
  10000 requests completed in 0.65 seconds
  50 parallel clients
  3 bytes payload
  keep alive: 1

0.15% <= 1 milliseconds
93.53% <= 2 milliseconds
99.51% <= 3 milliseconds
99.96% <= 4 milliseconds
100.00% <= 4 milliseconds
15337.42 requests per second
====== LRANGE_600 (first 600 elements) ======
  10000 requests completed in 0.95 seconds
  50 parallel clients
  3 bytes payload
  keep alive: 1

0.10% <= 1 milliseconds
35.34% <= 2 milliseconds
84.92% <= 3 milliseconds
92.32% <= 4 milliseconds
99.36% <= 5 milliseconds
99.97% <= 6 milliseconds
100.00% <= 6 milliseconds
10537.41 requests per second

====== MSET (10 keys) ======
  10000 requests completed in 0.10 seconds
  50 parallel clients
  3 bytes payload
  keep alive: 1

99.70% <= 1 milliseconds
99.92% <= 2 milliseconds
99.97% <= 3 milliseconds
100.00% <= 3 milliseconds
97087.38 requests per second