应用优化
2016-07-20 15:10
267 查看
1.使用连接池
2.减少对 mysql 的访问
select old, gender from users where userid = 231;
select address from users where userid = 231;
这两句跟
select old, gender, address from users where userid = 231;
这个请求数就减少了
3.使用查询缓存
show variables like '%query_cache%';
have_query_cache | YES | 表明服务器在安装是否已经配置了高速缓存
| query_cache_limit | 1048576 |
| query_cache_min_res_unit | 4096 |
| query_cache_size | 1048576 | 表明缓存区大小,单位为 MB
| query_cache_type | OFF | 0/off 缓存关闭 1/on 缓存打开(使用 sql_no_cache 提示的 select 除外) 2/demand 只有带 sql_cache 的 select 语句提供高速缓存
| query_cache_wlock_invalidate | OFF
Qcache_free_blocks | 1 | 查询缓存中的空闲内存块的数目
| Qcache_free_memory | 1031360 | 查询缓存的空闲内存总数
| Qcache_hits | 0 | 缓存采样数数目
| Qcache_inserts | 0 | 被加入到缓存中的查询数目
| Qcache_lowmem_prunes | 0 | 因为缺少内存而被从缓存中删除的查询数目
| Qcache_not_cached | 2139001 | 没有被缓存的查询数目(不能被缓存的,或由于 query_cache_type)
| Qcache_queries_in_cache | 0 | 在缓存中已注册的查询数目
| Qcache_total_blocks | 1 | 查询缓存中的块的总数目
| Queries | 4008543 |
| Questions | 3
4.增加 cache 层
5.负载均衡
1)利用 mysql 复制分流查询操作
2)采用分布式数据库架构
2.减少对 mysql 的访问
select old, gender from users where userid = 231;
select address from users where userid = 231;
这两句跟
select old, gender, address from users where userid = 231;
这个请求数就减少了
3.使用查询缓存
show variables like '%query_cache%';
have_query_cache | YES | 表明服务器在安装是否已经配置了高速缓存
| query_cache_limit | 1048576 |
| query_cache_min_res_unit | 4096 |
| query_cache_size | 1048576 | 表明缓存区大小,单位为 MB
| query_cache_type | OFF | 0/off 缓存关闭 1/on 缓存打开(使用 sql_no_cache 提示的 select 除外) 2/demand 只有带 sql_cache 的 select 语句提供高速缓存
| query_cache_wlock_invalidate | OFF
Qcache_free_blocks | 1 | 查询缓存中的空闲内存块的数目
| Qcache_free_memory | 1031360 | 查询缓存的空闲内存总数
| Qcache_hits | 0 | 缓存采样数数目
| Qcache_inserts | 0 | 被加入到缓存中的查询数目
| Qcache_lowmem_prunes | 0 | 因为缺少内存而被从缓存中删除的查询数目
| Qcache_not_cached | 2139001 | 没有被缓存的查询数目(不能被缓存的,或由于 query_cache_type)
| Qcache_queries_in_cache | 0 | 在缓存中已注册的查询数目
| Qcache_total_blocks | 1 | 查询缓存中的块的总数目
| Queries | 4008543 |
| Questions | 3
4.增加 cache 层
5.负载均衡
1)利用 mysql 复制分流查询操作
2)采用分布式数据库架构
相关文章推荐
- 直接用编译器按ctrl+F5运行和Release、Debug下双击运行结果不一样
- java中读取配置文件的方法
- XSS攻击
- 一代记忆
- ThreadLocal误区解密
- 移动网络手机抓包分享
- Javascript 基础之Date对象
- Linux makefile 教程,简单粗暴,2小时学习makefile
- 磁盘 I/O 优化
- Web压力测试工具-Apache Bench
- 如何把HTML标记分类
- Redis 集群
- Window下sqlite的安装
- Oracle 查看一个表对应的主键和外键的约束关系
- linux 下部署 tomcat
- Java 调整格式日志输出
- POJ 3984 迷宫问题
- AOJ-795 西瓜理发记(三)
- 欢迎使用CSDN-markdown编辑器
- Java RMI 概览