Redis教程

2021-12-21 [redis] 生成rdb对磁盘io的压力测试

本文主要是介绍2021-12-21 [redis] 生成rdb对磁盘io的压力测试,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

目录

摘要:

测试方式:

redis内存数据准备:

数据填充脚本:

测试脚本:

io测试脚本:

磁盘测试脚本:

一.  磁盘写入测试:

二. 单个redis生成快照测试磁盘io:

三. 两个redis进程分别同时生成rdb快照时的磁盘io

测试结果:

一. 磁盘基准写入数据:

二. 单个redis进程生成rdb快照:

三. 两个redis进程分别同时生成rdb快照时的磁盘io

结论:


摘要:

测试redis在生成rdb快照时,性能瓶颈

测试方式:

  1.  使用dd测试磁盘的写速度
  2. 测试单个redis生成rdb快照时的磁盘io
  3. 测试两个redis进程分别同时生成rdb快照时的磁盘io

redis内存数据准备:

  1.  向redis内填充2G的string类型数据
  2. 可使用py脚本使用pipeline加快数据填充速度

数据填充脚本:

# -*- coding:utf-8 -*-

import redis
import time
import random
from concurrent.futures import ProcessPoolExecutor
from rediscluster import RedisCluster

# cluster
startup_nodes = [
    {"host":"127.0.0.1", "port":7000}, 
    {"host":"127.0.0.1", "port":7001}, 
    {"host":"127.0.0.1", "port":7002}, 
    {"host":"127.0.0.1", "port":7003}
]

# r = RedisCluster(startup_nodes=startup_nodes, decode_responses=True)

# sin
r = redis.Redis(host='127.0.0.1', port=6379, password='')


def try_pipeline():
    start = time.time()
    with r.pipeline(transaction=False) as p:        
        for i in range(1, 1000000):
            for i in range (1, 10000):
                index1 = random.randint(0,1000000)
                index2 = random.randint(0,1000000)
                index3 = random.randint(0,1000000)
                key = "key_" + str(index1) + "_" + str(index2)
                value = "value_" + str(index3) + "_" + "9p3gbQjrUOjm5yFARiwrnqoBzswhfJZXcTOetMsSYyxjSluPoJeRR9T2vYKlZc6XxgenvtPHUPu6x1nI7ZdSISJEuDrrScOCG199p3gbQjrUOjm5yFARiwrnqoBzswhfJZXcTOetMsSYyxjSluPoJeRR9T2vYKlZc6XxgenvtPHUPu6x1nI7ZdSISJEuDrrScOCG199p3gbQjrUOjm5yFARiwrnqoBzswhfJZXcTOetMsSYyxjSluPoJeRR9T2vYKlZc6XxgenvtPHUPu6x1nI7ZdSISJEuDrrScOCG199p3gbQjrUOjm5yFARiwrnqoBzswhfJZXcTOetMsSYyxjSluPoJeRR9T2vYKlZc6XxgenvtPHUPu6x1nI7ZdSISJEuDrrScOCG19"

                p.set(key, value)    
            p.execute()
    
        print("ok")

try_pipeline()

测试脚本:

io测试脚本:

#!/bin/bash

echo iotop -b -o -n 10 -d 5 -t  > ./iotop.log
iotop -b -o -n 10 -d 5 -t  > ./iotop.log

磁盘测试脚本:

一.  磁盘写入测试:

#!/bin/bash

bash ./io.sh &

sync;/usr/bin/time -p bash -c "(dd if=/dev/zero of=test.dd  bs=1000K count=20000;sync)"

二. 单个redis生成快照测试磁盘io:

#!/bin/bash

# rm sin-redis/dump.rdb -f

bash ./io.sh &

time redis-cli -p 6379 save &

三. 两个redis进程分别同时生成rdb快照时的磁盘io

#!/bin/bash

# rm sin-redis/dump.rdb -f
# rm sin-redis2/dump.rdb -f

bash ./io_two.sh &

time redis-cli -p 6379 save &
time redis-cli -p 6389 save &

测试结果:

一. 磁盘基准写入数据:

^C3737+0 records in
3737+0 records out
3826688000 bytes (3.8 GB, 3.6 GiB) copied, 13.8006 s, 277 MB/s
real 14.13
user 0.01
sys 3.29

13:37:27 Total DISK READ :       0.00 B/s | Total DISK WRITE :       0.00 B/s
13:37:27 Actual DISK READ:       0.00 B/s | Actual DISK WRITE:       0.00 B/s
    TIME    TID  PRIO  USER     DISK READ  DISK WRITE  SWAPIN      IO    COMMAND
13:37:32 Total DISK READ :     703.53 K/s | Total DISK WRITE :     452.99 M/s
13:37:32 Actual DISK READ:     703.53 K/s | Actual DISK WRITE:     370.28 M/s
    TIME    TID  PRIO  USER     DISK READ  DISK WRITE  SWAPIN      IO    COMMAND
b'13:37:32 3635232 be/4 root        0.00 B/s  452.87 M/s  0.00 % 33.94 % dd if=/dev/zero of=test.dd bs=1000K count=20000'
b'13:37:32 3633611 be/4 root      814.95 B/s    0.00 B/s  0.00 % 15.73 % [kworker/u256:1+flush-8:0]'
b'13:37:32 3635167 be/7 root      702.74 K/s   96.30 K/s  0.00 %  6.52 % platform-python /usr/bin/dnf makecache --timer'
b'13:37:32 3635077 be/4 root        0.00 B/s    0.00 B/s  0.00 %  0.03 % [kworker/1:2-events_power_efficient]'
b'13:37:32    3081 be/3 root        0.00 B/s  814.95 B/s  0.00 %  0.00 % auditd'
b'13:37:32    3243 be/4 root        0.00 B/s  814.95 B/s  0.00 %  0.00 % rsyslogd -n [in:imjournal]'
b'13:37:32    3247 be/4 root        0.00 B/s    4.78 K/s  0.00 %  0.00 % rsyslogd -n [rs:main Q:Reg]'
b'13:37:32  340090 be/4 root        0.00 B/s   18.30 K/s  0.00 %  0.00 % java -Dzookeeper.log.dir=/usr/local/apache-zookeeper-3.7.0-bin/bin/../logs -Dzookeeper.log.file=zookeeper-root-server-localhost.localdomain.log -Dzookeeper.root.logger=INFO,CONSOLE -XX:+HeapDumpOnOutOfMemoryError -XX:OnOutOfMemoryError=kill -9 %p -cp /usr/local/apache-zookeeper-3.7.0-bin/bin/../zookeeper-server/target/classes:/usr/local/apache-zookeeper-3.7.0-bin/bin/../build/classes:/usr/local/apache-zookeeper-3.7.0-bin/bin/../zookeeper-server/target/lib/*.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../build/lib/*.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../lib/zookeeper-prometheus-metrics-3.7.0.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../lib/zookeeper-jute-3.7.0.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../lib/zookeeper-3.7.0.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../lib/snappy-java-1.1.7.7.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../lib/slf4j-log4j12-1.7.30.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../lib/slf4j-api-1.7.30.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../lib/simpleclient_servlet-0.9.0.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../lib/simpleclient_hotspot-0.9.0.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../lib/simpleclient_common-0.9.0.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../lib/simpleclient-0.9.0.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../lib/netty-transport-native-unix-common-4.1.59.Final.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../lib/netty-transport-native-epoll-4.1.59.Final.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../lib/netty-transport-4.1.59.Final.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../lib/netty-resolver-4.1.59.Final.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../lib/netty-handler-4.1.59.Final.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../lib/netty-common-4.1.59.Final.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../lib/netty-codec-4.1.59.Final.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../lib/netty-buffer-4.1.59.Final.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../lib/metrics-core-4.1.12.1.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../lib/log4j-1.2.17.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../lib/jline-2.14.6.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../lib/jetty-util-ajax-9.4.38.v20210224.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../lib/jetty-util-9.4.38.v20210224.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../lib/jetty-servlet-9.4.38.v20210224.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../lib/jetty-server-9.4.38.v20210224.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../lib/jetty-security-9.4.38.v20210224.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../lib/jetty-io-9.4.38.v20210224.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../lib/jetty-http-9.4.38.v20210224.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../lib/javax.servlet-api-3.1.0.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../lib/jackson-databind-2.10.5.1.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../lib/jackson-core-2.10.5.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../lib/jackson-annotations-2.10.5.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../lib/commons-cli-1.4.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../lib/audience-annotations-0.12.0.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../zookeeper-*.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../zookeeper-server/src/main/resources/lib/*.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../conf: -Xmx1000m -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.local.only=false org.apache.zookeeper.server.quorum.QuorumPeerMain /usr/local/apache-zookeeper-3.7.0-bin/bin/../conf/zoo.cfg [VM Periodic Tas]'
b'13:37:32 3604087 be/4 root        0.00 B/s  814.95 B/s  0.00 %  0.00 % node /root/.vscode-server/bin/899d46d82c4c95423fb7e10e68eba52050e30ba3/out/bootstrap-fork --type=extensionHost --uriTransformerPath=/root/.vscode-server/bin/899d46d82c4c95423fb7e10e68eba52050e30ba3/out/vs/server/uriTransformer.js'
b'13:37:32 3635227 be/4 root        0.00 B/s  814.95 B/s  0.00 %  0.00 % platform-python -s /usr/sbin/iotop -b -o -n 10 -d 5 -t'
13:37:37 Total DISK READ :      20.65 K/s | Total DISK WRITE :     179.01 M/s
13:37:37 Actual DISK READ:      20.65 K/s | Actual DISK WRITE:     161.78 M/s
    TIME    TID  PRIO  USER     DISK READ  DISK WRITE  SWAPIN      IO    COMMAND
b'13:37:37 3635232 be/4 root        0.00 B/s  178.29 M/s  0.00 % 82.61 % dd if=/dev/zero of=test.dd bs=1000K count=20000'
b'13:37:37 3633611 be/4 root        0.00 B/s    0.00 B/s  0.00 % 79.56 % [kworker/u256:1+flush-8:0]'
b'13:37:37 3635167 be/7 root       16.68 K/s  725.06 K/s  0.00 %  8.92 % platform-python /usr/bin/dnf makecache --timer'
b'13:37:37 3635077 be/4 root        0.00 B/s    0.00 B/s  0.00 %  0.06 % [kworker/1:2-events_power_efficient]'
b'13:37:37 3635227 be/4 root      813.22 B/s 1626.43 B/s  0.00 %  0.00 % platform-python -s /usr/sbin/iotop -b -o -n 10 -d 5 -t'
b'13:37:37  340090 be/4 root        0.00 B/s    9.53 K/s  0.00 %  0.00 % java -Dzookeeper.log.dir=/usr/local/apache-zookeeper-3.7.0-bin/bin/../logs -Dzookeeper.log.file=zookeeper-root-server-localhost.localdomain.log -Dzookeeper.root.logger=INFO,CONSOLE -XX:+HeapDumpOnOutOfMemoryError -XX:OnOutOfMemoryError=kill -9 %p -cp /usr/local/apache-zookeeper-3.7.0-bin/bin/../zookeeper-server/target/classes:/usr/local/apache-zookeeper-3.7.0-bin/bin/../build/classes:/usr/local/apache-zookeeper-3.7.0-bin/bin/../zookeeper-server/target/lib/*.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../build/lib/*.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../lib/zookeeper-prometheus-metrics-3.7.0.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../lib/zookeeper-jute-3.7.0.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../lib/zookeeper-3.7.0.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../lib/snappy-java-1.1.7.7.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../lib/slf4j-log4j12-1.7.30.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../lib/slf4j-api-1.7.30.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../lib/simpleclient_servlet-0.9.0.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../lib/simpleclient_hotspot-0.9.0.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../lib/simpleclient_common-0.9.0.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../lib/simpleclient-0.9.0.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../lib/netty-transport-native-unix-common-4.1.59.Final.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../lib/netty-transport-native-epoll-4.1.59.Final.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../lib/netty-transport-4.1.59.Final.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../lib/netty-resolver-4.1.59.Final.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../lib/netty-handler-4.1.59.Final.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../lib/netty-common-4.1.59.Final.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../lib/netty-codec-4.1.59.Final.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../lib/netty-buffer-4.1.59.Final.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../lib/metrics-core-4.1.12.1.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../lib/log4j-1.2.17.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../lib/jline-2.14.6.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../lib/jetty-util-ajax-9.4.38.v20210224.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../lib/jetty-util-9.4.38.v20210224.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../lib/jetty-servlet-9.4.38.v20210224.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../lib/jetty-server-9.4.38.v20210224.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../lib/jetty-security-9.4.38.v20210224.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../lib/jetty-io-9.4.38.v20210224.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../lib/jetty-http-9.4.38.v20210224.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../lib/javax.servlet-api-3.1.0.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../lib/jackson-databind-2.10.5.1.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../lib/jackson-core-2.10.5.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../lib/jackson-annotations-2.10.5.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../lib/commons-cli-1.4.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../lib/audience-annotations-0.12.0.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../zookeeper-*.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../zookeeper-server/src/main/resources/lib/*.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../conf: -Xmx1000m -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.local.only=false org.apache.zookeeper.server.quorum.QuorumPeerMain /usr/local/apache-zookeeper-3.7.0-bin/bin/../conf/zoo.cfg [VM Periodic Tas]'
b'13:37:37 2870558 be/4 root        3.18 K/s    0.00 B/s  0.00 %  0.00 % dirmngr --daemon --homedir /root/.gnupg'
13:37:42 Total DISK READ :       0.00 B/s | Total DISK WRITE :    1239.91 K/s
13:37:42 Actual DISK READ:      10.28 M/s | Actual DISK WRITE:     159.37 M/s
    TIME    TID  PRIO  USER     DISK READ  DISK WRITE  SWAPIN      IO    COMMAND
