基础架构
MySQL主要由连接器、分析器、优化器、执行器及存储引擎组成
连接器
管理连接,权限验证。如果客户端长时间没有发送请求,连接器会自动断开,由wait_timeout字段控制,默认8小时
分析器
词法分析,语法分析。并不仅仅是语法是否符合sql标准,同时也会判断取的字段表中是否存在
优化器
执行器
存储引擎
存储数据,提供读写接口。常见的有InnoDB、MyISAM等
性能测试
机器配置
一般数据库服务都配置在高配服务器上,最低8核16G,正常在16核32G(一般qps在2000~4000)
性能关注测试指标
QPS
query per second。每秒可以处理的查询请求的数量
TPS
transaction per second。每秒可以处理的事务请求的数量
IOPS
机器的随机IO并发处理的能力。dstat -r(读iops和写iops分别是多少)。dstat -n每秒⽹卡接收和发送的流量
吞吐量
机器的磁盘存储每秒可以读写多少字节的数据量。可通过dstat -d 命令查看,普通机械硬盘每秒上百
latency
CPU负载
网络负载
内存负载
sysbench性能测试工具
构建语句
sysbench --db-driver=mysql --time=300 --threads=5 --report-interva l=1 --mysql-host=127.0.0.1 --mysql-port=3306 --mysql-user=root --m 3ysql-password=psd --mysql-db=test_db --tables=20 --table_s ize=500000 oltp_read_write --db-ps-mode=disable prepare
运行语句
sysbench --db-driver=mysql --time=300 --threads=5 --report-interva l=1 --mysql-host=ali-mysql --mysql-port=3306 --mysql-user=root --m ysql-password=psd --mysql-db=test_db --tables=20 --table_s ize=50000 oltp_read_write --db-ps-mode=disable run
模式选择
oltp_read_only
oltp_delete
oltp_update_index
oltp_update_non_index
oltp_update_non_index
oltp_insert
oltp_write_only
清除数据
sysbench --db-driver=mysql --time=300 --threads=10 --report-interv al=1 --mysql-host=127.0.0.1 --mysql-port=3306 --mysql-user=test_us er --mysql-password=test_user --mysql-db=test_db --tables=20 --tab le_size=1000000 oltp_read_write --db-ps-mode=disable cleanup
