写点什么

v7.1 LTS Resource Control 试用

  • 2023-06-09
    北京
  • 本文字数:5533 字

    阅读完需:约 18 分钟

作者: weixiaobing 原文来源:https://tidb.net/blog/38269f09


1、集群信息


[tidb@vm116 ~]$ tiup cluster display tidb-prdtiup is checking updates for component cluster ...Starting component `cluster`: /home/tidb/.tiup/components/cluster/v1.12.2/tiup-cluster display tidb-prdCluster type:       tidbCluster name:       tidb-prdCluster version:    v7.1.0Deploy user:        tidbSSH type:           builtinDashboard URL:      http://10.2.103.116:32379/dashboardGrafana URL:        http://10.2.103.116:5000ID                  Role          Host          Ports                            OS/Arch       Status   Data Dir                            Deploy Dir--                  ----          ----          -----                            -------       ------   --------                            ----------10.2.103.116:9793   alertmanager  10.2.103.116  9793/9794                        linux/x86_64  Up       /data1/tidb-data/alertmanager-9793  /data1/tidb-deploy/alertmanager-979310.2.103.116:5000   grafana       10.2.103.116  5000                             linux/x86_64  Up       -                                   /data1/tidb-deploy/grafana-500010.2.103.116:32379  pd            10.2.103.116  32379/3380                       linux/x86_64  Up|L|UI  /data1/tidb-data/pd-32379           /data1/tidb-deploy/pd-3237910.2.103.116:9390   prometheus    10.2.103.116  9390/32020                       linux/x86_64  Up       /data1/tidb-data/prometheus-9390    /data1/tidb-deploy/prometheus-939010.2.103.116:43000  tidb          10.2.103.116  43000/20080                      linux/x86_64  Up       -                                   /data1/tidb-deploy/tidb-3400010.2.103.116:9300   tiflash       10.2.103.116  9300/9123/4930/30170/30292/8234  linux/x86_64  Up       /data1/tidb-data/tiflash-9300       /data1/tidb-deploy/tiflash-930010.2.103.116:30160  tikv          10.2.103.116  30160/30180                      linux/x86_64  Up       /data1/tidb-data/tikv-30160         /data1/tidb-deploy/tikv-30160Total nodes: 7[tidb@vm116 ~]$
复制代码

相关参数

mysql> show variables like '%tidb_enable_resource_control%';+------------------------------+-------+| Variable_name                | Value |+------------------------------+-------+| tidb_enable_resource_control | ON    |+------------------------------+-------+1 row in set (0.00 sec)
mysql> show config where name like '%resource-control%';+---------+--------------------+------------------------------------------+-------+| Type | Instance | Name | Value |+---------+--------------------+------------------------------------------+-------+| tikv | 10.2.103.116:30160 | resource-control.enabled | true || tiflash | 10.2.103.116:4930 | raftstore-proxy.resource-control.enabled | true |+---------+--------------------+------------------------------------------+-------+2 rows in set (0.01 sec)
mysql>
复制代码

预估集群容量

mysql> CALIBRATE RESOURCE;+-------+| QUOTA |+-------+| 23256 |+-------+1 row in set (0.01 sec)
mysql> CALIBRATE RESOURCE WORKLOAD OLTP_WRITE_ONLY;+-------+| QUOTA |+-------+| 36592 |+-------+1 row in set (0.00 sec)
mysql> CALIBRATE RESOURCE WORKLOAD OLTP_READ_ONLY;+-------+| QUOTA |+-------+| 6985 |+-------+1 row in set (0.00 sec)
mysql> CALIBRATE RESOURCE WORKLOAD OLTP_READ_WRITE;+-------+| QUOTA |+-------+| 14886 |+-------+1 row in set (0.00 sec)
mysql>
复制代码



mysql> CALIBRATE RESOURCE START_TIME '2023-06-07 10:40:00' DURATION '20m';ERROR 1105 (HY000): There are too few metrics points available in selected time windowmysql> 
复制代码




当负载太小时,可能不能正确的估算出容量



调整负载后,可以正常估算容量


管理资源组

创建资源组

mysql> CREATE RESOURCE GROUP IF NOT EXISTS read_write RU_PER_SEC = 5000 BURSTABLE;Query OK, 0 rows affected (0.21 sec)
mysql> CREATE RESOURCE GROUP IF NOT EXISTS read_write_no RU_PER_SEC = 5000 ;Query OK, 0 rows affected (0.14 sec)
mysql> CREATE RESOURCE GROUP IF NOT EXISTS read RU_PER_SEC = 2000 ;ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your TiDB version for the right syntax to use line 1 column 40 near "read RU_PER_SEC = 2000"
mysql> CREATE RESOURCE GROUP IF NOT EXISTS read_only RU_PER_SEC = 2000;Query OK, 0 rows affected (0.17 sec)
mysql> CREATE RESOURCE GROUP IF NOT EXISTS write_only RU_PER_SEC = 12000;Query OK, 0 rows affected (0.18 sec)
mysql> CREATE RESOURCE GROUP IF NOT EXISTS write RU_PER_SEC = 12000;ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your TiDB version for the right syntax to use line 1 column 41 near "write RU_PER_SEC = 12000" mysql>
复制代码


mysql> select * from information_schema.RESOURCE_GROUPS;+---------------+------------+----------+-----------+| NAME          | RU_PER_SEC | PRIORITY | BURSTABLE |+---------------+------------+----------+-----------+| default       | UNLIMITED  | MEDIUM   | YES       || read_only     | 2000       | MEDIUM   | NO        || read_write    | 5000       | MEDIUM   | YES       || read_write_no | 5000       | MEDIUM   | NO        || write_only    | 12000      | MEDIUM   | NO        |+---------------+------------+----------+-----------+5 rows in set (0.01 sec)
mysql>
复制代码

