sonumb

TPC-C: YugabyteDB VS. TiDB 본문

개발자 이야기/DBMS_일반

TPC-C: YugabyteDB VS. TiDB

sonumb 2021. 3. 9. 14:54

목차

    1. 테스팅 전략
  • 1.1. benchmarksql
  • 1.1.1. 검증
  • 1.1.2. 테스트
  • 1.1.3. benchmarksql 5.1
  • 1.2. tpcc
  • 1.2.1. 사전작업
  • 1.2.1.1. config/workload_mysql.xml 파일
  • 1.2.1.2. tpcc-mysql-ddl.sql 파일
  • 1.2.2. 검증
  • 1.2.3. yugabyteDB 테스트
  • 1.2.3.1. Load data
  • 1.2.3.2. TPC-C 실행
  • 1.2.4. TiDB (mysql) 으로 TPCC 실행 시 문제
  • 1.2.5. 수정사항
  • 1.3. oltpbench
    1. 환경설정 및 실행
  • 2.1. benchmarksql
  • 2.1.1. Yugabyte 세팅
  • 2.1.2. JDBC 드라이버
  • 2.1.3. 컨넥션 스트링 세팅
  • 2.2. tpcc
  • 2.3. oltpbenchmark
  • 2.3.1. 사용법
  • 2.3.2. 데이터 구성
  • 2.3.2.1. command
    1. 테스트
  • 3.1. 개요
  • 3.2. 환경
  • 3.2.1. 데이터
  • 3.2.2. 변수들
  • 3.2.2.1. 통제변수
  • 3.2.2.2. 조작 변수
  • 3.2.2.2.1. TPCC 데이터셋 생성 및 로딩
  • 3.2.2.2.2. TPCC 트랜잭션 처리 테스트
  • 3.2.3. 측정결과값 (종속변인)
  • 3.3. 스크립트
  • 3.3.1. YugabyteDB
  • 3.3.2. TiDB
  • 3.4. 결과
  • 3.4.1. 테이블 및 그래프
  • 3.4.1.1. 1번 TPCC 데이터셋 생성 및 로딩 실험
  • 3.4.1.2. 2번 트랜잭션 처리 테스트 - 터미널 개수 고정, 웨어하우스 변경
  • 3.4.1.3. 3번 트랜잭션 처리 테스트 - 터미널 개수 변경, 웨어하우스 고정
⚠️ 중요:
TiDB와 YugabyteDB에서 제공하는 tpcc 테스트는 각기 다른 소스코드를 사용한다.
따라서, 얼추 맞추기 위해, TiDB의 테스트를  YugabayteDB용 tpcc 테스트의 모체가 되는 oltpbench를 이용해서 테스트를 하려하였다. 헌데, 이에 몇 가지 문제가 있어서 결국 각 제조사에서 제공하는 테스트슈트로 테스트를 진행하였고, 그것에 대한 결과는 '3. 결과'에 기록하였다.

1. 테스팅 전략

  • TiDB용 TPC-C 슈트(benchmarksql)를 이용하여 테스트
  • YugabyteDB용 TPC-C 슈트(tpcc)를 이용하여 테스트
  • oltpbench 를 이용하여 테스트

1.1. benchmarksql