b'13:37:42 3633611 be/4 root        0.00 B/s    0.00 B/s  0.00 % 67.42 % [kworker/u256:1-flush-8:0]'
b'13:37:42 3635167 be/7 root        0.00 B/s 1227.23 K/s  0.00 %  6.29 % platform-python /usr/bin/dnf makecache --timer'
b'13:37:42 3633588 be/4 root        0.00 B/s    0.00 B/s  0.00 %  0.05 % [kworker/1:1-events_power_efficient]'
b'13:37:42    3081 be/3 root        0.00 B/s 1622.58 B/s  0.00 %  0.00 % auditd'
b'13:37:42    3247 be/4 root        0.00 B/s 1622.58 B/s  0.00 %  0.00 % rsyslogd -n [rs:main Q:Reg]'
b'13:37:42  340090 be/4 root        0.00 B/s    7.92 K/s  0.00 %  0.00 % java -Dzookeeper.log.dir=/usr/local/apache-zookeeper-3.7.0-bin/bin/../logs -Dzookeeper.log.file=zookeeper-root-server-localhost.localdomain.log -Dzookeeper.root.logger=INFO,CONSOLE -XX:+HeapDumpOnOutOfMemoryError -XX:OnOutOfMemoryError=kill -9 %p -cp /usr/local/apache-zookeeper-3.7.0-bin/bin/../zookeeper-server/target/classes:/usr/local/apache-zookeeper-3.7.0-bin/bin/../build/classes:/usr/local/apache-zookeeper-3.7.0-bin/bin/../zookeeper-server/target/lib/*.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../build/lib/*.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../lib/zookeeper-prometheus-metrics-3.7.0.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../lib/zookeeper-jute-3.7.0.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../lib/zookeeper-3.7.0.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../lib/snappy-java-1.1.7.7.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../lib/slf4j-log4j12-1.7.30.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../lib/slf4j-api-1.7.30.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../lib/simpleclient_servlet-0.9.0.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../lib/simpleclient_hotspot-0.9.0.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../lib/simpleclient_common-0.9.0.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../lib/simpleclient-0.9.0.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../lib/netty-transport-native-unix-common-4.1.59.Final.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../lib/netty-transport-native-epoll-4.1.59.Final.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../lib/netty-transport-4.1.59.Final.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../lib/netty-resolver-4.1.59.Final.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../lib/netty-handler-4.1.59.Final.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../lib/netty-common-4.1.59.Final.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../lib/netty-codec-4.1.59.Final.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../lib/netty-buffer-4.1.59.Final.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../lib/metrics-core-4.1.12.1.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../lib/log4j-1.2.17.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../lib/jline-2.14.6.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../lib/jetty-util-ajax-9.4.38.v20210224.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../lib/jetty-util-9.4.38.v20210224.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../lib/jetty-servlet-9.4.38.v20210224.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../lib/jetty-server-9.4.38.v20210224.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../lib/jetty-security-9.4.38.v20210224.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../lib/jetty-io-9.4.38.v20210224.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../lib/jetty-http-9.4.38.v20210224.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../lib/javax.servlet-api-3.1.0.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../lib/jackson-databind-2.10.5.1.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../lib/jackson-core-2.10.5.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../lib/jackson-annotations-2.10.5.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../lib/commons-cli-1.4.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../lib/audience-annotations-0.12.0.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../zookeeper-*.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../zookeeper-server/src/main/resources/lib/*.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../conf: -Xmx1000m -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.local.only=false org.apache.zookeeper.server.quorum.QuorumPeerMain /usr/local/apache-zookeeper-3.7.0-bin/bin/../conf/zoo.cfg [VM Periodic Tas]'
b'13:37:42 3635227 be/4 root        0.00 B/s 1622.58 B/s  0.00 %  0.00 % platform-python -s /usr/sbin/iotop -b -o -n 10 -d 5 -t'

