更新时间:2022-09-02 09:21:47
TPC-C是业界常用的一套Benchmark,由TPC委员会制定发布,用于评测数据库的联机交易处理(偏向OLTP能力)。主要涉及10张表,包含了NewOrder(新订单的生成)、Payment(订单付款)、OrderStatus(最近订单查询)、Delivery(配送)和StockLevel(库存缺货状态分析)等五类业务事务模型。TPC-C使用tpmC值(Transactions per Minute)来衡量系统最大有效吞吐量(MQTh,Max Qualified Throughput),其中Transactions以NewOrder Transaction为准,即最终衡量单位为每分钟处理的新订单数。
说明 本文的TPC-C的实现基于TPC-C的基准测试,并不能与已发布的TPC-C基准测试结果相比较,本文中的测试并不符合TPC-C基准测试的所有要求。
tpcc
,详细操作步骤请参见步骤二:在私有定制RDS实例之上构建PolarDB-X 1.0数据库
mkdir tpcc tar zxvf tpcc.tar.gz -C tpcc
src/client/jTPCC.java(增加一个MySQL的type) src/client/jTPCCConnection.java(支持MySQL的语法,加一个别名) src/LoadData/LoadData.java(关闭loader数据时的大事务机制) src/LoadData/LoadDataWorker.java(关闭loader数据时的大事务机制) run/funcs.sh(脚本增加一个MySQL的type) run/runDatabaseBuild.sh(去掉不必要的阶段) run/runBenchmark.sh(调整默认jvm参数) run/runLoader.sh(调整默认jvm参数) run/sql.common/foreignKeys.sql (注释全部外键创建,PolarDB-X不支持外键) run/sql.common/indexCreates.sql (注释掉全部主键创建,只留2个索引创建,MySQL默认在建表时直接创建索引) run/sql.common/indexDrops.sql(注释全部主键删除) run/sql.common/tableCreates.sql(添加主键和拆分键,PolarDB-X需要指定拆分键)
tpcc/run
目录下创建props.mysql
文件:// --------- env config --------- // db=mysql driver=com.mysql.jdbc.Driver conn=jdbc:mysql://drdsxxxx:3306/tpcc? useSSL=false&useServerPrepStmts=false&useConfigs=maxPerformance&rewriteBatchedStatements=true user=tpcc password=tpcc // warehouse 数量 warehouses=1000 // 导入数据的并发数,每100并发预计产生2万TPS,可以结合目标TPS能力调整并发 // runLoader.sh的jvm内存,100并发默认为4 GB,500并发建议设置为16 GB loadWorkers=100 // TPC-C 压测并发数 terminals=1000 // 压测时间,单位分钟 runMins=10 // ---------- default config ------- // //To run specified transactions per terminal- runMins must equal zero runTxnsPerTerminal=0 //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
(仓库数)和loadWorkers
(并发数)。terminals
(并发数)和runMins
(运行时间)。cd tpcc/run nohup ./runDatabaseBuild.sh props.mysql &
cd tpcc/run ./runBenchmark.sh props.mysql
08:56:16,844 [Thread-883] INFO jTPCC : Term-00, Measured tpmC (NewOrders) = 104230.88 08:56:16,844 [Thread-883] INFO jTPCC : Term-00, Measured tpmTOTAL = 231664.49 08:56:16,844 [Thread-883] INFO jTPCC : Term-00, Session Start = 2019-09-19 08:54:16 08:56:16,845 [Thread-883] INFO jTPCC : Term-00, Session End = 2019-09-19 08:56:16 08:56:16,845 [Thread-883] INFO jTPCC : Term-00, Transaction Count = 465440
tpmC
值即为对应压测场景下的结果。更多测试结果详情,请参见测试结果。cd tpcc/run ./runDatabaseDestroy.sh props.mysql
并发度 | 标准版实例tpmC | 企业版实例tpmC | 超大规格实例tpmC |
1个客户端x 1000并发 | 65,735.14 | 101,620.8 | / |
6个客户端x 1000并发 | / | / | 821,547.97 |