MySQL/TPC-C - Run and Analyze the Results

정현철·2023년 4월 16일
0

Database Project

목록 보기
1/7
post-thumbnail

회원가입 과정에서,

  1. User는 ID와 PW 정보를 기입하여, 특정 App이나 페이지에 Sign up 요청을 보낸다.
  2. 해당 App의 서버는 DBMS에 INSERT SQL query를 보낸다.
  3. DBMS는 해당 유저의 ID와 PW를 Disk에 저장한다.

위와 같은 과정은 단 하나의 user와 서버, DBMS간의 통신이지만, 실제 서비스에서는 엄청나게 많은 유저가 다양한 요청을 하고, 그만큼 많은 query가 DBMS에 동시에(Simultaneously) 전달된다. 그러므로 DBMS는 그만큼 동시성, 정확성, 속도 등에서 충분한 성능을 보장해 주어야 하는 것.

Benchmarking : What and Why

  • 벤치마크란, 주어진 App의 performance를 측정하는 과정이며, 다른 유사한 workloads와 해당 App의 성능을 비교하는 것이다.
    • 성능을 개선하고, 혹시나 있을지 모르는 performance gap을 발견하기 위해서 수행한다.
  • 벤치마크는 domain-specific하다.
    • 벤치마크는 특정한 workload의 작업을 대표할 수 있는 핵심적인 속성을 추출(distillation)하여, 그 성능을 측정하는 것을 말한다.
    • 그래서 The more general the benchmark, the less useful it is.
  • 그렇다면 바람직한 attributes란,
    • Relevant(적절함): 벤치마크는 target domain에게 의미있는 결과를 제공해야 한다.
    • Understandable/acceptable(이해 가능/수용 가능): Vender와 user가 모두 그 결과를 수용(embrace)할 수 있어야 한다.
    • Scalable/coverable(확장 가능/넓은 커버리지): 벤치마크가 다양한 환경에 적용가능하도록, 대상 환경을 너무 단순화하지 않아야 한다.

TPC-C

  • 29년이나 된, 데이터베이스 성능 측정의 산업 표준 OLTP 벤치마크이다.
  • e-commerce와 retail company의 서버 상황을 시뮬레이션한다.
  • 9개의 table과 다섯 종류의 transaction을 사용해 성능을 평가한다.
  • Random한 많은 I/O로 구성되는데, 65%가 reads, 그리고 35%가 writes이다.

Transactions

  1. New Order Transaction
    고객이 새로운 주문을 요청했을 때 일어나는 transaction
// Place an order for on average 10 items from a warehouse
Select(whouse-id) from Warehouse // 주문을 처리할 창고 선택
Select(dist-id, whouse-id) from District // 창고에 속한 구역(District) 선택
Update(dist-id, whouse-id) in District // 이 구역의 주문 수를 증가시키는 Update
Select(customer-id, dist-id, whouse-id) from Customer // 구역에서 주문을 요청한 고객 정보 선택

// Insert Order 주문 정보 order table에 저장
Insert into Order
Insert into New-Order 

// Update the corresponding stock level for each item
for each item(10 items):
	1. Select(item-id) from Item // 상품 id 선택
    2. Select(item-id, whouse-id) from Stock // 해당 상품의 존재하는 창고를 바탕으로 재고 선택
    3. Update(item-id, whouse-id) in Stock // 재고 업데이트
    4. Insert into Order-Line // 주문 정보를 Order-Line 테이블에 삽입

commit // 변경된 데이터를 disk에 저장
  1. Payment Transaction
// Process a payment for a customer
Select(whouse-id) from WareHouse // 주문 처리할 창고 선택
Select(dist-id, whouse-id) from District // 창고에 속한 구역 선택
Case 1: Select(customer-id, dist-id, whouse-id) from Customer // 고객 id로 선택
Case 2: Non-Unique-Select(customer-name, dist-id, whouse-id) from Customer // 이름으로 선택(중복될 가능성이 있어서 non-unique-select)

// Update balances and other data
Update(whouse-id) in Warehouse // 창고의 잔액 업데이트
Update(dist-id, whouse-id) in District // 구역의 잔액 업데이트
Update(customer-id, dist-id, whouse-id) in Customer // 고객의 잔액과 다른 데이터 업데이트
Insert into History // History 테이블에 새로운 행 삽입

commit
  1. Order-Status(Read Only)
    고객의 주문이 어떻게 처리되고 있는지 확인하는 transaction
// return the status of a customer's last order
Case 1: Select(customer-id, dist-id, whouse-id) from Customer
Case 2: Non-Unique-Select(customer-name, dist-id, whouse-id) from Customer // 고객 정보 알아오기
Select(Max(order-id), customer-id) from Order // 최근 주문 id 찾기
for each item in order: // 주문의 각 상품 정보 조회
	Select(order-id) from Order-Line

Commit // 변경할 내용은 없고 그냥 transaction 종료
  1. Delivery Transaction
