회원가입 과정에서,
위와 같은 과정은 단 하나의 user와 서버, DBMS간의 통신이지만, 실제 서비스에서는 엄청나게 많은 유저가 다양한 요청을 하고, 그만큼 많은 query가 DBMS에 동시에(Simultaneously) 전달된다. 그러므로 DBMS는 그만큼 동시성, 정확성, 속도 등에서 충분한 성능을 보장해 주어야 하는 것.
OLTP
벤치마크이다.
// 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에 저장
// 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
// 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 종료
/* 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):
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 TimeTpmC
: New-Order transactions executed per minute$ 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
...