BenchmarkSQL對數據庫性能測試示例


BenchmarkSQL對數據庫性能測試示例

 

最近在做TIDB的上線部署,部署完成后需要對其進行性能測試,所以我們就用了benchmarkSQL這個工具啦

TiDB文檔地址:https://pingcap.com/docs-cn/stable/benchmark/benchmark-tidb-using-tpcc/

#首先我們需要下載benchmarksql

git clone -b 5.0-mysql-support-opt-2.1 https://github.com/pingcap/benchmarksql.git

#安裝好 java , ant

sudo yum install -y java ant

#構建ant

cd benchmarksql

ant
#遠程復制服務命令:(將下載好的benchmarksql通過scp遠程復制到指定服務器,如果網絡是通的則可以直接SecureFX上傳)

scp -r user@10.22.33.44:/home/user/tidb/benchmarksql ./

  

接下來我們就要開始准備測試數據庫性能了,這里我們是使用benchmarksql測試tidb (和Mysql類似,所以我們會參考mysql的配置信息來做調整

1.參考 benchmarksql/run/ props.mysql 配置文件

db=mysql
driver=com.mysql.jdbc.Driver
conn=jdbc:mysql://localhost:4000/tpcc?useSSL=false&useServerPrepStmts=true&useConfigs=maxPerformance&rewriteBatchedStatements=true
user=root
password=

warehouses=1
loadWorkers=4

terminals=1
//To run specified transactions per terminal- runMins must equal zero
runTxnsPerTerminal=0
//To run for specified minutes- runTxnsPerTerminal must equal zero
runMins=10
//Number of total transactions per minute
limitTxnsPerMin=0

//Set to true to run in 4.x compatible mode. Set to false to use the
//entire configured database evenly.
terminalWarehouseFixed=true

//The following five values must add up to 100
//The default percentages of 45, 43, 4, 4 & 4 match the TPC-C spec
newOrderWeight=45
paymentWeight=43
orderStatusWeight=4
deliveryWeight=4
stockLevelWeight=4

// Directory name to create for collecting detailed result data.
// Comment this out to suppress.
resultDirectory=my_result_%tY-%tm-%td_%tH%tM%tS
//osCollectorScript=./misc/os_collector_linux.py
//osCollectorInterval=1
//osCollectorSSHAddr=user@dbhost
//osCollectorDevices=net_eth0 blk_sda

 

配置文件說明:

Warehouses 代表倉庫數,框中的數字表示該表將存放的記錄條數,倉庫數的調整在測試中能夠體現數據庫所能支持的數據規模的能力。每個 Warehouse 的數據量,其大小約為 76823.04KB,可以有小量的變化,因為測試過程中將會插入或刪除現有記錄。可以根據每個Warehouse的數據量,計算測試過程中的數據總量。
計算公式為:數據總量(KB)≈ Warehouse個數*76823.04KB
以10個Warehouse的數據量為例計算其數據總量大小約為:768230.4KB

loadWorkers=10   //用於在數據庫中初始化數據的加載進程數量,默認為4,實際使用過程中可以根據實際情況調整,加載速度會隨worker數量的增加而有所提升

terminals=10  //終端數,即並發客戶端數量,通常設置為CPU線程總數的2~6倍

runTxnsPerTerminal=10 //每個終端(terminal)運行的固定事務數量,例如:如果該值設置為10,意味着每個terminal運行10個事務,如果有32個終端,那整體運行320個事務后,測試結束。該參數配置為非0值時,下面的runMins參數必須設置為0
 
runMins=0    //要測試的整體時間,單位為分鍾,如果runMins設置為60,那么測試持續1小時候結束。該值設置為非0值時,runTxnsPerTerminal參數必須設置為0。這兩個參數不能同時設置為正整數,如果設置其中一個,另一個必須為0,主要區別是runMins定義時間長度來控制測試時間;runTxnsPerTerminal定義事務總數來控制時間。

  

參考以上配置文件新建我們自己的測試配置文件 benchmark_tidb.properties 並調整參數信息:(需要先新建對應的庫信息 在數據庫中新建數據庫:benchmark_test )

db=mysql
driver=com.mysql.cj.jdbc.Driver
conn=jdbc:mysql://10.55.33.44:4000/benchmark_test
user=root
password=

warehouses=40
loadWorkers=10

terminals=100
//To run specified transactions per terminal- runMins must equal zero
runTxnsPerTerminal=0
//To run for specified minutes- runTxnsPerTerminal must equal zero
runMins=2
//Number of total transactions per minute
limitTxnsPerMin=0

//Set to true to run in 4.x compatible mode. Set to false to use the
//entire configured database evenly.
terminalWarehouseFixed=true

//The following five values must add up to 100
//The default percentages of 45, 43, 4, 4 & 4 match the TPC-C spec
newOrderWeight=45
paymentWeight=43
orderStatusWeight=4
deliveryWeight=4
stockLevelWeight=4

// Directory name to create for collecting detailed result data.
// Comment this out to suppress.
resultDirectory=my_result_%tY-%tm-%td_%tH%tM%tS
//osCollectorScript=./misc/os_collector_linux.py
//osCollectorInterval=1
//osCollectorSSHAddr=user@dbhost
//osCollectorDevices=net_eth0 blk_sda

 

2.開始運行 進入benchmarkSQL的run目錄,依次執行以下命令

./runSQL.sh benchmark_tidb.properties ./sql.common/tableCreates.sql

.
/runSQL.sh benchmark_tidb.properties ./sql.common/indexCreates.sql
.
/runDatabaseBuild.sh benchmark_tidb.properties
.
/runBenchmark.sh benchmark_tidb.properties

 

./runBenchmark.sh benchmark_tidb.properties 執行結果:

 

 

netstat -tlnp  #說明 l:listening  t: tcp    n:number   p:process

  


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM