作者: tidb狂熱愛好者 原文來源: https://tidb.net/blog/ef242615
項目背景介紹
有一個20t-30t的歷史庫需要做數(shù)據(jù)分析,節(jié)能減排,減容增效。今年大環(huán)境不好,aws的費用又是出奇的貴。
歷史庫的作用是公司近1年的訂單合集,平時不需要查詢,偶爾會有月統(tǒng)計的需求。之前用aws的mysql無法完成需求,現(xiàn)在尋找數(shù)據(jù)庫替換。
分別測試了oltp性能和olap性能。
數(shù)據(jù)分析pk
壓測步驟
如何對 TiDB 進行 CH-benCHmark 測試
本地啟動一個tidb單節(jié)點端口4000,啟動一個mysql8.0 端口4001
tiup playground
初始化測試數(shù)據(jù)
tiup bench tpch --sf=1 prepare -P4000
tiup bench tpch --sf=1 prepare -P4001
#進入tidb開啟tiflash。 ALTER DATABASE tpcc SET TIFLASH REPLICA 1; #等待同步完成后收集統(tǒng)計信息。 analyze table customer; analyze table district; analyze table history; analyze table item; analyze table new_order; analyze table order_line; analyze table orders; analyze table stock; analyze table warehouse; analyze table nation; analyze table region; analyze table supplier;
分別開始測試
tiup bench tpch --sf=1 run -P4000
tiup bench tpch --sf=1 run -P4001
mysql8數(shù)據(jù)分析測試
tiup is checking updates for component bench ...timeout(2s)! Starting component bench: /var/root/.tiup/components/bench/v1.12.0/tiup-bench tpch --sf=1 run -P4001 [Current] Q1: 78.89s [Current] Q2: 3.79s [Current] Q3: 26.81s [Current] Q4: 6.14s [Current] Q5: 6.48s [Current] Q6: 10.23s [Current] Q7: 26.21s [Current] Q8: 39.76s [Current] Q9: 98.75s [Current] Q10: 13.25s [Current] Q11: 10.37s [Current] Q12: 15.94s [Current] Q13: 12.72s [Current] Q14: 32.78s [Current] Q15: 31.24s [Current] Q16: 4.06s mysql無法進行數(shù)據(jù)分析依賴redshift 無法進行Q17測試。
tidb數(shù)據(jù)分析
[Current] Q3: 0.30s [Current] Q4: 1.31s [Current] Q5: 0.57s [Current] Q6: 0.17s [Current] Q7: 0.30s [Current] Q8: 0.50s [Current] Q9: 0.97s [Current] Q1: 0.57s [Current] Q10: 0.44s [Current] Q11: 0.17s [Current] Q12: 0.44s [Current] Q13: 0.70s [Current] Q14: 0.17s [Current] Q15: 0.50s [Current] Q16: 0.23s [Current] Q17: 0.44s [Current] Q18: 0.84s [Current] Q2: 0.17s [Current] Q21: 0.84s [Current] Q22: 0.10s [Current] Q3: 0.30s [Current] Q4: 1.38s [Current] Q5: 0.44s [Current] Q6: 0.17s [Current] Q7: 0.37s [Current] Q8: 0.50s [Current] Q9: 0.91s [Current] Q1: 0.57s [Current] Q10: 0.44s [Current] Q11: 0.17s [Current] Q12: 0.30s [Current] Q13: 0.57s [Current] Q14: 0.17s [Current] Q15: 0.64s [Current] Q16: 0.23s [Current] Q17: 0.50s [Current] Q19: 0.64s [Current] Q2: 0.17s [Current] Q20: 0.23s [Current] Q21: 0.91s [Current] Q22: 0.10s [Current] Q3: 0.37s [Current] Q4: 1.17s [Current] Q5: 0.44s [Current] Q6: 0.17s [Current] Q7: 0.37s [Current] Q8: 0.50s [Current] Q9: 0.84s [Current] Q1: 0.64s [Current] Q10: 0.44s [Current] Q11: 0.17s [Current] Q12: 0.23s [Current] Q13: 0.57s [Current] Q14: 0.10s [Current] Q15: 0.37s [Current] Q16: 0.17s [Current] Q17: 0.30s [Current] Q18: 0.67s [Current] Q19: 0.64s [Current] Q2: 0.17s [Current] Q20: 0.30s [Current] Q21: 0.77s [Current] Q22: 0.10s [Current] Q3: 0.30s [Current] Q4: 1.17s [Current] Q5: 0.44s [Current] Q6: 0.10s [Current] Q7: 0.37s [Current] Q8: 0.30s [Current] Q9: 0.70s tidb數(shù)據(jù)分析性能是mysql的幾百倍 均是幾百毫秒完成。
測試結(jié)果比較
差距最大的q1 q9 有100多倍,最小q4 也有5倍
q1 | q2 | q3 | q4 | q5 | q6 | q7 | q8 | q9 | q10 | |
---|---|---|---|---|---|---|---|---|---|---|
mysql8 | 78.89s | 3.79s | 26.81s | 6.14s | 6.14s | 10.23s | 26.21s | 39.76s | 98.75s | 13.25s |
tidb | 0.64s | 0.17s | 0.30s | 1.17s | 0.44s | 0.10s | 0.37s | 0.30s | 0.70s | 0.44s |
ycsb測試
測試命令
讀10000次計算執(zhí)行時間
更新500次計算執(zhí)行時間
tiup bench ycsb run tidb -p tidb.instances=127.0.0.1:4000 -p operationcount=10000
tiup bench ycsb run mysql -p tidb.instances=127.0.0.1:4001 -p operationcount=10000
tidb
Starting component `bench`: /var/root/.tiup/components/bench/v1.12.0/tiup-bench ycsb run mysql -p tidb.instances=127.0.0.1:4000 -p operationcount=10000 ***************** properties ***************** "command"="run" "tidb.instances"="127.0.0.1:4000" "operationcount"="10000" "dotransactions"="true" ********************************************** Run finished, takes 4.191237542s READ - Takes(s): 4.2, Count: 9495, OPS: 2267.3, Avg(us): 402, Min(us): 179, Max(us): 7951, 99th(us): 705, 99.9th(us): 3519, 99.99th(us): 7007 UPDATE - Takes(s): 4.2, Count: 505, OPS: 120.7, Avg(us): 675, Min(us): 419, Max(us): 2497, 99th(us): 1117, 99.9th(us): 1926, 99.99th(us): 2497
mysql
tiup is checking updates for component bench ... Starting component `bench`: /var/root/.tiup/components/bench/v1.12.0/tiup-bench ycsb run mysql -p tidb.instances=127.0.0.1:4001 -p operationcount=10000 ***************** properties ***************** "operationcount"="10000" "dotransactions"="true" "command"="run" "tidb.instances"="127.0.0.1:4001" ********************************************** READ - Takes(s): 10.0, Count: 4522, OPS: 452.5, Avg(us): 2086, Min(us): 778, Max(us): 151423, 99th(us): 8687, 99.9th(us): 26655, 99.99th(us): 151423 UPDATE - Takes(s): 9.9, Count: 234, OPS: 23.6, Avg(us): 2306, Min(us): 972, Max(us): 10543, 99th(us): 7859, 99.9th(us): 10543, 99.99th(us): 10543 Run finished, takes 19.66040875s READ - Takes(s): 19.7, Count: 9506, OPS: 483.7, Avg(us): 1955, Min(us): 778, Max(us): 151423, 99th(us): 7867, 99.9th(us): 17759, 99.99th(us): 41343 UPDATE - Takes(s): 19.6, Count: 494, OPS: 25.2, Avg(us): 2080, Min(us): 807, Max(us): 10543, 99th(us): 6959, 99.9th(us): 10543, 99.99th(us): 10543
結(jié)論
tp性能測試 | read 9506 count |
update 494 count |
---|---|---|
mysql | 19.6s | 19.7s |
tidb | 4.2s | 4.2s |
亞馬遜上的費用對比
三實例aws Aurora費用
cpu | 實例小時費用 | 存儲費用小時 | io1萬次數(shù) | 總費用 | ||
---|---|---|---|---|---|---|
主讀 | r5.4xlarge | 16 | 2.3200?USD | 每月每 GB 0.12 USD | 每月每 IOPS 0.27 | |
主寫 | r5.4xlarge | 16 | 2.3200?USD | 每月每 GB 0.12 USD | 每月每 IOPS 0.27 | |
redshift最低配 | dc2.8xlarge | 32 | 4,449.35 | |||
月費用 | 3340.8 | 491.52 | 5400 | 9232.32 |
aurora預估費用頁面 https://aws.amazon.com/cn/rds/aurora/pricing/?pg=pr&loc=1 存儲費率 每月每 GB 0.12 USD 每月每 GB 0.27 USD I/O 費率 每 100 萬個請求 0.24 USD 包含
aws rds費用
cpu | 實例小時費用 | 存儲費用小時 | io1萬次數(shù) | 總費用 | ||
---|---|---|---|---|---|---|
主讀 | r5.4xlarge | 16 | 2.2800?USD | 每月每 GB 0.375 USD | 每月每 IOPS 0.30 | |
主寫 | r5.4xlarge | 16 | 2.2800?USD | 每月每 GB 0.375 USD | 每月每 IOPS 0.30 | |
redshift最低配 | dc2.8xlarge | 32 | 4,449.35 | |||
月費用 | 5088.96 | 1536 | 6000 | 10819.2 |
rds預估費用頁面 https://aws.amazon.com/cn/rds/mysql/pricing/?pg=pr&loc=2 多可用區(qū)存儲費率 每月每 GB 0.45 USD 多可用區(qū)預調(diào)配 IOPS 費率 每月每 IOPS 0.36 USD
tidb 非高可用方案 冷磁盤250m峰值讀取
cpu | 實例小時費用 | 20t cold hhd | gp3 1t(給tiflash) | 總費用 | ||
---|---|---|---|---|---|---|
pd | c5.2xlarge | 8 | 0.192 | 0 | ||
tidb | c5.4xlarge | 16 | 0.856 | 0 | ||
kv | r5.4xlarge | 16 | 1.096 | 200 | 200 | |
月費用 | 1543.68 | 200 | 200 | 1943 |
優(yōu)點:
費用便宜只需要1943元就能完成大數(shù)據(jù)的計算任務。如果好后期可以擴容支撐大數(shù)據(jù)計算業(yè)務
tiflash采用計算分離架構(gòu)節(jié)約80%費用
TiFlash 存算分離架構(gòu)與 S3 支持
缺點:
本方案是單點tidb。如果ec2宕機,需要代碼遇到tidb無法寫入時,不再刪除mysql原始庫的數(shù)據(jù)。等待處理
tidb高可用三副本
cpu | 實例小時費用 | 20t cold hhd(1月) | gp3 1t(給tiflash) | 總費用 | ||
---|---|---|---|---|---|---|
pd | c5.2xlarge | 8 | 0.192 | 0 | ||
pd | c5.2xlarge | 8 | 0.192 | 0 | ||
pd | c5.2xlarge | 8 | 0.192 | 0 | ||
tidb | c5.4xlarge | 16 | 0.856 | 0 | ||
tidb | c5.4xlarge | 16 | 0.856 | 0 | ||
kv | r5.4xlarge | 16 | 1.096 | 200 | ||
kv | r5.4xlarge | 16 | 1.096 | 200 | ||
kv | r5.4xlarge | 16 | 1.096 | 200 | 200 | |
月費用 | 4631.04 | 600 | 200 | 5431.04 |
優(yōu)點:
費用便宜只需要5431元就能完成大數(shù)據(jù)的計算任務。如果好后期可以擴容支撐大數(shù)據(jù)計算業(yè)務
并且是三副本高可用的版本。不存在宕機問題
tiflash采用計算分離架構(gòu)節(jié)約80%費用
https://docs.pingcap.com/zh/tidb/stable/tiflash-disaggregated-and-s3
缺點:
相比單節(jié)點費用較高。保證了業(yè)務可用性。
結(jié)論
感覺tidb上了后會節(jié)約至少一半的費用。
整體算下來 aurora的費用會比rds便宜因為aurora的存儲基于s3的三副本。存儲費用低。 文章來源:http://www.zghlxwxcb.cn/news/detail-538893.html
而自建tidb的存儲價格會比aurora低。合理利用s3,hhd,gp3,不同存儲的搭配會節(jié)省出不少費用。s3作為aws的引流產(chǎn)品價格是出奇的低我恨不得任何時候任何產(chǎn)品后段都掛載s3.實現(xiàn)容量和性價比的 文章來源地址http://www.zghlxwxcb.cn/news/detail-538893.html
tidb | 費用對比 | 費用比 |
---|---|---|
single | 1943 | 0.35 |
tidb | 5431.04 | 1.0 |
rds | 10819.2 | 2.0 |
Aurora | 9232.32 | 1.7 |
到了這里,關于aws上采用tidb和原生使用aws rds價格的比較。兼數(shù)據(jù)分析性能的測試的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關文章,希望大家以后多多支持TOY模板網(wǎng)!