二. 单个redis进程生成rdb快照:

real    0m16.749s
user    0m0.002s
sys     0m0.006s

13:00:01 Total DISK READ :       0.00 B/s | Total DISK WRITE :      47.68 M/s
13:00:01 Actual DISK READ:       0.00 B/s | Actual DISK WRITE:       0.00 B/s
    TIME    TID  PRIO  USER     DISK READ  DISK WRITE  SWAPIN      IO    COMMAND
b'13:00:01 3597773 be/4 root        0.00 B/s   47.68 M/s  0.00 %  0.00 % redis-server *:6379'
13:00:06 Total DISK READ :       0.00 B/s | Total DISK WRITE :      36.16 M/s
13:00:06 Actual DISK READ:       0.00 B/s | Actual DISK WRITE:      31.89 M/s
    TIME    TID  PRIO  USER     DISK READ  DISK WRITE  SWAPIN      IO    COMMAND
b'13:00:06 3597773 be/4 root        0.00 B/s   36.16 M/s  0.00 %  2.24 % redis-server *:6379'
b'13:00:06 3632068 be/4 root        0.00 B/s    0.00 B/s  0.00 %  0.02 % [kworker/1:1-events_power_efficient]'
b'13:00:06 3632301 be/4 root        0.00 B/s  815.80 B/s  0.00 %  0.00 % platform-python -s /usr/sbin/iotop -b -o -n 10 -d 5 -t'
13:00:11 Total DISK READ :       0.00 B/s | Total DISK WRITE :      37.67 M/s
13:00:11 Actual DISK READ:       0.00 B/s | Actual DISK WRITE:      38.04 M/s
    TIME    TID  PRIO  USER     DISK READ  DISK WRITE  SWAPIN      IO    COMMAND
b'13:00:11 3597773 be/4 root        0.00 B/s   37.67 M/s  0.00 %  2.24 % redis-server *:6379'
b'13:00:11 3632068 be/4 root        0.00 B/s    0.00 B/s  0.00 %  0.02 % [kworker/1:1-events_power_efficient]'
b'13:00:11    3243 be/4 root        0.00 B/s    0.00 B/s  0.00 %  0.00 % rsyslogd -n [in:imjournal]'
b'13:00:11    3247 be/4 root        0.00 B/s  811.37 B/s  0.00 %  0.00 % rsyslogd -n [rs:main Q:Reg]'
b'13:00:11 3632301 be/4 root        0.00 B/s  811.37 B/s  0.00 %  0.00 % platform-python -s /usr/sbin/iotop -b -o -n 10 -d 5 -t'
13:00:16 Total DISK READ :     210.03 K/s | Total DISK WRITE :      35.40 M/s
13:00:16 Actual DISK READ:     210.03 K/s | Actual DISK WRITE:      38.29 M/s
    TIME    TID  PRIO  USER     DISK READ  DISK WRITE  SWAPIN      IO    COMMAND
b'13:00:16 3592870 be/4 root       46.14 K/s    0.00 B/s  0.00 %  9.24 % node /root/.vscode-server/bin/899d46d82c4c95423fb7e10e68eba52050e30ba3/out/vs/server/main.js --start-server --host=127.0.0.1 --enable-remote-auto-shutdown --port=0 --connection-secret /root/.vscode-server/.899d46d82c4c95423fb7e10e68eba52050e30ba3.token'
b'13:00:16 3592871 be/4 root       42.96 K/s    0.00 B/s  0.00 %  9.14 % node /root/.vscode-server/bin/899d46d82c4c95423fb7e10e68eba52050e30ba3/out/vs/server/main.js --start-server --host=127.0.0.1 --enable-remote-auto-shutdown --port=0 --connection-secret /root/.vscode-server/.899d46d82c4c95423fb7e10e68eba52050e30ba3.token'
b'13:00:16 3592868 be/4 root       86.72 K/s    0.00 B/s  0.00 %  5.13 % node /root/.vscode-server/bin/899d46d82c4c95423fb7e10e68eba52050e30ba3/out/vs/server/main.js --start-server --host=127.0.0.1 --enable-remote-auto-shutdown --port=0 --connection-secret /root/.vscode-server/.899d46d82c4c95423fb7e10e68eba52050e30ba3.token'
b'13:00:16 3592869 be/4 root       34.21 K/s    0.00 B/s  0.00 %  4.57 % node /root/.vscode-server/bin/899d46d82c4c95423fb7e10e68eba52050e30ba3/out/vs/server/main.js --start-server --host=127.0.0.1 --enable-remote-auto-shutdown --port=0 --connection-secret /root/.vscode-server/.899d46d82c4c95423fb7e10e68eba52050e30ba3.token'
b'13:00:16 3597773 be/4 root        0.00 B/s   35.40 M/s  0.00 %  2.34 % redis-server *:6379'
b'13:00:16 3632068 be/4 root        0.00 B/s    0.00 B/s  0.00 %  0.01 % [kworker/1:1-events_power_efficient]'
13:00:21 Total DISK READ :     814.43 B/s | Total DISK WRITE :      10.45 M/s
13:00:21 Actual DISK READ:     756.37 K/s | Actual DISK WRITE:      12.43 M/s
    TIME    TID  PRIO  USER     DISK READ  DISK WRITE  SWAPIN      IO    COMMAND
b'13:00:21 3597773 be/4 root      814.43 B/s   10.45 M/s  0.00 %  0.67 % redis-server *:6379'
b'13:00:21    3082 be/3 root        0.00 B/s    0.00 B/s  0.00 %  0.06 % auditd'
b'13:00:21 3632068 be/4 root        0.00 B/s    0.00 B/s  0.00 %  0.01 % [kworker/1:1-ata_sff]'
b'13:00:21 3607290 be/4 root        0.00 B/s    0.00 B/s  0.00 %  0.00 % [kworker/1:0-mpt_poll_0]'
b'13:00:21    3243 be/4 root        0.00 B/s    0.00 B/s  0.00 %  0.00 % rsyslogd -n [in:imjournal]'
13:00:26 Total DISK READ :       0.00 B/s | Total DISK WRITE :       2.39 K/s
13:00:26 Actual DISK READ:       0.00 B/s | Actual DISK WRITE:       3.19 K/s
    TIME    TID  PRIO  USER     DISK READ  DISK WRITE  SWAPIN      IO    COMMAND
b'13:00:26 3607290 be/4 root        0.00 B/s    0.00 B/s  0.00 %  0.02 % [kworker/1:0-events_power_efficient]'
b'13:00:26  340090 be/4 root        0.00 B/s 1632.62 B/s  0.00 %  0.00 % java -Dzookeeper.log.dir=/usr/local/apache-zookeeper-3.7.0-bin/bin/../logs -Dzookeeper.log.file=zookeeper-root-server-localhost.localdomain.log -Dzookeeper.root.logger=INFO,CONSOLE -XX:+HeapDumpOnOutOfMemoryError -XX:OnOutOfMemoryError=kill -9 %p -cp /usr/local/apache-zookeeper-3.7.0-bin/bin/../zookeeper-server/target/classes:/usr/local/apache-zookeeper-3.7.0-bin/bin/../build/classes:/usr/local/apache-zookeeper-3.7.0-bin/bin/../zookeeper-server/target/lib/*.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../build/lib/*.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../lib/zookeeper-prometheus-metrics-3.7.0.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../lib/zookeeper-jute-3.7.0.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../lib/zookeeper-3.7.0.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../lib/snappy-java-1.1.7.7.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../lib/slf4j-log4j12-1.7.30.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../lib/slf4j-api-1.7.30.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../lib/simpleclient_servlet-0.9.0.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../lib/simpleclient_hotspot-0.9.0.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../lib/simpleclient_common-0.9.0.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../lib/simpleclient-0.9.0.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../lib/netty-transport-native-unix-common-4.1.59.Final.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../lib/netty-transport-native-epoll-4.1.59.Final.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../lib/netty-transport-4.1.59.Final.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../lib/netty-resolver-4.1.59.Final.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../lib/netty-handler-4.1.59.Final.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../lib/netty-common-4.1.59.Final.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../lib/netty-codec-4.1.59.Final.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../lib/netty-buffer-4.1.59.Final.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../lib/metrics-core-4.1.12.1.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../lib/log4j-1.2.17.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../lib/jline-2.14.6.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../lib/jetty-util-ajax-9.4.38.v20210224.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../lib/jetty-util-9.4.38.v20210224.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../lib/jetty-servlet-9.4.38.v20210224.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../lib/jetty-server-9.4.38.v20210224.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../lib/jetty-security-9.4.38.v20210224.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../lib/jetty-io-9.4.38.v20210224.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../lib/jetty-http-9.4.38.v20210224.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../lib/javax.servlet-api-3.1.0.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../lib/jackson-databind-2.10.5.1.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../lib/jackson-core-2.10.5.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../lib/jackson-annotations-2.10.5.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../lib/commons-cli-1.4.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../lib/audience-annotations-0.12.0.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../zookeeper-*.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../zookeeper-server/src/main/resources/lib/*.jar:/usr/local/apache-zookeeper-3.7.0-bin/bin/../conf: -Xmx1000m -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.local.only=false org.apache.zookeeper.server.quorum.QuorumPeerMain /usr/local/apache-zookeeper-3.7.0-bin/bin/../conf/zoo.cfg [VM Periodic Tas]'
b'13:00:26 3632301 be/4 root        0.00 B/s  816.31 B/s  0.00 %  0.00 % platform-python -s /usr/sbin/iotop -b -o -n 10 -d 5 -t'

