性能测试(sysbench)

环境

推荐硬件环境

  1. CPU: 32 Cores
  2. RAM: 128 GB
  3. NIC: 10Gb Ethernet

至少需要5台机器:

  1. Jenkins * 1: ${host-jenkins}
  2. Sysbench * 1: ${host-sysbench}
  3. ShardingSphere-Proxy * 1: ${host-proxy}
  4. MySQL Server * 2: ${host-mysql-1}, ${host-mysql-2}

可以适当降低Jenkins和Sysbench机器的硬件标准

软件环境

  1. Jenins: 最新版本
  2. Sysbench: 1.0.20
  3. ShardingSphere-Proxy: master分支代码打包
  4. MySQL Server: 5.7.28

测试方案

根据以上的硬件环境,配置参数如下,参数应根据硬件环境改变而调整

ShardingSphere-Proxy配置

  1. Proxy运行在${host-proxy}机器
  2. 版本包括:Master分支版本、4.1.1版本、3.0.0版本
  3. 场景包括:config-shardingconfig-replica-queryconfig-sharding-replica-queryconfig-encrypt
  4. 配置文件详细内容:见附录1

MySQL Server配置

两个MySQL实例分别运行在${host-mysql-1}和${host-mysql-2}机器

  1. 需要提前在两个实例上创建sbtest数据库
  2. 设置参数max_prepared_stmt_count = 500000
  3. 设置参数max_connections = 2000

Jenkins配置

创建6个Jenkins任务,每个任务依次调用下一个任务:(运行在${host-jenkins}机器)

  1. 1. sysbench_install: 拉取最新代码,打包Proxy压缩包