jTPCC(http://jtpcc.sourceforge.net/)를%EB%A5%BC) fork하여, BenchmarkSQL( https://sourceforge.net/projects/benchmarksql/)를%EB%A5%BC) 작성함

YugabyteDB 테스트를 위한 변경/추가 작업을 http://github.com/sarang2dan/benchmarksql 에 기록하였다.

1.1.1. 검증

java 소스의 구조는 아래와 같음

public interface jTPCCConfig
{
    // 생략

    public final static int  configCommitCount  = 10000;  // commit every n records in LoadData

    public final static int  configWhseCount    = 10;
    public final static int  configItemCount    = 100000; // tpc-c std = 100,000
    public final static int  configDistPerWhse  = 10;     // tpc-c std = 10
    public final static int  configCustPerDist  = 3000;   // tpc-c std = 3,000
}

1.1.2. 테스트
실행 방법은 README.md 파일을 참고하라

실행전에 DB가 생성되어 있어야 한다.

$ mysql -u root <<< "drop database if exists tpcc; create database tpcc;"

기본적인 설정값은 아래와 같다.

warehouses=10
loadWorkers=10
terminals=100
runMins=10

Measured tpmC (NewOrders) = 28490.21

17:49:49,384 [main] INFO   jTPCC : Term-00,
17:49:49,385 [main] INFO   jTPCC : Term-00, +-------------------------------------------------------------+
17:49:49,385 [main] INFO   jTPCC : Term-00,      BenchmarkSQL v5.0
17:49:49,386 [main] INFO   jTPCC : Term-00, +-------------------------------------------------------------+
17:49:49,386 [main] INFO   jTPCC : Term-00,  (c) 2003, Raul Barbosa
17:49:49,386 [main] INFO   jTPCC : Term-00,  (c) 2004-2016, Denis Lussier
17:49:49,387 [main] INFO   jTPCC : Term-00,  (c) 2016, Jan Wieck
17:49:49,387 [main] INFO   jTPCC : Term-00, +-------------------------------------------------------------+
17:49:49,387 [main] INFO   jTPCC : Term-00,
17:49:49,393 [main] INFO   jTPCC : Term-00, db=mysql
17:49:49,394 [main] INFO   jTPCC : Term-00, driver=com.mysql.jdbc.Driver
17:49:49,394 [main] INFO   jTPCC : Term-00, conn=jdbc:mysql://localhost:4000/tpcc?useSSL=false&useServerPrepStmts=true&useConfigs=maxPerformance&rewriteBatchedStatements=true
17:49:49,394 [main] INFO   jTPCC : Term-00, user=root
17:49:49,394 [main] INFO   jTPCC : Term-00,
17:49:49,394 [main] INFO   jTPCC : Term-00, warehouses=10
17:49:49,394 [main] INFO   jTPCC : Term-00, terminals=100
17:49:49,397 [main] INFO   jTPCC : Term-00, runMins=10
17:49:49,397 [main] INFO   jTPCC : Term-00, limitTxnsPerMin=0
17:49:49,397 [main] INFO   jTPCC : Term-00, terminalWarehouseFixed=true
17:49:49,397 [main] INFO   jTPCC : Term-00,
17:49:49,397 [main] INFO   jTPCC : Term-00, newOrderWeight=45
17:49:49,397 [main] INFO   jTPCC : Term-00, paymentWeight=43
17:49:49,397 [main] INFO   jTPCC : Term-00, orderStatusWeight=4
17:49:49,397 [main] INFO   jTPCC : Term-00, deliveryWeight=4
17:49:49,397 [main] INFO   jTPCC : Term-00, stockLevelWeight=4
17:49:49,397 [main] INFO   jTPCC : Term-00,
17:49:49,397 [main] INFO   jTPCC : Term-00, resultDirectory=result_tidb_%tY-%tm-%td_%tH%tM%tS
17:49:49,398 [main] INFO   jTPCC : Term-00, osCollectorScript=null
17:49:49,398 [main] INFO   jTPCC : Term-00,
Loading class `com.mysql.jdbc.Driver'. This is deprecated. The new driver class is `com.mysql.cj.jdbc.Driver'. The driver is automatically registered via the SPI and manual loading of the driver class is generally unnecessary.
17:49:49,413 [main] INFO   jTPCC : Term-00, copied props.tidb to result_tidb_2021-02-09_174949/run.properties
17:49:49,417 [main] INFO   jTPCC : Term-00, created result_tidb_2021-02-09_174949/data/runInfo.csv for runID 15
17:49:49,417 [main] INFO   jTPCC : Term-00, writing per transaction results to result_tidb_2021-02-09_174949/data/result.csv
17:49:49,417 [main] INFO   jTPCC : Term-00,
17:49:49,576 [main] INFO   jTPCC : Term-00, C value for C_LAST during load: 189
17:49:49,576 [main] INFO   jTPCC : Term-00, C value for C_LAST this run:    87
17:49:49,576 [main] INFO   jTPCC : Term-00,
Term-00, Running Average tpmTOTAL: 63289.98    Current tpmTOTAL: 4181004    Memory Usage: 629MB / 1024MB
17:59:51,081 [Thread-76] INFO   jTPCC : Term-00,
17:59:51,082 [Thread-76] INFO   jTPCC : Term-00,
17:59:51,083 [Thread-76] INFO   jTPCC : Term-00, Measured tpmC (NewOrders) = 28490.21
17:59:51,084 [Thread-76] INFO   jTPCC : Term-00, Measured tpmTOTAL = 63280.48
17:59:51,084 [Thread-76] INFO   jTPCC : Term-00, Session Start     = 2021-02-09 17:49:50
17:59:51,084 [Thread-76] INFO   jTPCC : Term-00, Session End       = 2021-02-09 17:59:51
17:59:51,084 [Thread-76] INFO   jTPCC : Term-00, Transaction Count = 632999
17:59:51,084 [Thread-76] INFO   jTPCC : executeTime[Payment]=33116129
17:59:51,084 [Thread-76] INFO   jTPCC : executeTime[Order-Status]=170395
17:59:51,084 [Thread-76] INFO   jTPCC : executeTime[Delivery]=5049184
17:59:51,085 [Thread-76] INFO   jTPCC : executeTime[Stock-Level]=357373
17:59:51,085 [Thread-76] INFO   jTPCC : executeTime[New-Order]=21310123

1.1.3. benchmarksql 5.1

기존 5.0에서 아래와 같은 사항이 변경/추가 되었다.

Clarify License
Remove deprecated Oracle proprietary features (allows to build without the ORA JDBC driver)
Change result graphs to inlined SVGs
Add an option to skip rampup time in the report
Add CPU utilization summary to report
Numerous bug fixes

그리고 여기에 mysql, tidb, yugabyte 를 테스트 할 수 있도록 추가 및 수정하였다.

변경된 사항들은 아래 git branch에 저장되어 있다.
http://github.com/sarang2dan/benchmarksql_5_1

실행전에 DB가 생성되어 있어야 한다.

$ mysql -u root <<< "drop database if exists tpcc; create database tpcc;"

1.2. tpcc

tpcc은 https://github.com/oltpbenchmark/oltpbench 를 베이스로 만들어졌다.

TiDB/YugabyteDB 테스트를 위한 변경/추가 작업을 http://github.com/sarang2dan/tpcc 에 기록하였다.

1.2.1. 사전작업

1.2.1.1. config/workload_mysql.xml 파일

config/workload.xml을 config/workload_mysql.xml로 복사하여 수정한다.

  <?xml version="1.0"?>
  <parameters>
      <dbtype>mysql</dbtype>
      <driver>com.mysql.jdbc.Driver</driver>
      <jdbcURL>jdbc:mysql://localhost:4000/test</jdbcURL>
      <port>4000</port>
      <DBName>mysql</DBName>
      <username>root</username>
      <password></password>
...

1.2.1.2. tpcc-mysql-ddl.sql 파일

.//src/com/oltpbenchmark/benchmarks/tpcc/ddls/tpcc-mysql-ddl.sql 파일을 생성하여 아래 내용을 채워넣는다.

빌드를 한 후였다면, 동일한 내용을 .//build/com/oltpbenchmark/benchmarks/tpcc/ddls/tpcc-mysql-ddl.sql 로 복사 해준다.

-- TODO: C_SINCE ON UPDATE CURRENT_TIMESTAMP,

-- woonhak, turn off foreign key check, reference tpcc-mysql and tpcc specification
SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;

DROP TABLE IF EXISTS CUSTOMER;
DROP TABLE IF EXISTS DISTRICT;
DROP TABLE IF EXISTS HISTORY;
DROP TABLE IF EXISTS ITEM;
DROP TABLE IF EXISTS NEW_ORDER;
DROP TABLE IF EXISTS OORDER;
DROP TABLE IF EXISTS ORDER_LINE;
DROP TABLE IF EXISTS STOCK;
DROP TABLE IF EXISTS WAREHOUSE;

CREATE TABLE CUSTOMER (
  C_W_ID INT NOT NULL,
  C_D_ID INT NOT NULL,
  C_ID INT NOT NULL,
  C_DISCOUNT DECIMAL(4,4) NOT NULL,
  C_CREDIT CHAR(2) NOT NULL,
  C_LAST VARCHAR(16) NOT NULL,
  C_FIRST VARCHAR(16) NOT NULL,
  C_CREDIT_LIM DECIMAL(12,2) NOT NULL,
  C_BALANCE DECIMAL(12,2) NOT NULL,
  C_YTD_PAYMENT FLOAT NOT NULL,
  C_PAYMENT_CNT INT NOT NULL,
  C_DELIVERY_CNT INT NOT NULL,
  C_STREET_1 VARCHAR(20) NOT NULL,
  C_STREET_2 VARCHAR(20) NOT NULL,
  C_CITY VARCHAR(20) NOT NULL,
  C_STATE CHAR(2) NOT NULL,
  C_ZIP CHAR(9) NOT NULL,
  C_PHONE CHAR(16) NOT NULL,
  C_SINCE TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
  C_MIDDLE CHAR(2) NOT NULL,
  C_DATA VARCHAR(500) NOT NULL,
  PRIMARY KEY (C_W_ID,C_D_ID,C_ID)
);


CREATE TABLE DISTRICT (
  D_W_ID INT NOT NULL,
  D_ID INT NOT NULL,
  D_YTD DECIMAL(12,2) NOT NULL,
  D_TAX DECIMAL(4,4) NOT NULL,
  D_NEXT_O_ID INT NOT NULL,
  D_NAME VARCHAR(10) NOT NULL,
  D_STREET_1 VARCHAR(20) NOT NULL,
  D_STREET_2 VARCHAR(20) NOT NULL,
  D_CITY VARCHAR(20) NOT NULL,
  D_STATE CHAR(2) NOT NULL,
  D_ZIP CHAR(9) NOT NULL,
  PRIMARY KEY (D_W_ID,D_ID)
);

-- TODO: H_DATE ON UPDATE CURRENT_TIMESTAMP

CREATE TABLE HISTORY (
  H_C_ID INT NOT NULL,
  H_C_D_ID INT NOT NULL,
  H_C_W_ID INT NOT NULL,
  H_D_ID INT NOT NULL,
  H_W_ID INT NOT NULL,
  H_DATE TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
  H_AMOUNT DECIMAL(6,2) NOT NULL,
  H_DATA VARCHAR(24) NOT NULL
);


CREATE TABLE ITEM (
  I_ID INT NOT NULL,
  I_NAME VARCHAR(24) NOT NULL,
  I_PRICE DECIMAL(5,2) NOT NULL,
  I_DATA VARCHAR(50) NOT NULL,
  I_IM_ID INT NOT NULL,
  PRIMARY KEY (I_ID)
);


CREATE TABLE NEW_ORDER (
  NO_W_ID INT NOT NULL,
  NO_D_ID INT NOT NULL,
  NO_O_ID INT NOT NULL,
  PRIMARY KEY (NO_W_ID,NO_D_ID,NO_O_ID)
);

-- TODO: O_ENTRY_D  ON UPDATE CURRENT_TIMESTAMP

CREATE TABLE OORDER (
  O_W_ID INT NOT NULL,
  O_D_ID INT NOT NULL,
  O_ID INT NOT NULL,
  O_C_ID INT NOT NULL,
  O_CARRIER_ID INT DEFAULT NULL,
  O_OL_CNT DECIMAL(2,0) NOT NULL,
  O_ALL_LOCAL DECIMAL(1,0) NOT NULL,
  O_ENTRY_D TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (O_W_ID,O_D_ID,O_ID),
  UNIQUE (O_W_ID,O_D_ID,O_C_ID,O_ID)
);


CREATE TABLE ORDER_LINE (
  OL_W_ID INT NOT NULL,
  OL_D_ID INT NOT NULL,
  OL_O_ID INT NOT NULL,
  OL_NUMBER INT NOT NULL,
  OL_I_ID INT NOT NULL,
  OL_DELIVERY_D TIMESTAMP NULL DEFAULT NULL,
  OL_AMOUNT DECIMAL(6,2) NOT NULL,
  OL_SUPPLY_W_ID INT NOT NULL,
  OL_QUANTITY DECIMAL(2,0) NOT NULL,
  OL_DIST_INFO CHAR(24) NOT NULL,
  PRIMARY KEY (OL_W_ID,OL_D_ID,OL_O_ID,OL_NUMBER)
);

CREATE TABLE STOCK (
  S_W_ID INT NOT NULL,
  S_I_ID INT NOT NULL,
  S_QUANTITY DECIMAL(4,0) NOT NULL,
  S_YTD DECIMAL(8,2) NOT NULL,
  S_ORDER_CNT INT NOT NULL,
  S_REMOTE_CNT INT NOT NULL,
  S_DATA VARCHAR(50) NOT NULL,
  S_DIST_01 CHAR(24) NOT NULL,
  S_DIST_02 CHAR(24) NOT NULL,
  S_DIST_03 CHAR(24) NOT NULL,
  S_DIST_04 CHAR(24) NOT NULL,
  S_DIST_05 CHAR(24) NOT NULL,
  S_DIST_06 CHAR(24) NOT NULL,
  S_DIST_07 CHAR(24) NOT NULL,
  S_DIST_08 CHAR(24) NOT NULL,
  S_DIST_09 CHAR(24) NOT NULL,
  S_DIST_10 CHAR(24) NOT NULL,
  PRIMARY KEY (S_W_ID,S_I_ID)
);

CREATE TABLE WAREHOUSE (
  W_ID INT NOT NULL,
  W_YTD DECIMAL(12,2) NOT NULL,
  W_TAX DECIMAL(4,4) NOT NULL,
  W_NAME VARCHAR(10) NOT NULL,
  W_STREET_1 VARCHAR(20) NOT NULL,
  W_STREET_2 VARCHAR(20) NOT NULL,
  W_CITY VARCHAR(20) NOT NULL,
  W_STATE CHAR(2) NOT NULL,
  W_ZIP CHAR(9) NOT NULL,
  PRIMARY KEY (W_ID)
);

-- INDEXES
CREATE INDEX IDX_CUSTOMER_NAME ON CUSTOMER (C_W_ID,C_D_ID,C_LAST,C_FIRST);

-- woohak, add constraints. MySQL/InnoDB storage engine is kind of IoT.
-- and add constraints and make indexes later aretoo slow when running a single thread.
-- so I just add create index and foreign key constraints before loading data.

-- already created
-- CREATE INDEX IDX_CUSTOMER ON CUSTOMER (C_W_ID,C_D_ID,C_LAST,C_FIRST);
CREATE INDEX IDX_ORDER ON OORDER (O_W_ID,O_D_ID,O_C_ID,O_ID);
-- tpcc-mysql create two indexes for the foreign key constraints, Is it really necessary?
-- CREATE INDEX FKEY_STOCK_2 ON STOCK (S_I_ID);
-- CREATE INDEX FKEY_ORDER_LINE_2 ON ORDER_LINE (OL_SUPPLY_W_ID,OL_I_ID);

-- add 'ON DELETE CASCADE'  to clear table work correctly

ALTER TABLE DISTRICT  ADD CONSTRAINT FKEY_DISTRICT_1 FOREIGN KEY(D_W_ID) REFERENCES WAREHOUSE(W_ID) ON DELETE CASCADE;
ALTER TABLE CUSTOMER ADD CONSTRAINT FKEY_CUSTOMER_1 FOREIGN KEY(C_W_ID,C_D_ID) REFERENCES DISTRICT(D_W_ID,D_ID)  ON DELETE CASCADE ;
ALTER TABLE HISTORY  ADD CONSTRAINT FKEY_HISTORY_1 FOREIGN KEY(H_C_W_ID,H_C_D_ID,H_C_ID) REFERENCES CUSTOMER(C_W_ID,C_D_ID,C_ID) ON DELETE CASCADE;
ALTER TABLE HISTORY  ADD CONSTRAINT FKEY_HISTORY_2 FOREIGN KEY(H_W_ID,H_D_ID) REFERENCES DISTRICT(D_W_ID,D_ID) ON DELETE CASCADE;
ALTER TABLE NEW_ORDER ADD CONSTRAINT FKEY_NEW_ORDER_1 FOREIGN KEY(NO_W_ID,NO_D_ID,NO_O_ID) REFERENCES OORDER(O_W_ID,O_D_ID,O_ID) ON DELETE CASCADE;
ALTER TABLE OORDER ADD CONSTRAINT FKEY_ORDER_1 FOREIGN KEY(O_W_ID,O_D_ID,O_C_ID) REFERENCES CUSTOMER(C_W_ID,C_D_ID,C_ID) ON DELETE CASCADE;
ALTER TABLE ORDER_LINE ADD CONSTRAINT FKEY_ORDER_LINE_1 FOREIGN KEY(OL_W_ID,OL_D_ID,OL_O_ID) REFERENCES OORDER(O_W_ID,O_D_ID,O_ID) ON DELETE CASCADE;
ALTER TABLE ORDER_LINE ADD CONSTRAINT FKEY_ORDER_LINE_2 FOREIGN KEY(OL_SUPPLY_W_ID,OL_I_ID) REFERENCES STOCK(S_W_ID,S_I_ID) ON DELETE CASCADE;
ALTER TABLE STOCK ADD CONSTRAINT FKEY_STOCK_1 FOREIGN KEY(S_W_ID) REFERENCES WAREHOUSE(W_ID) ON DELETE CASCADE;
ALTER TABLE STOCK ADD CONSTRAINT FKEY_STOCK_2 FOREIGN KEY(S_I_ID) REFERENCES ITEM(I_ID) ON DELETE CASCADE;


SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;

1.2.2. 검증

src/com/oltpbenchmark/benchmarks/tpcc/TPCCBenchmark.java 를 보면 update sql을 내장프로시져로 생성해서 실행한다.

TiDB는 내장 프로시져를 지원하지 않으므로, tpcc를 이용해서 TiDB의 TPC-C 테스트를 진행할 수 없다는 결론이 난다.

   // This function creates SQL procedures that the execution would need. Currently we have
   // procedures only to update the Stock table.
   public void createSqlProcedures() throws Exception {
     try {
       Connection conn = makeConnection();
       Statement st = conn.createStatement();

       StringBuilder argsSb = new StringBuilder();
       StringBuilder updateStatements = new StringBuilder();

       argsSb.append("wid int");
       for (int i = 1; i <= 15; ++i) {
         argsSb.append(String.format(", i%d int, q%d int, y%d int, r%d int", i, i, i, i));
         updateStatements.append(String.format(
               "UPDATE STOCK SET S_QUANTITY = q%d, S_YTD = y%d, S_ORDER_CNT = S_ORDER_CNT + 1, " +
               "S_REMOTE_CNT = r%d WHERE S_W_ID = wid AND S_I_ID = i%d;",
               i, i, i, i));
         String updateStmt =
           String.format("CREATE PROCEDURE updatestock%d (%s) AS '%s' LANGUAGE SQL;",
               i, argsSb.toString(), updateStatements.toString());

         st.execute(String.format("DROP PROCEDURE IF EXISTS updatestock%d", i));
         st.execute(updateStmt);
       }
     } catch (SQLException se) {
       LOG.error(se.getMessage());
       throw se;
     }
}

1.2.3. yugabyteDB 테스트

신뢰있는 테스트이나, benchmarksql의 결과와 직접적으로 비교하여 결론 것은 좋지 않다.

아래는 설정이다.

warehouses: 10
terminals: 100
dbConnections: 10
loaderThreads: 10

1.2.3.1. Load data

loading 시간은 대략 6분이 걸렸다.

$ ./tpccbenchmark --create=true --load=true
16:51:01,798 (DBWorkload.java:359) INFO  - Configuration -> nodes: [127.0.0.1], port: 5433, startWH: 1, warehouses: 10, total warehouses across shards: 10, terminals: 100, dbConnections: 10, loaderThreads: 10
16:51:02,053 (DBWorkload.java:390) INFO  - ======================================================================

Benchmark:     TPCC {com.oltpbenchmark.benchmarks.tpcc.TPCCBenchmark}
Configuration: config/workload_all.xml
Type:          POSTGRES
Driver:        org.postgresql.Driver
URL:           [127.0.0.1]
Isolation:     TRANSACTION_REPEATABLE_READ
Scale Factor:  10

16:51:02,053 (DBWorkload.java:391) INFO  - ======================================================================
16:51:02,071 (DBWorkload.java:668) INFO  - Creating new TPCC database...
16:51:17,839 (DBWorkload.java:671) INFO  - Finished!
16:51:17,839 (DBWorkload.java:672) INFO  - ======================================================================
16:51:17,840 (DBWorkload.java:695) INFO  - Loading data into TPCC database with 10 threads...
16:57:11,893 (DBWorkload.java:699) INFO  - Finished!
16:57:11,896 (DBWorkload.java:700) INFO  - ======================================================================
16:57:11,896 (DBWorkload.java:756) INFO  - Skipping benchmark workload execution
1.2.3.2. TPC-C 실행
TPM-C: 128.47

$ ./tpccbenchmark --execute=true
17:05:53,105 (DBWorkload.java:359) INFO  - Configuration -> nodes: [127.0.0.1], port: 5433, startWH: 1, warehouses: 10, total warehouses across shards: 10, terminals: 100, dbConnections: 10, loaderThreads: 10
[main] INFO com.zaxxer.hikari.HikariDataSource - HikariPool-1 - Starting...
[main] INFO com.zaxxer.hikari.HikariDataSource - HikariPool-1 - Start completed.
17:05:54,682 (DBWorkload.java:390) INFO  - ======================================================================

Benchmark:     TPCC {com.oltpbenchmark.benchmarks.tpcc.TPCCBenchmark}
Configuration: config/workload_all.xml
Type:          POSTGRES
Driver:        org.postgresql.Driver
URL:           [127.0.0.1]
Isolation:     TRANSACTION_REPEATABLE_READ
Scale Factor:  10

17:05:54,682 (DBWorkload.java:391) INFO  - ======================================================================
17:05:54,695 (DBWorkload.java:999) INFO  - Creating 100 virtual terminals...
17:05:54,728 (DBWorkload.java:1005) INFO  - Launching the TPCC Benchmark with 1 Phase...
17:05:54,739 (ThreadBench.java:342) INFO  - PHASE START :: [Workload=TPCC] [Serial=false] [Time=1800] [WarmupTime=0] [Rate=10000] [Arrival=REGULAR] [Ratios=[45.0, 43.0, 4.0, 4.0, 4.0]] [ActiveWorkers=100]
17:05:54,740 (ThreadBench.java:493) INFO  - MEASURE :: Warmup complete, starting measurements.
17:35:54,717 (ThreadBench.java:448) INFO  - TERMINATE :: Waiting for all terminals to finish ..
17:37:41,963 (ThreadBench.java:509) INFO  - Attempting to stop worker threads and collect measurements
17:37:41,964 (ThreadBench.java:247) INFO  - Starting WatchDogThread
17:37:41,980 (DBWorkload.java:1021) INFO  - ======================================================================
17:37:41,985 (DBWorkload.java:1028) INFO  - Throughput: Results(nanoSeconds=1800000081765, measuredRequests=8510) = 4.727777563018481 requests/sec reqs/sec
17:37:41,987 (DBWorkload.java:1029) INFO  - Num New Order transactions : 3854, time seconds: 1800
17:37:41,988 (DBWorkload.java:1030) INFO  - TPM-C: 128.47
17:37:41,988 (DBWorkload.java:1031) INFO  - Efficiency : 99.9%
17:37:41,996 (DBWorkload.java:1064) INFO  - NewOrder, Avg Latency: 11.127690531776912 msecs, p99 Latency: 16.954 msecs
17:37:41,999 (DBWorkload.java:1064) INFO  - Payment, Avg Latency: 7.813994399327919 msecs, p99 Latency: 9.957 msecs
17:37:41,999 (DBWorkload.java:1064) INFO  - OrderStatus, Avg Latency: 4.841972527472528 msecs, p99 Latency: 92.185 msecs
17:37:41,999 (DBWorkload.java:1064) INFO  - Delivery, Avg Latency: 26.912194029850745 msecs, p99 Latency: 88.084 msecs
17:37:41,999 (DBWorkload.java:1064) INFO  - StockLevel, Avg Latency: 51.39495064935065 msecs, p99 Latency: 115.059 msecs
17:37:42,001 (DBWorkload.java:859) INFO  - Output Raw data into file: results/oltpbench.csv

1.2.4. TiDB (mysql) 으로 TPCC 실행 시 문제

mysql jdbc 드라이버로 접속하지 않는 문제

  • Stored procedure를 사용하는 문제 (TiDB에서 지원하지 않음)
  • useStoredProcedures를 false로 지정했으나 내부적으로 사용함
    위 사항들이 문제가 있었다. 소스코드를 수정하여 해결. (git에 변경사항을 기입했음)

1.2.5. 수정사항

mysql 용 tpcc 설정파일 수정
tidb/yugabyte용 tpcc 설정파일 추가
테스트 실행 후, 결과물을 디렉토리 하에 저장 (result_<datetime>/)
커맨드 라인 을 저장한 파일
stdout 출력내용을 저장
시험 자체 결과

$ ll result_20210216_18.53.24/
total 4272
drwxr-xr-x   5 sonumb  staff      160  2 16 18:55 ./
drwxr-xr-x  33 sonumb  staff     1056  2 16 18:54 ../
-rw-r--r--   1 sonumb  staff       55  2 16 18:54 cmd_line.txt
-rw-r--r--   1 sonumb  staff  2176763  2 16 18:54 oltpbench.csv
-rw-r--r--   1 sonumb  staff     1823  2 16 18:54 stdout.txt

1.3. oltpbench

https://github.com/oltpbenchmark/oltpbench에 TiDB/YugabyteDB 테스트를 위한 변경/추가 작업을
http:///github.com/sarang2dan/oltpbench 에 기록하였다.

2. 환경설정 및 실행

YugabyteDB 홈페이지에서 설치 및 생성을 참조하여 yugabytedb를 설치 및 스탠드얼론으로 실행시킨다.

참고로, yugabyte는 postgres 프로토콜을 사용한다.

다만, postgres의 클라이언트 접속 포트의 기본값은 5432 인데, yugabytedb는 5433이다.

2.1. 사용자 생성 및 DB생성

$ ysqlsh
CREATE USER benchmarksql WITH ENCRYPTED PASSWORD 'changeme';
CREATE DATABASE benchmarksql OWNER benchmarksql;
\q

PostgreSQL 명령어

데이터 베이스 리스트: \l (참고로 프롬프트에는 접속한 데이터베이스 이름이 출력)

postgres-# \l
                                     List of databases
      Name       |    Owner     | Encoding | Collate |    Ctype    |   Access privileges
-----------------+--------------+----------+---------+-------------+-----------------------
 benchmarksql    | benchmarksql | UTF8     | C       | en_US.UTF-8 |
 postgres        | postgres     | UTF8     | C       | en_US.UTF-8 |
 system_platform | postgres     | UTF8     | C       | en_US.UTF-8 |
 template0       | postgres     | UTF8     | C       | en_US.UTF-8 | =c/postgres          +
                 |              |          |         |             | postgres=CTc/postgres
 template1       | postgres     | UTF8     | C       | en_US.UTF-8 | =c/postgres          +
                 |              |          |         |             | postgres=CTc/postgres
 yb_demo         | yugabyte     | UTF8     | C       | en_US.UTF-8 |
 yugabyte        | postgres     | UTF8     | C       | en_US.UTF-8 |
(7 rows)

데이터베이스 변경: \c

postgres-# \c benchmarksql
You are now connected to database "benchmarksql" as user "yugabyte".

테이블 보기: \dt (\dt+ 크기와 설명도 출력)

benchmarksql-# \dt
                List of relations
 Schema |       Name       | Type  |    Owner
--------+------------------+-------+--------------
 public | bmsql_config     | table | benchmarksql
 public | bmsql_district   | table | benchmarksql
 public | bmsql_item       | table | benchmarksql
 public | bmsql_new_order  | table | benchmarksql
 public | bmsql_order_line | table | benchmarksql
 public | bmsql_stock      | table | benchmarksql
 public | bmsql_warehouse  | table | benchmarksql
(7 rows)

benchmarksql=# \dt+
                            List of relations
 Schema |       Name       | Type  |    Owner     |  Size   | Description
--------+------------------+-------+--------------+---------+-------------
 public | bmsql_config     | table | benchmarksql | 0 bytes |
 public | bmsql_customer   | table | benchmarksql | 0 bytes |
 public | bmsql_district   | table | benchmarksql | 0 bytes |
 public | bmsql_history    | table | benchmarksql | 0 bytes |
 public | bmsql_item       | table | benchmarksql | 0 bytes |
 public | bmsql_new_order  | table | benchmarksql | 0 bytes |
 public | bmsql_oorder     | table | benchmarksql | 0 bytes |
 public | bmsql_order_line | table | benchmarksql | 0 bytes |
 public | bmsql_stock      | table | benchmarksql | 0 bytes |
 public | bmsql_warehouse  | table | benchmarksql | 0 bytes |
(10 rows)

benchmarksql=#

테이블 스키마: desc 명령어 없음.

SELECT 
   table_name, 
   column_name, 
   data_type 
FROM 
   information_schema.columns
WHERE 
   table_name = 'table_name';

TiDB 용 tpc-c 를 다운받고, 빌드 및 설정한다.

빌드하기 위해서 ant 설치를 먼저해야 한다.

cf) IntelliJ가 설치되어 있다면, ant 설치과정은 필요없이 내장된 ant로 빌드 가능하다.

git clone -b 5.0-mysql-support-opt-2.1 https://github.com/pingcap/benchmarksql.git
cd benchmarksql
ant   # 빌드 수행, 혹은 intelliJ에서 빌드
cd run && cp props.pg my_postgres.properties
./runDatabaseBuild.sh my_postgres.properties
my_postgres.properties파일의 conn 문자열에서, 포트번호를 5432를 5433으로 변경한다.

vi my_postgres.properties
conn=jdbc:postgresql://localhost:5433/postgres

동일 디렉토리 하에서 실행해보자

./runDatabaseBuild.sh my_postgres.properties

에러가 발생할 것이다.

YugabyteDB는 'ALTER TABLE ... ADD CONSTRAINT ... PRIMARY KEY ... ;' 구문이 지원되지 않는다.

따라서 ADD PRIMARY KEY는 CREATE UNIQUE INDEX로 대체되어야 한다.

# ------------------------------------------------------------
# Loading SQL file ./sql.common/tableCreates.sql
# ------------------------------------------------------------
create table bmsql_config (
cfg_name    varchar(30) primary key,
cfg_value   varchar(50)
);
create table bmsql_warehouse (

... 생략 ...

# ------------------------------------------------------------
# Loading SQL file ./sql.common/indexCreates.sql
# ------------------------------------------------------------
alter table bmsql_warehouse add constraint bmsql_warehouse_pkey
primary key (w_id);
ERROR: This ALTER TABLE command is not yet supported.

alter table bmsql_district add constraint bmsql_district_pkey
primary key (d_w_id, d_id);
ERROR: This ALTER TABLE command is not yet supported.

alter table bmsql_customer add constraint bmsql_customer_pkey
primary key (c_w_id, c_d_id, c_id);
ERROR: This ALTER TABLE command is not yet supported.

create index bmsql_customer_idx1
on  bmsql_customer (c_w_id, c_d_id, c_last, c_first);

alter table bmsql_oorder add constraint bmsql_oorder_pkey
primary key (o_w_id, o_d_id, o_id);
ERROR: This ALTER TABLE command is not yet supported.

create unique index bmsql_oorder_idx1
on  bmsql_oorder (o_w_id, o_d_id, o_carrier_id, o_id);

alter table bmsql_new_order add constraint bmsql_new_order_pkey
primary key (no_w_id, no_d_id, no_o_id);
ERROR: This ALTER TABLE command is not yet supported.

alter table bmsql_order_line add constraint bmsql_order_line_pkey
primary key (ol_w_id, ol_d_id, ol_o_id, ol_number);
ERROR: This ALTER TABLE command is not yet supported.

alter table bmsql_stock add constraint bmsql_stock_pkey
primary key (s_w_id, s_i_id);
ERROR: This ALTER TABLE command is not yet supported.

alter table bmsql_item add constraint bmsql_item_pkey
primary key (i_id);
ERROR: This ALTER TABLE command is not yet supported.

# ------------------------------------------------------------
# Loading SQL file ./sql.common/foreignKeys.sql
# ------------------------------------------------------------
alter table bmsql_district add constraint d_warehouse_fkey
foreign key (d_w_id)
references bmsql_warehouse (w_id);
ERROR: there is no unique constraint matching given keys for referenced table "bmsql_warehouse"
alter table bmsql_customer add constraint c_district_fkey
foreign key (c_w_id, c_d_id)
references bmsql_district (d_w_id, d_id);
ERROR: there is no unique constraint matching given keys for referenced table "bmsql_district"
alter table bmsql_history add constraint h_customer_fkey
foreign key (h_c_w_id, h_c_d_id, h_c_id)
references bmsql_customer (c_w_id, c_d_id, c_id);
ERROR: there is no unique constraint matching given keys for referenced table "bmsql_customer"
alter table bmsql_history add constraint h_district_fkey
foreign key (h_w_id, h_d_id)
references bmsql_district (d_w_id, d_id);
ERROR: there is no unique constraint matching given keys for referenced table "bmsql_district"
alter table bmsql_new_order add constraint no_order_fkey
foreign key (no_w_id, no_d_id, no_o_id)
references bmsql_oorder (o_w_id, o_d_id, o_id);
ERROR: there is no unique constraint matching given keys for referenced table "bmsql_oorder"
alter table bmsql_oorder add constraint o_customer_fkey
foreign key (o_w_id, o_d_id, o_c_id)
references bmsql_customer (c_w_id, c_d_id, c_id);
ERROR: there is no unique constraint matching given keys for referenced table "bmsql_customer"
alter table bmsql_order_line add constraint ol_order_fkey
foreign key (ol_w_id, ol_d_id, ol_o_id)
references bmsql_oorder (o_w_id, o_d_id, o_id);
ERROR: there is no unique constraint matching given keys for referenced table "bmsql_oorder"
alter table bmsql_order_line add constraint ol_stock_fkey
foreign key (ol_supply_w_id, ol_i_id)
references bmsql_stock (s_w_id, s_i_id);
ERROR: there is no unique constraint matching given keys for referenced table "bmsql_stock"
alter table bmsql_stock add constraint s_warehouse_fkey
foreign key (s_w_id)
references bmsql_warehouse (w_id);
ERROR: there is no unique constraint matching given keys for referenced table "bmsql_warehouse"
alter table bmsql_stock add constraint s_item_fkey
foreign key (s_i_id)
references bmsql_item (i_id);
ERROR: there is no unique constraint matching given keys for referenced table "bmsql_item"
# ------------------------------------------------------------
# Loading SQL file ./sql.postgres/extraHistID.sql
# ------------------------------------------------------------
-- ----
-- Extra Schema objects/definitions for history.hist_id in PostgreSQL
-- ----
-- ----
--      This is an extra column not present in the TPC-C
--      specs. It is useful for replication systems like
--      Bucardo and Slony-I, which like to have a primary
--      key on a table. It is an auto-increment or serial
--      column type. The definition below is compatible
--      with Oracle 11g, using a sequence and a trigger.
-- ----
-- Adjust the sequence above the current max(hist_id)
select setval('bmsql_hist_id_seq', (select max(hist_id) from bmsql_history));
-- Make nextval(seq) the default value of the hist_id column.
alter table bmsql_history
alter column hist_id set default nextval('bmsql_hist_id_seq');
-- Add a primary key history(hist_id)
alter table bmsql_history add primary key (hist_id);
ERROR: This ALTER TABLE command is not yet supported.
# ------------------------------------------------------------
# Loading SQL file ./sql.postgres/buildFinish.sql
# ------------------------------------------------------------
-- ----
-- Extra commands to run after the tables are created, loaded,
-- indexes built and extra's created.
-- PostgreSQL version.
-- ----
vacuum analyze;

2.1. benchmarksql

2.1.1. Yugabyte 세팅

아래에 언급되는 내용은 웬만하면 benchmarksql 리파지터리에 모두 적용되어 있으므로 크게 신경 쓰지 않아도 된다.

2.1.2. JDBC 드라이버

tpcc git repository의 lib 폴더에서 jdbc-yugabytedb-version.jar 를 찾을 수 있다. 이 파일을 benchmarksql/libs 폴더에 복사해야 한다.

 ~/work/tpcc/lib
$ ls *yuga*
jdbc-yugabytedb-42.2.7-yb-3.jar
$ cp jdbc-yugabytedb-42.2.7-yb-3.jar ~/work/benchmarksql/lib/

2.1.3. 컨넥션 스트링 세팅

테스트를 위해 성능을 향상시키거나 버퍼를 조정한다는지 특정 프로퍼티를 사용할 수 있다. 아래 링크를 참조하라.

https://github.com/yugabyte/jdbc-yugabytedb/blob/master/docs/documentation/93/connect.md

2.2. tpcc

oltpbenchmark 슈트에서 파생된 버전. 노드 정보를 주어서 접근하는 기능이 추가됨.

oltpbenchmark 와 비슷하므로 생략.

다만, yugabytedb의 특성상, SQL 처리하는 서버에 대한 게이트웨이가 없다.

따라서 TPC 테스트도 yb-tserver 클러스터를 구성하는 노드들의 정보를 아래와 같이 주어줘야 한다.

--nodes=10.10.1.2,10.10.1.3,10.10.1.4,10.10.1.5

2.3. oltpbenchmark

tpcc 슈트의 전신이다. tpcc 섹션에서 언급한 노드 정보를 주어서 접근하는 기능은 없다.

2.3.1. 사용법

usage: oltpbenchmark
 -b,--bench <arg>               [required] Benchmark class. Currently
                                supported: [tpcc, tpch, tatp, wikipedia,
                                resourcestresser, twitter, epinions, ycsb,
                                jpab, seats, auctionmark, chbenchmark,
                                voter, linkbench, sibench, noop,
                                smallbank, hyadapt]
 -c,--config <arg>              [required] Workload configuration file
    --clear <arg>               Clear all records in the database for this
                                benchmark
    --create <arg>              Initialize the database for this benchmark
 -d,--directory <arg>           Base directory for the result files,
                                default is current directory
    --dialects-export <arg>     Export benchmark SQL to a dialects file
    --execute <arg>             Execute the benchmark workload
 -h,--help                      Print this help
    --histograms                Print txn histograms
 -im,--interval-monitor <arg>   Throughput Monitoring Interval in
                                milliseconds
 -jh,--json-histograms <arg>    Export histograms to JSON file
    --load <arg>                Load data using the benchmark's data
                                loader
 -o,--output <arg>              Output file (default System.out)
    --output-raw <arg>          Output raw data
    --output-samples <arg>      Output sample data
    --runscript <arg>           Run an SQL script
 -s,--sample <arg>              Sampling window
 -ss                            Verbose Sampling per Transaction
 -t,--timestamp                 Each result file is prepended with a
                                timestamp for the beginning of the
                                experiment
 -ts,--tracescript <arg>        Script of transactions to execute
    --upload <arg>              Upload the result
    --uploadHash <arg>          git hash to be associated with the upload
 -v,--verbose                   Display Messages

2.3.2. 데이터 구성

2.3.2.1. command

$ ./oltpbenchmark -b tpcc -c config/tpcc_config_ds5_yugabyte.xml --create=true --load=true

3. 테스트

3.1. 개요

TiDB와 YugabyteDB 가각에 대한 TPC-C 테스트로, 수정된 oltpbenchmark와 tpcc 를 이용한다.

이유는 세 가지다.

  • 테스트 코드가 태생적으로 같은 소스코드를 쓴다.
  • tpcc는 YugabyteDB를 테스트하기 위해, yb-tserver 클러스터 노드들의 IP를 넘겨주는 기능이 더해짐
  • benchmarksql에 yugabytedb를 테스트하기 위한 ip 기능을 구현하는 것은 많은 노력이 든다.

3.2. 환경

서버를 네개로 구성하였다.  스펙은 네대 모두 동일하다.

 

  • cpu: Intel(R) Xeon(R) CPU           E5645  @ 2.40GHz
  • mem: 64GB
  • storage: scsi 하드를 raid 구성 (raid 레벨은 모르겠음)
  • NIC: 1Gbps

3.2.1. 데이터

TPC문서에서 TPC-C 테이블 구성을 확인바람.

3.2.2. 변수들

참고문서: OLTP서버 성능측정 및 규모산정을 위한 벤치마크 기준에 대한 고찰

https://www.koreascience.or.kr/article/JAKO200934939597678.pdf

3.2.2.1. 통제변수

변수명설명값

변수명 설명
KeyingTime 트랜잭션을 처리하는 과정의 여유 시간:
터미널에서 키(데이터)를 삽입에 소요되는 시간
false
Think Time

트랜잭션을 처리하는 과정의 여유 시간:
사용자가 트랜잭션 중간결과를 보고 생각하는 시간

false
useStoredProcedures 스토어 프로시져를 이용해서 DML 수행하겠는가? false
isolation level 트랜잭션 고립성 레벨 TRANSACTION_READ_COMMITTED
work.time TPC-C 가 구동되는 시간 180초 (3분)
work.rate work.time 동안 발생될 수 있는 트랜잭션 수 unlimited
batchSize commit당 처리하는 트랜잭션 수 500

3.2.2.2. 조작 변수

3.2.2.2.1. TPCC 데이터셋 생성 및 로딩
변수명 설명 도메인 통제변인
warehouses 창고의 수 1, 10, 20, 30

Loader Thread: 16개

3.2.2.2.2. TPCC 트랜잭션 처리 테스트
변수명 설명 도메인 통제변인
warehouses 창고의 수 1, 10, 20, 30 terminal: 16개
terminal

주문을 넣는 가상 클라이언트의 수

1, 8, 16, 32, 64 warehouse: 10개

3.2.3. 측정결과값 (종속변인)

항목 단위
데이터베이스 생성 및 로딩 sec
처리량(Throughput) 요청/sec
TPM-C (New Order 트랜잭션 처리수/minute)

3.3. 스크립트

msec 단위의 현재시간을 얻기위해 date 를 사용한다.

그런데, Mac에서는 나노초 단위로 출력하는 "%N" 포맷을 지원하지 않는다.

따라서, brew로 gnu coreutils를 받아서 해결하였으나, 아래와 같이 perl을 이용해서 msec을 얻을 수 있다.

perl -MTime::HiRes -e 'printf("%.0f\\n",Time::HiRes::time()\*1000)'

3.3.1. YugabyteDB

tpccbenchmark_all

#!/bin/bash

date_path=
OS=`uname -s`
if [[ "$OS" == "Darwin" ]]; then
  if [[ ! -f /usr/local/opt/coreutils/libexec/gnubin/date ]]; then
    echo "PLZ INSTALL 'date'"
    echo "    $ brew install coreutils"
    exit
  else
    date_path=/usr/local/opt/coreutils/libexec/gnubin/
  fi
fi


TEST_DIR=`pwd`

host=ds5
dbms=yuga
test_time=`date +"%m%d.%H%M%S"`

TPCC=$TEST_DIR/tpccbenchmark
CONF=$TEST_DIR/config/${host}_${dbms}_${t}_${w}.xml

node_list="10.10.1.32,10.10.1.33,10.10.1.34,10.10.1.35"
#node_list="127.0.0.1"
terminal_cnt="1 8 16 32 64"
warehouse_cnt="1 10 20 30"
#terminal_cnt="1"
#warehouse_cnt="1"

tseq=1
function print_line() {
  echo "#########################################################################"
  echo "######### $tseq. $1 ############"
  echo "#########################################################################"
  tseq=$(($tseq + 1))
}

function get_curtime_msec() {
  echo `${date_path}date +"%s%3N"`
}

function get_elapsed_sec() {
  _start=$1
  _end=$2
  _elapsed=`echo "scale=2; (${_end} - ${_start}) / 1000" | bc -l`
  echo ${_elapsed}
}

function get_tpmc() {
  grep "TPM-C" $1 | awk '{print $6}'
}

function get_req_per_sec() {
  grep "reqs\/sec" $1 | awk '{print $9}'
}

function get_conf_file() {
  t=$1 # terminal count
  w=$2 # warehouse count
  CONF=$TEST_DIR/config/${host}_${dbms}_${t}_${w}.xml
  echo $CONF
}

result_path=$TEST_DIR/res_${test_time}
result_file=${result_path}/result.txt
mkdir -p $result_path
touch ${result_file}

#########################################################################
print_line "loading DB 테스트"
#########################################################################
# terminal 수 출력
t=16  # loading 테스트에서는 terminal 수는 16으로 고정
printf "term_l\t%d\n" $t | tee -a ${result_file}
for w in $warehouse_cnt;
do
  # conf 파일 지정
  CONF=`(get_conf_file $t $w)`

  # 시작 시간 획득
  start_time=`(get_curtime_msec)`

  # DB create & loading  수행
  echo "$TPCC -c $CONF --create=true --load=true --nodes=${node_list}"
  $TPCC -c $CONF --create=true --load=true --nodes=${node_list}

  # 종료 시간 획득
  end_time=`(get_curtime_msec)`

  # 경과 시간 계산 및 출력
  elapsed=`(get_elapsed_sec ${start_time} ${end_time})`
  printf "%d\t%s\n" $w  $elapsed | tee -a ${result_file}
done
echo "" >> ${result_file}


#########################################################################
print_line "트랜잭션 처리 테스트 - 터미널 개수 고정, 웨어하우스 변경"
#########################################################################
# terminal 수 출력
t=16  # terminal 수는 16으로 고정
printf "term_e\t%d\n" $t | tee -a ${result_file}
for w in $warehouse_cnt;
do
  # conf 파일 지정
  CONF=`(get_conf_file $t $w)`

  # DB create & loading  수행
  echo "$TPCC -c $CONF --create=true --load=true --nodes=${node_list}"
  $TPCC -c $CONF --create=true --load=true --nodes=${node_list}

  # 트랜잭션 실행
  echo "$TPCC -c $CONF --execute=true --nodes=${node_list} | tee ${result_path}/tmp"
  $TPCC -c $CONF --execute=true --nodes=${node_list} | tee ${result_path}/tmp

  # 분단요청수 획득
  reqsec_val=`(get_req_per_sec ${result_path}/tmp)`

  # TPM-C  획득
  tpmc_val=`(get_tpmc ${result_path}/tmp)`


  # 결과 출력
  printf "%s\t%s\t%s\n" $w ${reqsec_val} ${tpmc_val} | tee -a ${result_file}
done
echo "" >> ${result_file}


#########################################################################
print_line "트랜잭션 처리 테스트 - 터미널 개수 변경,  웨어하우스 고정"
#########################################################################
# terminal 수 출력
w=10  # warehouse 수는 10으로 고정
printf "ware_e\t%d\n" $w | tee -a ${result_file}
for t in $terminal_cnt;
do
  # conf 파일 지정
  CONF=`(get_conf_file $t $w)`

  # DB create & loading  수행
  echo "$TPCC -c $CONF --create=true --load=true --nodes=${node_list}"
  $TPCC -c $CONF --create=true --load=true --nodes=${node_list}

  # 트랜잭션 실행
  echo "$TPCC -c $CONF --execute=true --nodes=${node_list} | tee ${result_path}/tmp"
  $TPCC -c $CONF --execute=true --nodes=${node_list} | tee ${result_path}/tmp

  # 분당 요청수 획득
  reqsec_val=`(get_req_per_sec ${result_path}/tmp)`

  # TPM-C  획득
  tpmc_val=`(get_tpmc ${result_path}/tmp)`

  # 결과 출력
  printf "%s\t%s\t%s\n" $t ${reqsec_val} ${tpmc_val} | tee -a ${result_file}
done
echo "" >> ${result_file}

3.3.2. TiDB

oltpbenchmark_all

#!/bin/bash
memory='8G'

date_path=
OS=`uname -s`
if [[ "$OS" == "Darwin" ]]; then
  if [[ ! -f /usr/local/opt/coreutils/libexec/gnubin/date ]]; then
    echo "PLZ INSTALL 'date'"
    echo "    $ brew install coreutils"
    exit
  else
    date_path=/usr/local/opt/coreutils/libexec/gnubin/
  fi
fi


TEST_DIR=`pwd`

host=ds6
dbms=tidb
test_time=`date +"%m%d.%H%M%S"`

TPCC_LOAD="$TEST_DIR/runDatabaseBuild.sh"
TPCC_EXEC="$TEST_DIR/runBenchmark.sh"
#CONF=$TEST_DIR/config/tpcc_config_${host}_${dbms}_$t_$w.xml

terminal_cnt="1 8 16 32 64"
warehouse_cnt="1 10 20 30"
#terminal_cnt="8"
#warehouse_cnt="20"


tseq=1
function print_line() {
  echo "#########################################################################"
  echo "######### $tseq. $1 ############"
  echo "#########################################################################"
  tseq=$(($tseq + 1))
}

function get_curtime_msec() {
  echo `${date_path}date +"%s%3N"`
}

function get_elapsed_sec() {
  _start=$1
  _end=$2
  _elapsed=`echo "scale=2; (${_end} - ${_start}) / 1000" | bc -l`
  echo ${_elapsed}
}

function get_tpmc() {
  grep "Measured tpmC" $1  | cut -d'=' -f2
  #grep "TPM-C" $1 | awk '{print $6}'
}

function get_req_per_sec() {
  grep "reqs\/sec" $1 | awk '{print $9}'
}

function get_conf_file() {
  t=$1 # terminal count
  w=$2 # warehouse count
  # props.ds6_tidb_16_30.cfg
  CONF=$TEST_DIR/props.${host}_${dbms}_${t}_${w}.cfg
  echo $CONF
}

function recreate_database() {
  mysql -h 10.10.1.33 -P4000 -uroot <<< "drop database if exists tpcc; create database tpcc;"
}

result_path=$TEST_DIR/res_${test_time}
result_file=${result_path}/result.txt
mkdir -p $result_path
touch ${result_file}

#########################################################################
print_line "loading DB 테스트"
#########################################################################
t=16  # loading 테스트에서는 terminal 수는 16으로 고정
printf "term_l\t%d\n" $t | tee -a ${result_file}
for w in $warehouse_cnt;
do
  recreate_database
  # conf 파일 지정
  CONF=`(get_conf_file $t $w)`

  # 시작 시간 획득
  start_time=`(get_curtime_msec)`

  # DB create & loading  수행
  echo "$TPCC_LOAD $CONF"
  $TPCC_LOAD $CONF

  # 종료 시간 획득
  end_time=`(get_curtime_msec)`

  elapsed=`(get_elapsed_sec ${start_time} ${end_time})`
  printf "%d\t%s\n" $w  $elapsed | tee -a ${result_file}
done
echo "" >> ${result_file}


#########################################################################
print_line "트랜잭션 처리 테스트 - 터미널 개수 고정, 웨어하우스 변경"
#########################################################################
t=16  # terminal 수는 16으로 고정
printf "term_e\t%d\n" $t | tee -a ${result_file}
for w in $warehouse_cnt;
do
  recreate_database
  # conf 파일 지정
  CONF=`(get_conf_file $t $w)`

  # DB create & loading  수행
  echo "$TPCC_LOAD $CONF"
  $TPCC_LOAD $CONF

  # 트랜잭션 실행
  echo "$TPCC_EXEC $CONF"
  $TPCC_EXEC $CONF | tee ${result_path}/tmp

  # 분단요청수 획득
  #reqsec_val=`(get_req_per_sec ${result_path}/tmp)`

  # TPM-C 획득
  tpmc_val=`(get_tpmc ${result_path}/tmp)`

  printf "%s\t%s\n" $w ${tpmc_val} | tee -a ${result_file}
  #printf "%s\t%s\t%s\n" $w ${reqsec_val} ${tpmc_val} | tee -a ${result_file}
done
echo "" >> ${result_file}


#########################################################################
print_line "트랜잭션 처리 테스트 - 터미널 개수 변경,  웨어하우스 고정"
#########################################################################
w=10  # warehouse 수는 10으로 고정
printf "ware_e\t%d\n" $w | tee -a ${result_file}
for t in $terminal_cnt;
do
  recreate_database
  # conf 파일 지정
  CONF=`(get_conf_file $t $w)`

  # DB create & loading  수행
  echo "$TPCC_LOAD $CONF"
  $TPCC_LOAD $CONF

  # 트랜잭션 실행
  echo "$TPCC_EXEC $CONF"
  $TPCC_EXEC $CONF | tee ${result_path}/tmp

  # 분단요청수 획득
  #reqsec_val=`(get_req_per_sec ${result_path}/tmp)`

  # TPM-C  획득
  tpmc_val=`(get_tpmc ${result_path}/tmp)`

  printf "%s\t%s\n" $t ${tpmc_val} | tee -a ${result_file}
  #printf "%s\t%s\t%s\n" $w ${reqsec_val} ${tpmc_val} | tee -a ${result_file}
done
echo "" >> ${result_file}

3.4. 결과

3.4.1. 테이블 및 그래프

3.4.1.1. 1번 TPCC 데이터셋 생성 및 로딩 실험

단위: sec (낮을 수록 좋은 것)

웨어하우스 수 YugabyteDB TiDB

1

164.40

128.13

10

253.56

278.62

20

411.78

529.49

30

2299.42

631.93

 

3.4.1.2. 2번 트랜잭션 처리 테스트 - 터미널 개수 고정, 웨어하우스 변경

TiDB 시험, 웨어하우스 1인 경우

benmarksql 시험은 , 테스트가 안되도록 코딩되어 있다.

(최소 터미널수: 3 으로 하드코딩되어 있음.)

 

 

단위: TPM-C (높을 수록 좋은 것)

 

웨어하우스 수 YugabyteDB TiDB

1

36.33

N/A

10

32.67

11697.17

20

37.33

11519.74

30

32.67

11925.03

 

3.4.1.3. 3번 트랜잭션 처리 테스트 - 터미널 개수 변경, 웨어하우스 고정

단위: TPM-C (높을 수록 좋은 것)

 

트랜잭션이 발생되는 터미널 수 YugabyteDB TiDB

1

2.67

961.18

8

19.67

7187.93

16

32.67

12719.91

32

71.33

14611.45

64

147.33

16186.76

 

반응형