绑定资源组

mysql> create user read_only identified by 'tidb';Query OK, 0 rows affected (0.08 sec)
mysql> create user read_write identified by 'tidb';Query OK, 0 rows affected (0.03 sec)
mysql> create user read_write_no identified by 'tidb';Query OK, 0 rows affected (0.04 sec)
mysql> create user write_only identified by 'tidb';Query OK, 0 rows affected (0.03 sec)
mysql> alter user read_only resource group read_only;Query OK, 0 rows affected (0.05 sec)
mysql> alter user write_only resource group write_only;Query OK, 0 rows affected (0.04 sec)
mysql> alter user read_write resource group read_write;Query OK, 0 rows affected (0.03 sec)
mysql> alter user read_write_no resource group read_write_no;Query OK, 0 rows affected (0.04 sec)
mysql>
复制代码

将用户绑定到资源组

mysql> select user,host,User_attributes from mysql.user;+---------------+------+-------------------------------------+| user          | host | User_attributes                     |+---------------+------+-------------------------------------+| root          | %    | NULL                                || read_only     | %    | {"resource_group": "read_only"}     || read_write    | %    | {"resource_group": "read_write"}    || write_only    | %    | {"resource_group": "write_only"}    || read_write_no | %    | {"resource_group": "read_write_no"} |+---------------+------+-------------------------------------+5 rows in set (0.00 sec)
mysql>
复制代码


性能测试

read_only

压测脚本

[tidb@vm116 ~]$ more sysbench_read_only.config mysql-host=10.2.103.116mysql-port=43000mysql-user=read_onlymysql-password=tidbmysql-db=sbtesttime=600threads=16report-interval=1db-driver=mysql[tidb@vm116 ~]$ 
sysbench --config-file=sysbench_read_only.config oltp_read_only --tables=10 --table-size=10000 run
复制代码

监控与图表

机器负载

压测结果

SQL statistics:    queries performed:        read:                            4125548        write:                           0        other:                           589364        total:                           4714912    transactions:                        294682 (491.11 per sec.)    queries:                             4714912 (7857.77 per sec.)    ignored errors:                      0      (0.00 per sec.)    reconnects:                          0      (0.00 per sec.)
General statistics: total time: 600.0306s total number of events: 294682
Latency (ms): min: 9.70 avg: 32.57 max: 204.13 95th percentile: 38.94 sum: 9599029.86
Threads fairness: events (avg/stddev): 18417.6250/23.24 execution time (avg/stddev): 599.9394/0.01
复制代码

read_only_no

压测脚本

[tidb@vm116 ~]$ more sysbench_read_only_no.config mysql-host=10.2.103.116mysql-port=43000mysql-user=read_only_nomysql-password=tidbmysql-db=sbtesttime=600threads=16report-interval=1db-driver=mysql[tidb@vm116 ~]$ sysbench --config-file=sysbench_read_only_no.config oltp_read_only --tables=10 --table-size=10000 run
复制代码

监控与图表

机器负载

压测结果

SQL statistics:    queries performed:        read:                            7025844        write:                           0        other:                           1003692        total:                           8029536    transactions:                        501846 (836.38 per sec.)    queries:                             8029536 (13382.01 per sec.)    ignored errors:                      0      (0.00 per sec.)    reconnects:                          0      (0.00 per sec.)
General statistics: total time: 600.0231s total number of events: 501846
Latency (ms): min: 7.99 avg: 19.13 max: 167.63 95th percentile: 28.67 sum: 9598335.88
Threads fairness: events (avg/stddev): 31365.3750/58.39 execution time (avg/stddev): 599.8960/0.01
[tidb@vm116 ~]$
复制代码

没有资源限制用户测试

压测脚本

[tidb@vm116 ~]$ more sysbench.config mysql-host=10.2.103.116mysql-port=43000mysql-user=rootmysql-password=mysql-db=sbtesttime=600threads=16report-interval=1db-driver=mysql[tidb@vm116 ~]$ 
复制代码

监控与图表

机器负载

压测结果

SQL statistics:    queries performed:        read:                            6938876        write:                           0        other:                           991268        total:                           7930144    transactions:                        495634 (826.02 per sec.)    queries:                             7930144 (13216.36 per sec.)    ignored errors:                      0      (0.00 per sec.)    reconnects:                          0      (0.00 per sec.)
General statistics: total time: 600.0232s total number of events: 495634
Latency (ms): min: 7.88 avg: 19.37 max: 239.23 95th percentile: 29.19 sum: 9598338.50
Threads fairness: events (avg/stddev): 30977.1250/55.63 execution time (avg/stddev): 599.8962/0.01
[tidb@vm116 ~]$
复制代码

总结

Resource Contro 的确可以限制用户的资源使用,但是当资源组设置 BURSTABLE 属性后,基本可以用到机器所有的资源,建议还是需要设置一个最大值,这样可以更好的保护集群。


由于测试资源有限,没有测试更大的集群,在有更多的 tidb servre 和 tikv 后,希望可以测试一下在资源管控后,是否会资源均衡,希望大家多多测试。


发布于: 刚刚阅读数: 2
用户头像

TiDB 社区官网:https://tidb.net/ 2021-12-15 加入

TiDB 社区干货传送门是由 TiDB 社区中布道师组委会自发组织的 TiDB 社区优质内容对外宣布的栏目,旨在加深 TiDBer 之间的交流和学习。一起构建有爱、互助、共创共建的 TiDB 社区 https://tidb.net/

评论

发布
暂无评论
v7.1 LTS Resource Control 试用_新版本/特性解读_TiDB 社区干货传送门_InfoQ写作社区