以下任务通过Jenkins slave运行在单独的Sysbench发压机器:(运行在${host-sysbench}机器)

  1. 2. sysbench_sharding:
  2. a. 远程部署各版本Proxy的分片场景
  3. b. 执行Sysbench命令压测Proxy
  4. c. 执行Sysbench命令压测MySQL Server
  5. d. 保存Sysbench压测结果
  6. e. 使用画图脚本生成性能曲线和表格(画图脚本见附录2
  7. 3. sysbench_master_slave:
  8. a. 远程部署各版本Proxy的读写分离场景
  9. b. 执行Sysbench命令压测Proxy
  10. c. 执行Sysbench命令压测MySQL Server
  11. d. 保存Sysbench压测结果
  12. e. 使用画图脚本生成性能曲线和表格
  13. 4. sysbench_sharding_master_slave:
  14. a. 远程部署各版本Proxy的分片+读写分离场景
  15. b. 执行Sysbench命令压测Proxy
  16. c. 执行Sysbench命令压测MySQL Server
  17. d. 保存Sysbench压测结果
  18. e. 使用画图脚本生成性能曲线和表格
  19. 5. sysbench_encrypt:
  20. a. 远程部署各版本Proxy的加密场景
  21. b. 执行Sysbench命令压测Proxy
  22. c. 执行Sysbench命令压测MySQL Server
  23. d. 保存Sysbench压测结果
  24. e. 使用画图脚本生成性能曲线和表格
  25. 6. sysbench_result_aggregation:
  26. a. 重新对所有任务的压测结果执行画图脚本
  27. python3 plot_graph.py sharding
  28. python3 plot_graph.py ms
  29. python3 plot_graph.py sharding_ms
  30. python3 plot_graph.py encrypt
  31. b. 使用JenkinsPublish HTML reports插件将所有图片整合到一个HTML页面中

测试过程

以sysbench_sharding为例(其他场景类似)

进入sysbench压测结果目录

  1. cd /home/jenkins/sysbench_res/sharding

创建本次构建的文件夹

  1. mkdir $BUILD_NUMBER

取最后14次构建,保存到隐藏文件中

  1. ls -v | tail -n14 > .build_number.txt

部署及压测

步骤1 执行远程部署脚本,部署Proxy到${host-proxy}

./deploy_sharding.sh

  1. #!/bin/sh
  2. rm -fr apache-shardingsphere-*-shardingsphere-proxy-bin
  3. tar zxvf apache-shardingsphere-*-shardingsphere-proxy-bin.tar.gz
  4. sh stop_proxy.sh
  5. cp -f prepared_conf/mysql-connector-java-5.1.47.jar apache-shardingsphere-*-shardingsphere-proxy-bin/lib
  6. cp -f prepared_conf/start.sh apache-shardingsphere-*-shardingsphere-proxy-bin/bin
  7. cp -f prepared_conf/config-sharding.yaml prepared_conf/server.yaml apache-shardingsphere-*-shardingsphere-proxy-bin/conf
  8. ./apache-shardingsphere-*-shardingsphere-proxy-bin/bin/start.sh
  9. sleep 30

步骤2 执行sysbench脚本

  1. # master
  2. cd /home/jenkins/sysbench_res/sharding
  3. cd $BUILD_NUMBER
  4. sysbench oltp_read_only --mysql-host=${host-proxy} --mysql-port=3307 --mysql-user=root --mysql-password='root' --mysql-db=sbtest --tables=10 --table-size=1000000 --report-interval=10 --time=3600 --threads=10 --max-requests=0 --percentile=99 --mysql-ignore-errors="all" --rand-type=uniform --range_selects=off --auto_inc=off cleanup
  5. sysbench oltp_read_only --mysql-host=${host-proxy} --mysql-port=3307 --mysql-user=root --mysql-password='root' --mysql-db=sbtest --tables=10 --table-size=1000000 --report-interval=10 --time=3600 --threads=10 --max-requests=0 --percentile=99 --mysql-ignore-errors="all" --rand-type=uniform --range_selects=off --auto_inc=off prepare
  6. sysbench oltp_read_only --mysql-host=${host-proxy} --mysql-port=3307 --mysql-user=root --mysql-password='root' --mysql-db=sbtest --tables=10 --table-size=1000000 --report-interval=30 --time=180 --threads=256 --max-requests=0 --percentile=99 --mysql-ignore-errors="all" --range_selects=off --rand-type=uniform --auto_inc=off run
  7. sysbench oltp_read_only --mysql-host=${host-proxy} --mysql-port=3307 --mysql-user=root --mysql-password='root' --mysql-db=sbtest --tables=10 --table-size=1000000 --report-interval=30 --time=180 --threads=256 --max-requests=0 --percentile=99 --mysql-ignore-errors="all" --range_selects=off --rand-type=uniform --auto_inc=off run | tee oltp_read_only.master.txt
  8. sysbench oltp_point_select --mysql-host=${host-proxy} --mysql-port=3307 --mysql-user=root --mysql-password='root' --mysql-db=sbtest --tables=10 --table-size=1000000 --report-interval=30 --time=180 --threads=256 --max-requests=0 --percentile=99 --mysql-ignore-errors="all" --range_selects=off --rand-type=uniform --auto_inc=off run | tee oltp_point_select.master.txt
  9. sysbench oltp_read_write --mysql-host=${host-proxy} --mysql-port=3307 --mysql-user=root --mysql-password='root' --mysql-db=sbtest --tables=10 --table-size=1000000 --report-interval=30 --time=180 --threads=256 --max-requests=0 --percentile=99 --mysql-ignore-errors="all" --range_selects=off --rand-type=uniform --auto_inc=off run | tee oltp_read_write.master.txt
  10. sysbench oltp_write_only --mysql-host=${host-proxy} --mysql-port=3307 --mysql-user=root --mysql-password='root' --mysql-db=sbtest --tables=10 --table-size=1000000 --report-interval=30 --time=180 --threads=256 --max-requests=0 --percentile=99 --mysql-ignore-errors="all" --range_selects=off --rand-type=uniform --auto_inc=off run | tee oltp_write_only.master.txt
  11. sysbench oltp_update_index --mysql-host=${host-proxy} --mysql-port=3307 --mysql-user=root --mysql-password='root' --mysql-db=sbtest --tables=10 --table-size=1000000 --report-interval=30 --time=180 --threads=256 --max-requests=0 --percentile=99 --mysql-ignore-errors="all" --range_selects=off --rand-type=uniform --auto_inc=off run | tee oltp_update_index.master.txt
  12. sysbench oltp_update_non_index --mysql-host=${host-proxy} --mysql-port=3307 --mysql-user=root --mysql-password='root' --mysql-db=sbtest --tables=10 --table-size=1000000 --report-interval=30 --time=180 --threads=256 --max-requests=0 --percentile=99 --mysql-ignore-errors="all" --range_selects=off --rand-type=uniform --auto_inc=off run | tee oltp_update_non_index.master.txt
  13. sysbench oltp_delete --mysql-host=${host-proxy} --mysql-port=3307 --mysql-user=root --mysql-password='root' --mysql-db=sbtest --tables=10 --table-size=1000000 --report-interval=30 --time=180 --threads=256 --max-requests=0 --percentile=99 --mysql-ignore-errors="all" --range_selects=off --rand-type=uniform --auto_inc=off run | tee oltp_delete.master.txt
  14. sysbench oltp_read_only --mysql-host=${host-proxy} --mysql-port=3307 --mysql-user=root --mysql-password='root' --mysql-db=sbtest --tables=10 --table-size=1000000 --report-interval=10 --time=3600 --threads=10 --max-requests=0 --percentile=99 --mysql-ignore-errors="all" --rand-type=uniform --range_selects=off --auto_inc=off cleanup

4.1.1、3.0.0、直连MySQL这三个场景,重复上面步骤1和步骤2

执行停止Proxy脚本

./stop_proxy.sh

  1. #!/bin/sh
  2. ./3.0.0_sharding-proxy/bin/stop.sh
  3. ./4.1.1_apache-shardingsphere-4.1.1-sharding-proxy-bin/bin/stop.sh
  4. ./apache-shardingsphere-*-shardingsphere-proxy-bin/bin/stop.sh

生成压测曲线图片

  1. # Generate graph
  2. cd /home/jenkins/sysbench_res/
  3. python3 plot_graph.py sharding

利用Jenkins的 Publish HTML reports插件 将图片发布到页面里

  1. HTML directory to archive: /home/jenkins/sysbench_res/graph/
  2. Index page[s]: 01_sharding.html
  3. Report title: HTML Report

sysbench测试用例分析

oltp_point_select

  1. Prepare Statement (ID = 1): SELECT c FROM sbtest1 WHERE id=?
  2. Execute Statement: ID = 1

oltp_read_only

  1. Prepare Statement (ID = 1): 'COMMIT'
  2. Prepare Statement (ID = 2): SELECT c FROM sbtest1 WHERE id=?
  3. Statement: 'BEGIN'
  4. Execute Statement: ID = 2
  5. Execute Statement: ID = 2
  6. Execute Statement: ID = 2
  7. Execute Statement: ID = 2
  8. Execute Statement: ID = 2
  9. Execute Statement: ID = 2
  10. Execute Statement: ID = 2
  11. Execute Statement: ID = 2
  12. Execute Statement: ID = 2
  13. Execute Statement: ID = 2
  14. Execute Statement: ID = 1

oltp_write_only

  1. Prepare Statement (ID = 1): 'COMMIT'
  2. Prepare Statement (ID = 2): UPDATE sbtest1 SET k=k+1 WHERE id=?
  3. Prepare Statement (ID = 3): UPDATE sbtest6 SET c=? WHERE id=?
  4. Prepare Statement (ID = 4): DELETE FROM sbtest1 WHERE id=?
  5. Prepare Statement (ID = 5): INSERT INTO sbtest1 (id, k, c, pad) VALUES (?, ?, ?, ?)
  6. Statement: 'BEGIN'
  7. Execute Statement: ID = 2
  8. Execute Statement: ID = 3
  9. Execute Statement: ID = 4
  10. Execute Statement: ID = 5
  11. Execute Statement: ID = 1

oltp_read_write

  1. Prepare Statement (ID = 1): 'COMMIT'
  2. Prepare Statement (ID = 2): SELECT c FROM sbtest1 WHERE id=?
  3. Prepare Statement (ID = 3): UPDATE sbtest3 SET k=k+1 WHERE id=?
  4. Prepare Statement (ID = 4): UPDATE sbtest10 SET c=? WHERE id=?
  5. Prepare Statement (ID = 5): DELETE FROM sbtest8 WHERE id=?
  6. Prepare Statement (ID = 6): INSERT INTO sbtest8 (id, k, c, pad) VALUES (?, ?, ?, ?)
  7. Statement: 'BEGIN'
  8. Execute Statement: ID = 2
  9. Execute Statement: ID = 2
  10. Execute Statement: ID = 2
  11. Execute Statement: ID = 2
  12. Execute Statement: ID = 2
  13. Execute Statement: ID = 2
  14. Execute Statement: ID = 2
  15. Execute Statement: ID = 2
  16. Execute Statement: ID = 2
  17. Execute Statement: ID = 2
  18. Execute Statement: ID = 3
  19. Execute Statement: ID = 4
  20. Execute Statement: ID = 5
  21. Execute Statement: ID = 6
  22. Execute Statement: ID = 1

oltp_update_index

  1. Prepare Statement (ID = 1): UPDATE sbtest1 SET k=k+1 WHERE id=?
  2. Execute Statement: ID = 1

oltp_update_non_index

  1. Prepare Statement (ID = 1): UPDATE sbtest1 SET c=? WHERE id=?
  2. Execute Statement: ID = 1

oltp_delete

  1. Prepare Statement (ID = 1): DELETE FROM sbtest1 WHERE id=?
  2. Execute Statement: ID = 1

附录1

Master branch version

server.yaml

  1. users:
  2. - root@%:root
  3. - sharding@:sharding
  4. props:
  5. max-connections-size-per-query: 10
  6. executor-size: 128 # Infinite by default.
  7. proxy-frontend-flush-threshold: 128 # The default value is 128.
  8. # LOCAL: Proxy will run with LOCAL transaction.
  9. # XA: Proxy will run with XA transaction.
  10. # BASE: Proxy will run with B.A.S.E transaction.
  11. proxy-transaction-type: LOCAL
  12. proxy-opentracing-enabled: false
  13. proxy-hint-enabled: false
  14. sql-show: false
  15. check-table-metadata-enabled: false
  16. lock-wait-timeout-milliseconds: 50000 # The maximum time to wait for a lock

config-sharding.yaml

  1. schemaName: sbtest
  2. dataSources:
  3. ds_0:
  4. url: jdbc:mysql://${host-mysql-1}:3306/sbtest?serverTimezone=UTC&useSSL=false
  5. username: root
  6. password:
  7. connectionTimeoutMilliseconds: 30000
  8. idleTimeoutMilliseconds: 60000
  9. maxLifetimeMilliseconds: 1800000
  10. maxPoolSize: 256
  11. minPoolSize: 256
  12. maintenanceIntervalMilliseconds: 30000
  13. ds_1:
  14. url: jdbc:mysql://${host-mysql-2}:3306/sbtest?serverTimezone=UTC&useSSL=false
  15. username: root
  16. password:
  17. connectionTimeoutMilliseconds: 30000
  18. idleTimeoutMilliseconds: 60000
  19. maxLifetimeMilliseconds: 1800000
  20. maxPoolSize: 256
  21. minPoolSize: 256
  22. maintenanceIntervalMilliseconds: 30000
  23. rules:
  24. - !SHARDING
  25. tables:
  26. sbtest1:
  27. actualDataNodes: ds_${0..1}.sbtest1_${0..99}
  28. tableStrategy:
  29. standard:
  30. shardingColumn: id
  31. shardingAlgorithmName: table_inline_1
  32. keyGenerateStrategy:
  33. column: id
  34. keyGeneratorName: snowflake
  35. sbtest2:
  36. actualDataNodes: ds_${0..1}.sbtest2_${0..99}
  37. tableStrategy:
  38. standard:
  39. shardingColumn: id
  40. shardingAlgorithmName: table_inline_2
  41. keyGenerateStrategy:
  42. column: id
  43. keyGeneratorName: snowflake
  44. sbtest3:
  45. actualDataNodes: ds_${0..1}.sbtest3_${0..99}
  46. tableStrategy:
  47. standard:
  48. shardingColumn: id
  49. shardingAlgorithmName: table_inline_3
  50. keyGenerateStrategy:
  51. column: id
  52. keyGeneratorName: snowflake
  53. sbtest4:
  54. actualDataNodes: ds_${0..1}.sbtest4_${0..99}
  55. tableStrategy:
  56. standard:
  57. shardingColumn: id
  58. shardingAlgorithmName: table_inline_4
  59. keyGenerateStrategy:
  60. column: id
  61. keyGeneratorName: snowflake
  62. sbtest5:
  63. actualDataNodes: ds_${0..1}.sbtest5_${0..99}
  64. tableStrategy:
  65. standard:
  66. shardingColumn: id
  67. shardingAlgorithmName: table_inline_5
  68. keyGenerateStrategy:
  69. column: id
  70. keyGeneratorName: snowflake
  71. sbtest6:
  72. actualDataNodes: ds_${0..1}.sbtest6_${0..99}
  73. tableStrategy:
  74. standard:
  75. shardingColumn: id
  76. shardingAlgorithmName: table_inline_6
  77. keyGenerateStrategy:
  78. column: id
  79. keyGeneratorName: snowflake
  80. sbtest7:
  81. actualDataNodes: ds_${0..1}.sbtest7_${0..99}
  82. tableStrategy:
  83. standard:
  84. shardingColumn: id
  85. shardingAlgorithmName: table_inline_7
  86. keyGenerateStrategy:
  87. column: id
  88. keyGeneratorName: snowflake
  89. sbtest8:
  90. actualDataNodes: ds_${0..1}.sbtest8_${0..99}
  91. tableStrategy:
  92. standard:
  93. shardingColumn: id
  94. shardingAlgorithmName: table_inline_8
  95. keyGenerateStrategy:
  96. column: id
  97. keyGeneratorName: snowflake
  98. sbtest9:
  99. actualDataNodes: ds_${0..1}.sbtest9_${0..99}
  100. tableStrategy:
  101. standard:
  102. shardingColumn: id
  103. shardingAlgorithmName: table_inline_9
  104. keyGenerateStrategy:
  105. column: id
  106. keyGeneratorName: snowflake
  107. sbtest10:
  108. actualDataNodes: ds_${0..1}.sbtest10_${0..99}
  109. tableStrategy:
  110. standard:
  111. shardingColumn: id
  112. shardingAlgorithmName: table_inline_10
  113. keyGenerateStrategy:
  114. column: id
  115. keyGeneratorName: snowflake
  116. defaultDatabaseStrategy:
  117. standard:
  118. shardingColumn: id
  119. shardingAlgorithmName: database_inline
  120. shardingAlgorithms:
  121. database_inline:
  122. type: INLINE
  123. props:
  124. algorithm-expression: ds_${id % 2}
  125. table_inline_1:
  126. type: INLINE
  127. props:
  128. algorithm-expression: sbtest1_${id % 100}
  129. table_inline_2:
  130. type: INLINE
  131. props:
  132. algorithm-expression: sbtest2_${id % 100}
  133. table_inline_3:
  134. type: INLINE
  135. props:
  136. algorithm-expression: sbtest3_${id % 100}
  137. table_inline_4:
  138. type: INLINE
  139. props:
  140. algorithm-expression: sbtest4_${id % 100}
  141. table_inline_5:
  142. type: INLINE
  143. props:
  144. algorithm-expression: sbtest5_${id % 100}
  145. table_inline_6:
  146. type: INLINE
  147. props:
  148. algorithm-expression: sbtest6_${id % 100}
  149. table_inline_7:
  150. type: INLINE
  151. props:
  152. algorithm-expression: sbtest7_${id % 100}
  153. table_inline_8:
  154. type: INLINE
  155. props:
  156. algorithm-expression: sbtest8_${id % 100}
  157. table_inline_9:
  158. type: INLINE
  159. props:
  160. algorithm-expression: sbtest9_${id % 100}
  161. table_inline_10:
  162. type: INLINE
  163. props:
  164. algorithm-expression: sbtest10_${id % 100}
  165. keyGenerators:
  166. snowflake:
  167. type: SNOWFLAKE
  168. props:
  169. worker-id: 123

config-replica-query.yaml

  1. schemaName: sbtest
  2. dataSources:
  3. ds_0:
  4. url: jdbc:mysql://${host-mysql-1}:3306/sbtest?serverTimezone=UTC&useSSL=false
  5. username: root
  6. password:
  7. connectionTimeoutMilliseconds: 30000
  8. idleTimeoutMilliseconds: 60000
  9. maxLifetimeMilliseconds: 1800000
  10. maxPoolSize: 128
  11. minPoolSize: 128
  12. maintenanceIntervalMilliseconds: 30000
  13. rules:
  14. - !READWRITE_SPLITTING
  15. dataSources:
  16. pr_ds:
  17. primaryDataSourceName: ds_0
  18. replicaDataSourceNames:
  19. - ds_0
  20. - ds_0

config-sharding-replica-query.yaml

  1. schemaName: sbtest
  2. dataSources:
  3. primary_ds_0:
  4. url: jdbc:mysql://${host-mysql-1}:3306/sbtest?serverTimezone=UTC&useSSL=false
  5. username: root
  6. password:
  7. connectionTimeoutMilliseconds: 30000
  8. idleTimeoutMilliseconds: 60000
  9. maxLifetimeMilliseconds: 1800000
  10. maxPoolSize: 256
  11. minPoolSize: 256
  12. maintenanceIntervalMilliseconds: 30000
  13. primary_ds_1:
  14. url: jdbc:mysql://${host-mysql-2}:3306/sbtest?serverTimezone=UTC&useSSL=false
  15. username: root
  16. password:
  17. connectionTimeoutMilliseconds: 30000
  18. idleTimeoutMilliseconds: 60000
  19. maxLifetimeMilliseconds: 1800000
  20. maxPoolSize: 256
  21. minPoolSize: 256
  22. maintenanceIntervalMilliseconds: 30000
  23. rules:
  24. - !SHARDING
  25. tables:
  26. sbtest1:
  27. actualDataNodes: ds_${0..1}.sbtest1_${0..99}
  28. tableStrategy:
  29. standard:
  30. shardingColumn: id
  31. shardingAlgorithmName: table_inline_1
  32. keyGenerateStrategy:
  33. column: id
  34. keyGeneratorName: snowflake
  35. sbtest2:
  36. actualDataNodes: ds_${0..1}.sbtest2_${0..99}
  37. tableStrategy:
  38. standard:
  39. shardingColumn: id
  40. shardingAlgorithmName: table_inline_2
  41. keyGenerateStrategy:
  42. column: id
  43. keyGeneratorName: snowflake
  44. sbtest3:
  45. actualDataNodes: ds_${0..1}.sbtest3_${0..99}
  46. tableStrategy:
  47. standard:
  48. shardingColumn: id
  49. shardingAlgorithmName: table_inline_3
  50. keyGenerateStrategy:
  51. column: id
  52. keyGeneratorName: snowflake
  53. sbtest4:
  54. actualDataNodes: ds_${0..1}.sbtest4_${0..99}
  55. tableStrategy:
  56. standard:
  57. shardingColumn: id
  58. shardingAlgorithmName: table_inline_4
  59. keyGenerateStrategy:
  60. column: id
  61. keyGeneratorName: snowflake
  62. sbtest5:
  63. actualDataNodes: ds_${0..1}.sbtest5_${0..99}
  64. tableStrategy:
  65. standard:
  66. shardingColumn: id
  67. shardingAlgorithmName: table_inline_5
  68. keyGenerateStrategy:
  69. column: id
  70. keyGeneratorName: snowflake
  71. sbtest6:
  72. actualDataNodes: ds_${0..1}.sbtest6_${0..99}
  73. tableStrategy:
  74. standard:
  75. shardingColumn: id
  76. shardingAlgorithmName: table_inline_6
  77. keyGenerateStrategy:
  78. column: id
  79. keyGeneratorName: snowflake
  80. sbtest7:
  81. actualDataNodes: ds_${0..1}.sbtest7_${0..99}
  82. tableStrategy:
  83. standard:
  84. shardingColumn: id
  85. shardingAlgorithmName: table_inline_7
  86. keyGenerateStrategy:
  87. column: id
  88. keyGeneratorName: snowflake
  89. sbtest8:
  90. actualDataNodes: ds_${0..1}.sbtest8_${0..99}
  91. tableStrategy:
  92. standard:
  93. shardingColumn: id
  94. shardingAlgorithmName: table_inline_8
  95. keyGenerateStrategy:
  96. column: id
  97. keyGeneratorName: snowflake
  98. sbtest9:
  99. actualDataNodes: ds_${0..1}.sbtest9_${0..99}
  100. tableStrategy:
  101. standard:
  102. shardingColumn: id
  103. shardingAlgorithmName: table_inline_9
  104. keyGenerateStrategy:
  105. column: id
  106. keyGeneratorName: snowflake
  107. sbtest10:
  108. actualDataNodes: ds_${0..1}.sbtest10_${0..99}
  109. tableStrategy:
  110. standard:
  111. shardingColumn: id
  112. shardingAlgorithmName: table_inline_10
  113. keyGenerateStrategy:
  114. column: id
  115. keyGeneratorName: snowflake
  116. defaultDatabaseStrategy:
  117. standard:
  118. shardingColumn: id
  119. shardingAlgorithmName: database_inline
  120. shardingAlgorithms:
  121. database_inline:
  122. type: INLINE
  123. props:
  124. algorithm-expression: ds_${id % 2}
  125. table_inline_1:
  126. type: INLINE
  127. props:
  128. algorithm-expression: sbtest1_${id % 100}
  129. table_inline_2:
  130. type: INLINE
  131. props:
  132. algorithm-expression: sbtest2_${id % 100}
  133. table_inline_3:
  134. type: INLINE
  135. props:
  136. algorithm-expression: sbtest3_${id % 100}
  137. table_inline_4:
  138. type: INLINE
  139. props:
  140. algorithm-expression: sbtest4_${id % 100}
  141. table_inline_5:
  142. type: INLINE
  143. props:
  144. algorithm-expression: sbtest5_${id % 100}
  145. table_inline_6:
  146. type: INLINE
  147. props:
  148. algorithm-expression: sbtest6_${id % 100}
  149. table_inline_7:
  150. type: INLINE
  151. props:
  152. algorithm-expression: sbtest7_${id % 100}
  153. table_inline_8:
  154. type: INLINE
  155. props:
  156. algorithm-expression: sbtest8_${id % 100}
  157. table_inline_9:
  158. type: INLINE
  159. props:
  160. algorithm-expression: sbtest9_${id % 100}
  161. table_inline_10:
  162. type: INLINE
  163. props:
  164. algorithm-expression: sbtest10_${id % 100}
  165. keyGenerators:
  166. snowflake:
  167. type: SNOWFLAKE
  168. props:
  169. worker-id: 123
  170. - !READWRITE_SPLITTING
  171. dataSources:
  172. ds_0:
  173. primaryDataSourceName: primary_ds_0
  174. replicaDataSourceNames:
  175. - primary_ds_0
  176. - primary_ds_0
  177. ds_1:
  178. name: ds_1
  179. primaryDataSourceName: primary_ds_1
  180. replicaDataSourceNames:
  181. - primary_ds_1
  182. - primary_ds_1

config-encrypt.yaml

  1. schemaName: sbtest
  2. dataSources:
  3. ds_0:
  4. url: jdbc:mysql://${host-mysql-1}:3306/sbtest?serverTimezone=UTC&useSSL=false
  5. username: root
  6. password:
  7. connectionTimeoutMilliseconds: 30000
  8. idleTimeoutMilliseconds: 60000
  9. maxLifetimeMilliseconds: 1800000
  10. maxPoolSize: 256
  11. minPoolSize: 256
  12. maintenanceIntervalMilliseconds: 30000
  13. rules:
  14. - !ENCRYPT
  15. encryptors:
  16. md5_encryptor:
  17. type: MD5
  18. tables:
  19. sbtest1:
  20. columns:
  21. pad:
  22. cipherColumn: pad
  23. encryptorName: md5_encryptor
  24. sbtest2:
  25. columns:
  26. pad:
  27. cipherColumn: pad
  28. encryptorName: md5_encryptor
  29. sbtest3:
  30. columns:
  31. pad:
  32. cipherColumn: pad
  33. encryptorName: md5_encryptor
  34. sbtest4:
  35. columns:
  36. pad:
  37. cipherColumn: pad
  38. encryptorName: md5_encryptor
  39. sbtest5:
  40. columns:
  41. pad:
  42. cipherColumn: pad
  43. encryptorName: md5_encryptor
  44. sbtest6:
  45. columns:
  46. pad:
  47. cipherColumn: pad
  48. encryptorName: md5_encryptor
  49. sbtest7:
  50. columns:
  51. pad:
  52. cipherColumn: pad
  53. encryptorName: md5_encryptor
  54. sbtest8:
  55. columns:
  56. pad:
  57. cipherColumn: pad
  58. encryptorName: md5_encryptor
  59. sbtest9:
  60. columns:
  61. pad:
  62. cipherColumn: pad
  63. encryptorName: md5_encryptor
  64. sbtest10:
  65. columns:
  66. pad:
  67. cipherColumn: pad
  68. encryptorName: md5_encryptor

4.1.1 version

server.yaml

  1. authentication:
  2. users:
  3. root:
  4. password: root
  5. sharding:
  6. password: sharding
  7. authorizedSchemas: sharding_db
  8. props:
  9. max.connections.size.per.query: 10
  10. acceptor.size: 256 # The default value is available processors count * 2.
  11. executor.size: 128 # Infinite by default.
  12. proxy.frontend.flush.threshold: 128 # The default value is 128.
  13. # LOCAL: Proxy will run with LOCAL transaction.
  14. # XA: Proxy will run with XA transaction.
  15. # BASE: Proxy will run with B.A.S.E transaction.
  16. proxy.transaction.type: LOCAL
  17. proxy.opentracing.enabled: false
  18. proxy.hint.enabled: false
  19. query.with.cipher.column: true
  20. sql.show: false
  21. allow.range.query.with.inline.sharding: false

config-sharding.yaml

  1. schemaName: sbtest
  2. dataSources:
  3. ds_0:
  4. url: jdbc:mysql://${host-mysql-1}:3306/sbtest?serverTimezone=UTC&useSSL=false
  5. username: root
  6. password:
  7. connectionTimeoutMilliseconds: 30000
  8. idleTimeoutMilliseconds: 60000
  9. maxLifetimeMilliseconds: 1800000
  10. maxPoolSize: 256
  11. ds_1:
  12. url: jdbc:mysql://${host-mysql-2}:3306/sbtest?serverTimezone=UTC&useSSL=false
  13. username: root
  14. password:
  15. connectionTimeoutMilliseconds: 30000
  16. idleTimeoutMilliseconds: 60000
  17. maxLifetimeMilliseconds: 1800000
  18. maxPoolSize: 256
  19. shardingRule:
  20. tables:
  21. sbtest1:
  22. actualDataNodes: ds_${0..1}.sbtest1_${0..99}
  23. tableStrategy:
  24. inline:
  25. shardingColumn: id
  26. algorithmExpression: sbtest1_${id % 100}
  27. keyGenerator:
  28. type: SNOWFLAKE
  29. column: id
  30. sbtest2:
  31. actualDataNodes: ds_${0..1}.sbtest2_${0..99}
  32. tableStrategy:
  33. inline:
  34. shardingColumn: id
  35. algorithmExpression: sbtest2_${id % 100}
  36. keyGenerator:
  37. type: SNOWFLAKE
  38. column: id
  39. sbtest3:
  40. actualDataNodes: ds_${0..1}.sbtest3_${0..99}
  41. tableStrategy:
  42. inline:
  43. shardingColumn: id
  44. algorithmExpression: sbtest3_${id % 100}
  45. keyGenerator:
  46. type: SNOWFLAKE
  47. column: id
  48. sbtest4:
  49. actualDataNodes: ds_${0..1}.sbtest4_${0..99}
  50. tableStrategy:
  51. inline:
  52. shardingColumn: id
  53. algorithmExpression: sbtest4_${id % 100}
  54. keyGenerator:
  55. type: SNOWFLAKE
  56. column: id
  57. sbtest5:
  58. actualDataNodes: ds_${0..1}.sbtest5_${0..99}
  59. tableStrategy:
  60. inline:
  61. shardingColumn: id
  62. algorithmExpression: sbtest5_${id % 100}
  63. keyGenerator:
  64. type: SNOWFLAKE
  65. column: id
  66. sbtest6:
  67. actualDataNodes: ds_${0..1}.sbtest6_${0..99}
  68. tableStrategy:
  69. inline:
  70. shardingColumn: id
  71. algorithmExpression: sbtest6_${id % 100}
  72. keyGenerator:
  73. type: SNOWFLAKE
  74. column: id
  75. sbtest7:
  76. actualDataNodes: ds_${0..1}.sbtest7_${0..99}
  77. tableStrategy:
  78. inline:
  79. shardingColumn: id
  80. algorithmExpression: sbtest7_${id % 100}
  81. keyGenerator:
  82. type: SNOWFLAKE
  83. column: id
  84. sbtest8:
  85. actualDataNodes: ds_${0..1}.sbtest8_${0..99}
  86. tableStrategy:
  87. inline:
  88. shardingColumn: id
  89. algorithmExpression: sbtest8_${id % 100}
  90. keyGenerator:
  91. type: SNOWFLAKE
  92. column: id
  93. sbtest9:
  94. actualDataNodes: ds_${0..1}.sbtest9_${0..99}
  95. tableStrategy:
  96. inline:
  97. shardingColumn: id
  98. algorithmExpression: sbtest9_${id % 100}
  99. keyGenerator:
  100. type: SNOWFLAKE
  101. column: id
  102. sbtest10:
  103. actualDataNodes: ds_${0..1}.sbtest10_${0..99}
  104. tableStrategy:
  105. inline:
  106. shardingColumn: id
  107. algorithmExpression: sbtest10_${id % 100}
  108. keyGenerator:
  109. type: SNOWFLAKE
  110. column: id
  111. defaultDatabaseStrategy:
  112. inline:
  113. shardingColumn: id
  114. algorithmExpression: ds_${id % 2}

config-master_slave.yaml

  1. schemaName: sbtest
  2. dataSources:
  3. ds_0:
  4. url: jdbc:mysql://${host-mysql-1}:3306/sbtest?serverTimezone=UTC&useSSL=false
  5. username: root
  6. password:
  7. connectionTimeoutMilliseconds: 30000
  8. idleTimeoutMilliseconds: 60000
  9. maxLifetimeMilliseconds: 1800000
  10. maxPoolSize: 256
  11. masterSlaveRule:
  12. name: ms_ds
  13. masterDataSourceName: ds_0
  14. slaveDataSourceNames:
  15. - ds_0
  16. - ds_0

config-sharding-master_slave.yaml

  1. schemaName: sbtest
  2. dataSources:
  3. primary_ds_0:
  4. url: jdbc:mysql://${host-mysql-1}:3306/sbtest?serverTimezone=UTC&useSSL=false
  5. username: root
  6. password:
  7. connectionTimeoutMilliseconds: 30000
  8. idleTimeoutMilliseconds: 60000
  9. maxLifetimeMilliseconds: 1800000
  10. maxPoolSize: 256
  11. primary_ds_1:
  12. url: jdbc:mysql://${host-mysql-2}:3306/sbtest?serverTimezone=UTC&useSSL=false
  13. username: root
  14. password:
  15. connectionTimeoutMilliseconds: 30000
  16. idleTimeoutMilliseconds: 60000
  17. maxLifetimeMilliseconds: 1800000
  18. maxPoolSize: 256
  19. shardingRule:
  20. tables:
  21. sbtest1:
  22. actualDataNodes: ds_${0..1}.sbtest1_${0..99}
  23. tableStrategy:
  24. inline:
  25. shardingColumn: id
  26. algorithmExpression: sbtest1_${id % 100}
  27. keyGenerator:
  28. type: SNOWFLAKE
  29. column: id
  30. sbtest2:
  31. actualDataNodes: ds_${0..1}.sbtest2_${0..99}
  32. tableStrategy:
  33. inline:
  34. shardingColumn: id
  35. algorithmExpression: sbtest2_${id % 100}
  36. keyGenerator:
  37. type: SNOWFLAKE
  38. column: id
  39. sbtest3:
  40. actualDataNodes: ds_${0..1}.sbtest3_${0..99}
  41. tableStrategy:
  42. inline:
  43. shardingColumn: id
  44. algorithmExpression: sbtest3_${id % 100}
  45. keyGenerator:
  46. type: SNOWFLAKE
  47. column: id
  48. sbtest4:
  49. actualDataNodes: ds_${0..1}.sbtest4_${0..99}
  50. tableStrategy:
  51. inline:
  52. shardingColumn: id
  53. algorithmExpression: sbtest4_${id % 100}
  54. keyGenerator:
  55. type: SNOWFLAKE
  56. column: id
  57. sbtest5:
  58. actualDataNodes: ds_${0..1}.sbtest5_${0..99}
  59. tableStrategy:
  60. inline:
  61. shardingColumn: id
  62. algorithmExpression: sbtest5_${id % 100}
  63. keyGenerator:
  64. type: SNOWFLAKE
  65. column: id
  66. sbtest6:
  67. actualDataNodes: ds_${0..1}.sbtest6_${0..99}
  68. tableStrategy:
  69. inline:
  70. shardingColumn: id
  71. algorithmExpression: sbtest6_${id % 100}
  72. keyGenerator:
  73. type: SNOWFLAKE
  74. column: id
  75. sbtest7:
  76. actualDataNodes: ds_${0..1}.sbtest7_${0..99}
  77. tableStrategy:
  78. inline:
  79. shardingColumn: id
  80. algorithmExpression: sbtest7_${id % 100}
  81. keyGenerator:
  82. type: SNOWFLAKE
  83. column: id
  84. sbtest8:
  85. actualDataNodes: ds_${0..1}.sbtest8_${0..99}
  86. tableStrategy:
  87. inline:
  88. shardingColumn: id
  89. algorithmExpression: sbtest8_${id % 100}
  90. keyGenerator:
  91. type: SNOWFLAKE
  92. column: id
  93. sbtest9:
  94. actualDataNodes: ds_${0..1}.sbtest9_${0..99}
  95. tableStrategy:
  96. inline:
  97. shardingColumn: id
  98. algorithmExpression: sbtest9_${id % 100}
  99. keyGenerator:
  100. type: SNOWFLAKE
  101. column: id
  102. sbtest10:
  103. actualDataNodes: ds_${0..1}.sbtest10_${0..99}
  104. tableStrategy:
  105. inline:
  106. shardingColumn: id
  107. algorithmExpression: sbtest10_${id % 100}
  108. keyGenerator:
  109. type: SNOWFLAKE
  110. column: id
  111. defaultDatabaseStrategy:
  112. inline:
  113. shardingColumn: id
  114. algorithmExpression: ds_${id % 2}
  115. masterSlaveRules:
  116. ds_0:
  117. masterDataSourceName: primary_ds_0
  118. slaveDataSourceNames: [primary_ds_0, primary_ds_0]
  119. loadBalanceAlgorithmType: ROUND_ROBIN
  120. ds_1:
  121. masterDataSourceName: primary_ds_1
  122. slaveDataSourceNames: [primary_ds_1, primary_ds_1]
  123. loadBalanceAlgorithmType: ROUND_ROBIN

config-encrypt.yaml

  1. schemaName: sbtest
  2. dataSources:
  3. ds_0:
  4. url: jdbc:mysql://${host-mysql-1}:3306/sbtest?serverTimezone=UTC&useSSL=false
  5. username: root
  6. password:
  7. connectionTimeoutMilliseconds: 30000
  8. idleTimeoutMilliseconds: 60000
  9. maxLifetimeMilliseconds: 1800000
  10. maxPoolSize: 256
  11. encryptRule:
  12. encryptors:
  13. encryptor_md5:
  14. type: md5
  15. tables:
  16. sbtest1:
  17. columns:
  18. pad:
  19. cipherColumn: pad
  20. encryptor: encryptor_md5
  21. sbtest2:
  22. columns:
  23. pad:
  24. cipherColumn: pad
  25. encryptor: encryptor_md5
  26. sbtest3:
  27. columns:
  28. pad:
  29. cipherColumn: pad
  30. encryptor: encryptor_md5
  31. sbtest4:
  32. columns:
  33. pad:
  34. cipherColumn: pad
  35. encryptor: encryptor_md5
  36. sbtest5:
  37. columns:
  38. pad:
  39. cipherColumn: pad
  40. encryptor: encryptor_md5
  41. sbtest6:
  42. columns:
  43. pad:
  44. cipherColumn: pad
  45. encryptor: encryptor_md5
  46. sbtest7:
  47. columns:
  48. pad:
  49. cipherColumn: pad
  50. encryptor: encryptor_md5
  51. sbtest8:
  52. columns:
  53. pad:
  54. cipherColumn: pad
  55. encryptor: encryptor_md5
  56. sbtest9:
  57. columns:
  58. pad:
  59. cipherColumn: pad
  60. encryptor: encryptor_md5
  61. sbtest10:
  62. columns:
  63. pad:
  64. cipherColumn: pad
  65. encryptor: encryptor_md5

3.0.0 version

server.yaml

  1. authentication:
  2. username: root
  3. password: root
  4. props:
  5. max.connections.size.per.query: 10
  6. acceptor.size: 256 # The default value is available processors count * 2.
  7. executor.size: 128 # Infinite by default.
  8. proxy.frontend.flush.threshold: 128 # The default value is 128.
  9. # LOCAL: Proxy will run with LOCAL transaction.
  10. # XA: Proxy will run with XA transaction.
  11. # BASE: Proxy will run with B.A.S.E transaction.
  12. proxy.transaction.type: LOCAL
  13. proxy.opentracing.enabled: false
  14. sql.show: false

config-sharding.yaml

  1. schemaName: sbtest
  2. dataSources:
  3. ds_0:
  4. url: jdbc:mysql://${host-mysql-1}:3306/sbtest?serverTimezone=UTC&useSSL=false
  5. username: root
  6. password:
  7. autoCommit: true
  8. connectionTimeout: 30000
  9. idleTimeout: 60000
  10. maxLifetime: 1800000
  11. maximumPoolSize: 256
  12. ds_1:
  13. url: jdbc:mysql://${host-mysql-2}:3306/sbtest?serverTimezone=UTC&useSSL=false
  14. username: root
  15. password:
  16. autoCommit: true
  17. connectionTimeout: 30000
  18. idleTimeout: 60000
  19. maxLifetime: 1800000
  20. maximumPoolSize: 256
  21. shardingRule:
  22. tables:
  23. sbtest1:
  24. actualDataNodes: ds_${0..1}.sbtest1_${0..99}
  25. tableStrategy:
  26. inline:
  27. shardingColumn: id
  28. algorithmExpression: sbtest1_${id % 100}
  29. sbtest2:
  30. actualDataNodes: ds_${0..1}.sbtest2_${0..99}
  31. tableStrategy:
  32. inline:
  33. shardingColumn: id
  34. algorithmExpression: sbtest2_${id % 100}
  35. sbtest3:
  36. actualDataNodes: ds_${0..1}.sbtest3_${0..99}
  37. tableStrategy:
  38. inline:
  39. shardingColumn: id
  40. algorithmExpression: sbtest3_${id % 100}
  41. sbtest4:
  42. actualDataNodes: ds_${0..1}.sbtest4_${0..99}
  43. tableStrategy:
  44. inline:
  45. shardingColumn: id
  46. algorithmExpression: sbtest4_${id % 100}
  47. sbtest5:
  48. actualDataNodes: ds_${0..1}.sbtest5_${0..99}
  49. tableStrategy:
  50. inline:
  51. shardingColumn: id
  52. algorithmExpression: sbtest5_${id % 100}
  53. sbtest6:
  54. actualDataNodes: ds_${0..1}.sbtest6_${0..99}
  55. tableStrategy:
  56. inline:
  57. shardingColumn: id
  58. algorithmExpression: sbtest6_${id % 100}
  59. sbtest7:
  60. actualDataNodes: ds_${0..1}.sbtest7_${0..99}
  61. tableStrategy:
  62. inline:
  63. shardingColumn: id
  64. algorithmExpression: sbtest7_${id % 100}
  65. sbtest8:
  66. actualDataNodes: ds_${0..1}.sbtest8_${0..99}
  67. tableStrategy:
  68. inline:
  69. shardingColumn: id
  70. algorithmExpression: sbtest8_${id % 100}
  71. sbtest9:
  72. actualDataNodes: ds_${0..1}.sbtest9_${0..99}
  73. tableStrategy:
  74. inline:
  75. shardingColumn: id
  76. algorithmExpression: sbtest9_${id % 100}
  77. sbtest10:
  78. actualDataNodes: ds_${0..1}.sbtest10_${0..99}
  79. tableStrategy:
  80. inline:
  81. shardingColumn: id
  82. algorithmExpression: sbtest10_${id % 100}
  83. defaultDatabaseStrategy:
  84. inline:
  85. shardingColumn: id
  86. algorithmExpression: ds_${id % 2}

config-master_slave.yaml

  1. schemaName: sbtest
  2. dataSources:
  3. ds_0:
  4. url: jdbc:mysql://${host-mysql-1}:3306/sbtest?serverTimezone=UTC&useSSL=false
  5. username: root
  6. password:
  7. autoCommit: true
  8. connectionTimeout: 30000
  9. idleTimeout: 60000
  10. maxLifetime: 1800000
  11. maximumPoolSize: 256
  12. masterSlaveRule:
  13. name: ms_ds
  14. masterDataSourceName: ds_0
  15. slaveDataSourceNames:
  16. - ds_0
  17. - ds_0

config-sharding-master_slave.yaml

  1. schemaName: sbtest
  2. dataSources:
  3. primary_ds_0:
  4. url: jdbc:mysql://${host-mysql-1}:3306/sbtest?serverTimezone=UTC&useSSL=false
  5. username: root
  6. password:
  7. autoCommit: true
  8. connectionTimeout: 30000
  9. idleTimeout: 60000
  10. maxLifetime: 1800000
  11. maximumPoolSize: 256
  12. primary_ds_1:
  13. url: jdbc:mysql://${host-mysql-2}:3306/sbtest?serverTimezone=UTC&useSSL=false
  14. username: root
  15. password:
  16. autoCommit: true
  17. connectionTimeout: 30000
  18. idleTimeout: 60000
  19. maxLifetime: 1800000
  20. maximumPoolSize: 256
  21. shardingRule:
  22. tables:
  23. sbtest1:
  24. actualDataNodes: ds_${0..1}.sbtest1_${0..99}
  25. tableStrategy:
  26. inline:
  27. shardingColumn: id
  28. algorithmExpression: sbtest1_${id % 100}
  29. sbtest2:
  30. actualDataNodes: ds_${0..1}.sbtest2_${0..99}
  31. tableStrategy:
  32. inline:
  33. shardingColumn: id
  34. algorithmExpression: sbtest2_${id % 100}
  35. sbtest3:
  36. actualDataNodes: ds_${0..1}.sbtest3_${0..99}
  37. tableStrategy:
  38. inline:
  39. shardingColumn: id
  40. algorithmExpression: sbtest3_${id % 100}
  41. sbtest4:
  42. actualDataNodes: ds_${0..1}.sbtest4_${0..99}
  43. tableStrategy:
  44. inline:
  45. shardingColumn: id
  46. algorithmExpression: sbtest4_${id % 100}
  47. sbtest5:
  48. actualDataNodes: ds_${0..1}.sbtest5_${0..99}
  49. tableStrategy:
  50. inline:
  51. shardingColumn: id
  52. algorithmExpression: sbtest5_${id % 100}
  53. sbtest6:
  54. actualDataNodes: ds_${0..1}.sbtest6_${0..99}
  55. tableStrategy:
  56. inline:
  57. shardingColumn: id
  58. algorithmExpression: sbtest6_${id % 100}
  59. sbtest7:
  60. actualDataNodes: ds_${0..1}.sbtest7_${0..99}
  61. tableStrategy:
  62. inline:
  63. shardingColumn: id
  64. algorithmExpression: sbtest7_${id % 100}
  65. sbtest8:
  66. actualDataNodes: ds_${0..1}.sbtest8_${0..99}
  67. tableStrategy:
  68. inline:
  69. shardingColumn: id
  70. algorithmExpression: sbtest8_${id % 100}
  71. sbtest9:
  72. actualDataNodes: ds_${0..1}.sbtest9_${0..99}
  73. tableStrategy:
  74. inline:
  75. shardingColumn: id
  76. algorithmExpression: sbtest9_${id % 100}
  77. sbtest10:
  78. actualDataNodes: ds_${0..1}.sbtest10_${0..99}
  79. tableStrategy:
  80. inline:
  81. shardingColumn: id
  82. algorithmExpression: sbtest10_${id % 100}
  83. defaultDatabaseStrategy:
  84. inline:
  85. shardingColumn: id
  86. algorithmExpression: ds_${id % 2}
  87. masterSlaveRules:
  88. ds_0:
  89. masterDataSourceName: primary_ds_0
  90. slaveDataSourceNames: [primary_ds_0, primary_ds_0]
  91. loadBalanceAlgorithmType: ROUND_ROBIN
  92. ds_1:
  93. masterDataSourceName: primary_ds_1
  94. slaveDataSourceNames: [primary_ds_1, primary_ds_1]
  95. loadBalanceAlgorithmType: ROUND_ROBIN

config-encrypt.yaml

  1. 不支持

附录2

plot_graph.py

  1. import sys
  2. import matplotlib.pyplot as plt
  3. import numpy as np
  4. def generate_graph(path, case_name):
  5. dataset = {
  6. 'build_num': [],
  7. 'master_version': [],
  8. 'master_xa': [],
  9. '4.1.1_version': [],
  10. '3.0.0_version': [],
  11. 'mysql_server': []
  12. }
  13. with open(path + '/.build_number.txt') as builds:
  14. for line in builds:
  15. dataset['build_num'].append(int(line))
  16. generate_data(path, case_name, dataset)
  17. print(dataset)
  18. fig, ax = plt.subplots()
  19. ax.grid(True)
  20. plt.title(case_name)
  21. data = [dataset['master_version'][-7:], dataset['master_xa'][-7:], dataset['4.1.1_version'][-7:], dataset['3.0.0_version'][-7:], dataset['mysql_server'][-7:]]
  22. columns = dataset['build_num'][-7:]
  23. rows = ['master', 'xa', '4.1.1', '3.0.0', 'mysql']
  24. rcolors = plt.cm.BuPu(np.full(len(rows), 0.1))
  25. ccolors = plt.cm.BuPu(np.full(len(columns), 0.1))
  26. the_table = plt.table(cellText=data, rowLabels=rows, colLabels=columns, rowColours=rcolors, colColours=ccolors,
  27. loc='bottom', bbox=[0.0, -0.50, 1, .28])
  28. plt.subplots_adjust(left=0.15, bottom=0.3, right=0.98)
  29. plt.xticks(range(14))
  30. ax.set_xticklabels(dataset['build_num'])
  31. plt.plot(dataset['master_version'], 'o-', color='magenta', label='master_version')
  32. plt.plot(dataset['master_xa'], 'o-', color='darkviolet', label='master_xa')
  33. plt.plot(dataset['4.1.1_version'], 'r--', color='blue', label='4.1.1_version')
  34. plt.plot(dataset['3.0.0_version'], 'r--', color='orange', label='3.0.0_version')
  35. plt.plot(dataset['mysql_server'], 'r--', color='lime', label='mysql_server')
  36. plt.xlim()
  37. plt.legend()
  38. plt.xlabel('build_num')
  39. plt.ylabel('transactions per second')
  40. plt.savefig('graph/' + path + '/' + case_name)
  41. plt.show()
  42. def generate_data(path, case_name, dataset):
  43. for build in dataset['build_num']:
  44. fill_dataset(build, case_name, dataset, path, 'master_version', '.master.txt')
  45. fill_dataset(build, case_name, dataset, path, 'master_xa', '.xa.txt')
  46. fill_dataset(build, case_name, dataset, path, '4.1.1_version', '.4_1_1.txt')
  47. fill_dataset(build, case_name, dataset, path, '3.0.0_version', '.3_0_0.txt')
  48. fill_dataset(build, case_name, dataset, path, 'mysql_server', '.mysql.txt')
  49. def fill_dataset(build, case_name, dataset, path, version, suffix):
  50. try:
  51. with open(path + '/' + str(build) + '/' + case_name + suffix) as version_master:
  52. value = 0
  53. for line in version_master:
  54. if 'transactions:' in line:
  55. items = line.split('(')
  56. value = float(items[1][:-10])
  57. dataset[version].append(value)
  58. except FileNotFoundError:
  59. dataset[version].append(0)
  60. if __name__ == '__main__':
  61. path = sys.argv[1]
  62. generate_graph(path, 'oltp_point_select')
  63. generate_graph(path, 'oltp_read_only')
  64. generate_graph(path, 'oltp_write_only')
  65. generate_graph(path, 'oltp_read_write')
  66. generate_graph(path, 'oltp_update_index')
  67. generate_graph(path, 'oltp_update_non_index')
  68. generate_graph(path, 'oltp_delete')

目前在 ShardingSphere 的 benchmark 项目 shardingsphere-benchmark 中已经共享了 sysbench 的使用方式 : sysbench 压测工具