三. 两个redis进程分别同时生成rdb快照时的磁盘io

real    0m15.922s
user    0m0.002s
sys     0m0.005s
OK

real    0m15.929s
user    0m0.002s
sys     0m0.009s

12:58:24 Total DISK READ :       0.00 B/s | Total DISK WRITE :      40.44 M/s
12:58:24 Actual DISK READ:       0.00 B/s | Actual DISK WRITE:       0.00 B/s
    TIME    TID  PRIO  USER     DISK READ  DISK WRITE  SWAPIN      IO    COMMAND
b'12:58:24 3597773 be/4 root        0.00 B/s    9.18 M/s  0.00 %  0.00 % redis-server *:6379'
b'12:58:24 3599437 be/4 root        0.00 B/s   31.26 M/s  0.00 %  0.00 % redis-server *:6389'
12:58:29 Total DISK READ :       0.00 B/s | Total DISK WRITE :      72.65 M/s
12:58:29 Actual DISK READ:       0.00 B/s | Actual DISK WRITE:      63.46 M/s
    TIME    TID  PRIO  USER     DISK READ  DISK WRITE  SWAPIN      IO    COMMAND
b'12:58:29 3597773 be/4 root        0.00 B/s   35.98 M/s  0.00 %  0.58 % redis-server *:6379'
b'12:58:29 3599437 be/4 root        0.00 B/s   36.67 M/s  0.00 %  0.42 % redis-server *:6389'
b'12:58:29 3607290 be/4 root        0.00 B/s    0.00 B/s  0.00 %  0.02 % [kworker/1:0-ata_sff]'
b'12:58:29    3081 be/3 root        0.00 B/s 1624.04 B/s  0.00 %  0.00 % auditd'
b'12:58:29    3243 be/4 root        0.00 B/s    0.00 B/s  0.00 %  0.00 % rsyslogd -n [in:imjournal]'
b'12:58:29    3247 be/4 root        0.00 B/s  812.02 B/s  0.00 %  0.00 % rsyslogd -n [rs:main Q:Reg]'
b'12:58:29 3604087 be/4 root        0.00 B/s  812.02 B/s  0.00 %  0.00 % node /root/.vscode-server/bin/899d46d82c4c95423fb7e10e68eba52050e30ba3/out/bootstrap-fork --type=extensionHost --uriTransformerPath=/root/.vscode-server/bin/899d46d82c4c95423fb7e10e68eba52050e30ba3/out/vs/server/uriTransformer.js'
b'12:58:29 3632048 be/4 root        0.00 B/s  812.02 B/s  0.00 %  0.00 % platform-python -s /usr/sbin/iotop -b -o -n 10 -d 5 -t'
12:58:34 Total DISK READ :       0.00 B/s | Total DISK WRITE :      75.05 M/s
12:58:34 Actual DISK READ:       0.00 B/s | Actual DISK WRITE:      74.72 M/s
    TIME    TID  PRIO  USER     DISK READ  DISK WRITE  SWAPIN      IO    COMMAND