/* Process orders corresponding to 10 pending orders,
one for each district, with 10 items per order */
for each district within warehouse(i.e. tem times):

  • skewed update: 일부 record를 자주 업데이트하게 된다.
  • growing: 시간이 지남에 따라 테이블이 점점 커진다(insert가 반복되므로)

Result

  1. TPC-C 결과창
10, trx: 493, 95%: 764.362, 99%: 1011.230, max_rt: 3165.036, 460|7427.418, 48|1684.188, 51|3922.317, 51| 5881.677
20, trx: 456, 95%: 838.937, 99%: 1053.247, max_rt: 1200.276, 465|3532.571, 46|324.480, 45|1275.379, 49|5178.482
30, trx: 503, 95%: 828.704, 99%: 1013.655, max_rt: 2262.165, 491|4421.898, 50|410.298, 50|1592.177, 44|4334.301
...
<Raw Results>
  [0] sc:4 lt:218054  rt:0  fl:0 avg_rt: 576.5 (5)
  [1] sc:0 lt:217563  rt:0  fl:0 avg_rt: 387.7 (5)
  [2] sc:3587 lt:18220  rt:0  fl:0 avg_rt: 131.3 (5)
  [3] sc:0 lt:21800  rt:0  fl:0 avg_rt: 1576.9 (80)
  [4] sc:2610 lt:19202  rt:0  fl:0 avg_rt: 2724.4 (20)
 in 3600 sec.

<Raw Results2(sum ver.)>
  [0] sc:4  lt:218068  rt:0  fl:0 
  [1] sc:0  lt:218068  rt:0  fl:0 
  [2] sc:3587  lt:18220  rt:0  fl:0 
  [3] sc:0  lt:21802  rt:0  fl:0 
  [4] sc:2610  lt:19202  rt:0  fl:0 

<Constraint Check> (all must be [OK])
 [transaction percentage]
        Payment: 43.42% (>=43.0%) [OK]
   Order-Status: 4.35% (>= 4.0%) [OK]
       Delivery: 4.35% (>= 4.0%) [OK]
    Stock-Level: 4.35% (>= 4.0%) [OK]
 [response time (at least 90% passed)]
      New-Order: 0.00%  [NG] *
        Payment: 0.00%  [NG] *
   Order-Status: 16.45%  [NG] *
       Delivery: 0.00%  [NG] *
    Stock-Level: 11.97%  [NG] *

<TpmC>
                 3634.300 TpmC
  • trx: New Order Transactions가 주어진 interval에서 몇 번이나 실행되었는지. (throughput per interval) 클수록 좋다
  • 95%: New Order Transactions per interval의 95% 응답 시간.
  • 99%: New Order Transactions per interval의 99% 응답 시간.
  • max_rt: New Order Transactions per interval의 Max Response Time
  • TpmC: New-Order transactions executed per minute
  1. iostat
$ iostat -mx 1
Linux 4.15.0-55-generic (mijin-desktop)         2019년 09월 16일        _x86_64_        (32 CPU)

avg-cpu:  %user   %nice %system %iowait  %steal   %idle
          10.41    0.00    5.03   21.70    0.00   62.85

Device:         rrqm/s   wrqm/s     r/s     w/s    rMB/s    wMB/s avgrq-sz avgqu-sz   await r_await w_await  svctm  %util
loop0             0.00     0.00    0.00    0.00     0.00     0.00     0.00     0.00    0.00    0.00    0.00   0.00   0.00
nvme0n1           0.00   746.00 24513.00  574.00    95.75   205.30    24.58    13.75    0.60    0.55    2.43   0.04 100.00
sda               0.00     2.00  598.00    5.00     2.34     2.37    15.99     0.04    0.06    0.05    1.60   0.05   3.20
sdb               0.00     0.00    0.00    0.00     0.00     0.00     0.00     0.00    0.00    0.00    0.00   0.00   0.00
sdc               0.00     0.00    0.00    0.00     0.00     0.00     0.00     0.00    0.00    0.00    0.00   0.00   0.00

avg-cpu:  %user   %nice %system %iowait  %steal   %idle
           9.25    0.00    4.43   21.94    0.00   64.38

Device:         rrqm/s   wrqm/s     r/s     w/s    rMB/s    wMB/s avgrq-sz avgqu-sz   await r_await w_await  svctm  %util
loop0             0.00     0.00    0.00    0.00     0.00     0.00     0.00     0.00    0.00    0.00    0.00   0.00   0.00
nvme0n1           0.00   732.00 22845.00  547.00    89.24   192.13    24.63    13.89    0.64    0.59    2.37   0.04  99.20
sda               0.00     2.00  570.00    5.00     2.23     2.43    16.57     0.02    0.04    0.03    1.60   0.02   1.20
sdb               0.00     4.00    0.00    3.00     0.00     0.18   122.67     0.04   13.33    0.00   13.33  13.33   4.00
sdc               0.00     0.00    0.00    0.00     0.00     0.00     0.00     0.00    0.00    0.00    0.00   0.00   0.00

...
  • Note each value of iostat of your data device
    • Especially, r/s, w/s, rMB/s, wMB/s, %util, avg-cpu

0개의 댓글