1. 数据库性能测试
1.1. 目的
发现数据库相关的性能瓶颈
1.2. 范围
- sql慢查询
- 资源使用率
- 数据库架构设计
- 数据库性能监控
1.3. 数据库主从复制
master-slave
keepalived
1.4. 数据库分库分表
pass
1.5. MySQL数据库监控
QPS
每秒查询数,Queries/seconds
show global status like 'Question%';
TPS
show global status like 'Com_commit';
show global status like 'Com_rollback';
线程链接数
show global status like 'Max_used_connections';
show global status like 'Theads%';
1.5.1. 查询缓存
- 查询缓存用于缓存select查询结果,便于下次相同请求,加速响应
- 适用于大量查询,很少改变表中数据
配置方式
修改mysql配置文件
设置query_cache_size为具体的大小
query_cache_type=0/1/2 #1缓存所有结果,2只缓存通过SQL_CACHE指定要缓存的查询
查询缓存命中率
show status like 'Qcache%';
1.5.2. 锁定状态
show global status like '%lock%';
Table_locks_immediate
Table_locks_waited
值越大代表锁造成的阻塞越严重
1.5.3. 主从延迟
show slave status