b'12:58:34 3597773 be/4 root        0.00 B/s   37.22 M/s  0.00 %  0.56 % redis-server *:6379'
b'12:58:34 3599437 be/4 root        0.00 B/s   37.82 M/s  0.00 %  0.24 % redis-server *:6389'
b'12:58:34 3632068 be/4 root        0.00 B/s    0.00 B/s  0.00 %  0.04 % [kworker/1:1-events_power_efficient]'
12:58:39 Total DISK READ :       0.00 B/s | Total DISK WRITE :      82.87 M/s
12:58:39 Actual DISK READ:       0.00 B/s | Actual DISK WRITE:      88.83 M/s
    TIME    TID  PRIO  USER     DISK READ  DISK WRITE  SWAPIN      IO    COMMAND
b'12:58:39 3599437 be/4 root        0.00 B/s   41.86 M/s  0.00 %  0.88 % redis-server *:6389'
b'12:58:39 3597773 be/4 root        0.00 B/s   41.01 M/s  0.00 %  0.32 % redis-server *:6379'
b'12:58:39 3632068 be/4 root        0.00 B/s    0.00 B/s  0.00 %  0.03 % [kworker/1:1-events_power_efficient]'
b'12:58:39    3243 be/4 root        0.00 B/s    0.00 B/s  0.00 %  0.00 % rsyslogd -n [in:imjournal]'
b'12:58:39    3247 be/4 root        0.00 B/s  811.96 B/s  0.00 %  0.00 % rsyslogd -n [rs:main Q:Reg]'
12:58:44 Total DISK READ :     771.13 K/s | Total DISK WRITE :       9.41 M/s
12:58:44 Actual DISK READ:     771.13 K/s | Actual DISK WRITE:      13.48 M/s
    TIME    TID  PRIO  USER     DISK READ  DISK WRITE  SWAPIN      IO    COMMAND
b'12:58:44 3597773 be/4 root        3.98 K/s    5.17 M/s  0.00 %  0.68 % redis-server *:6379'
b'12:58:44 3599437 be/4 root        3.98 K/s    4.24 M/s  0.00 %  0.67 % redis-server *:6389'
b'12:58:44 3632068 be/4 root        0.00 B/s    0.00 B/s  0.00 %  0.04 % [kworker/1:1-xfs-buf/sda3]'
b'12:58:44 3604110 be/4 root      762.38 K/s    0.00 B/s  0.00 %  0.03 % node /root/.vscode-server/bin/899d46d82c4c95423fb7e10e68eba52050e30ba3/out/bootstrap-fork --type=watcherServiceParcel'
b'12:58:44 3607200 be/4 root      814.90 B/s    0.00 B/s  0.00 %  0.00 % [kworker/u256:2-flush-8:0]'
12:58:49 Total DISK READ :    1615.95 B/s | Total DISK WRITE :     807.98 B/s
12:58:49 Actual DISK READ:    1615.95 B/s | Actual DISK WRITE:       0.00 B/s
    TIME    TID  PRIO  USER     DISK READ  DISK WRITE  SWAPIN      IO    COMMAND
b'12:58:49 3607290 be/4 root        0.00 B/s    0.00 B/s  0.00 %  0.01 % [kworker/1:0-events_power_efficient]'
b'12:58:49 3598709 be/4 root     1615.95 B/s    0.00 B/s  0.00 %  0.00 % node /root/.vscode-server/bin/899d46d82c4c95423fb7e10e68eba52050e30ba3/out/bootstrap-fork --type=extensionHost --uriTransformerPath=/root/.vscode-server/bin/899d46d82c4c95423fb7e10e68eba52050e30ba3/out/vs/server/uriTransformer.js'
b'12:58:49 3632048 be/4 root        0.00 B/s  807.98 B/s  0.00 %  0.00 % platform-python -s /usr/sbin/iotop -b -o -n 10 -d 5 -t'

结论:

  1. 磁盘的写速度在 277 MB/s
  2. redis生成rdb快照的速度, 无论是单个redis, 还是两个redis进程同时进行. 都保持在 40MB/s左右
  3. redis生成快照的速度远小于磁盘io的上限
这篇关于2021-12-21 [redis] 生成rdb对磁盘io的压力测试的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!