TiDB 帮助企业在 AWS 上大幅降低数据库成本分析

网友投稿 279 2024-03-24



项目背景介绍

有一个400t的历史库需要做数据分析,节能减排,减容增效。今年大环境不好,aws的费用又是出奇的贵。

TiDB 帮助企业在 AWS 上大幅降低数据库成本分析

历史库的作用是公司近1年的订单合集,平时不需要查询,偶尔会有月统计的需求。之前用aws的mysql无法完成需求,现在寻找数据库替换。

分别测试了oltp性能和olap性能。

数据分析pk

压测步骤

如何对 TiDB 进行 CH-benCHmark 测试

本地启动一个tidb单节点端口4000,启动一个mysql8.0 端口4001

tiup playground

初始化测试数据

tiup bench tpch --sf=1 prepare -P4000

tiup bench tpch --sf=1 prepare -P4001

#进入tidb开启tiflash。 ALTER DATABASE tpcc SET TIFLASH REPLICA 1; #等待同步完成后收集统计信息。 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数据分析测试

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无法进行数据分析依赖redshift 无法进行Q17测试。

tidb数据分析

[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数据分析性能是mysql的几百倍 均是几百毫秒完成。

测试结果比较

差距最大的q1 q9 有100多倍,最小q4 也有5倍

q1q2q3q4q5q6q7q8q9q10mysql878.89s3.79s26.81s6.14s6.14s10.23s26.21s39.76s98.75s13.25stidb0.64s0.17s0.30s1.17s0.44s0.10s0.37s0.30s0.70s0.44s

ycsb测试

测试命令

读10000次计算执行时间

更新500次计算执行时间

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

结论

tp性能测试read 9506countupdate 494 countmysql19.6s19.7stidb4.2s4.2s

亚马逊上的费用对比

三实例aws Aurora费用

cpu实例小时费用存储费用小时io1万次数总费用主读r5.4xlarge162.3200 USD每月每 GB 0.12 USD每月每 IOPS 0.27主写r5.4xlarge162.3200 USD每月每 GB 0.12 USD每月每 IOPS 0.27redshift最低配dc2.8xlarge324,449.35月费用334096054009700

auror

aws rds费用

cpu实例小时费用存储费用小时io1万次数总费用主读r5.4xlarge162.2800 USD每月每 GB 0.375 USD每月每 IOPS 0.30主写r5.4xlarge162.2800 USD每月每 GB 0.375 USD每月每 IOPS 0.30redshift最低配dc2.8xlarge324,449.35月费用5088.963000600012319.2

tidb 非高可用方案 冷磁盘250m峰值读取

cpu实例小时费用20t cold hhdgp3 1t(给tiflash)总费用pdc5.2xlarge80.1920tidbc5.4xlarge160.8560kvr5.4xlarge161.0964000月费用1543.6820001943

优点:

费用便宜只需要1943就能完成大数据的计算任务。如果好后期可以扩容支撑大数据计算业务

tiflash采用计算分离架构节约80%费用

TiFlash 存算分离架构与 S3 支持

缺点:

本方案是单点tidb。如果ec2宕机,需要代码遇到tidb无法写入时,不再删除mysql原始库的数据。等待处理

tidb高可用三副本

cpu实例小时费用40t cold hhd(1月)gp3 1t(给tiflash)总费用pdc5.2xlarge80.1920pdc5.2xlarge80.1920pdc5.2xlarge80.1920tidbc5.4xlarge160.8560tidbc5.4xlarge160.8560kvr5.4xlarge161.096400kvr5.4xlarge161.096400kvr5.4xlarge161.0964000月费用4631.04120005831.04

优点:

费用便宜只需要5831元就能完成大数据的计算任务。如果好后期可以扩容支撑大数据计算业务

并且是三副本高可用的版本。不存在宕机问题

tiflash采用计算分离架构节约80%费用

TiFlash 存算分离架构与 S3 支持

缺点:

相比单节点费用较高。保证了业务可用性。

结论

感觉tidb上了后会节约至少一半的费用。

整体算下来 aurora的费用会比rds便宜因为aurora的存储基于s3的三副本。存储费用低。

而自建tidb的存储价格会比aurora低。合理利用s3 hhd和gp3 不同存储的搭配会节省出不少费用。

tidb费用对比费用比single19430.35tidb5431.041.0rds10819.22.0Aurora9232.321.7

本文是按照美元计价的月费用如果rmb计价就很恐怖了。

tidb费用对比费用比single1632120.35tidb456207.361.0rds960749.42.0Aurora819830.0161.7

一个数据库一年的话费能从上百万减少到16万

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:TiDB 容器化管理利器 TiDB Operator
下一篇:TiDB 常用 SQL 指南
相关文章