Quantcast
Channel: CodeSection,代码区,数据库(综合) - CodeSec
Viewing all articles
Browse latest Browse all 6262

非关系型数据库性能调优

$
0
0

Mongodb

1、Mongodb优化:

a、语句优化可能通过Profile找到执行时间长的语句。db.getProfiling.Level()来获取profile级别 db.system.profile.find()查看profile记录。

b、找到语句后,通过explain来解析这条语句,可以看到有没有使用索引,使用了什么索引?db.collection.find({xx:xx}).explain();

c、通过explain的结果来优化查询语句。

2、mongodb连接数:

如果大并发下,连接数不够的话,会导致程序连接不上mongodb,需要调大连接数。

3、内存大小

内存大点或者磁盘改成ssd

redis通过info来监控

linux下通过redis-cli进入redis数据库(首先保证redis数据库是启动的哦)

进入redis输入info 可以查看缓存命中率、连接数

缓存命中率

命中次数/(命中次数+未命中次数)

命中率低的原因:

1、key失效时间过短

2、内存设置过小,导致内存中数据存满,redis自己清除了一些key

memcache没有可视化视图,可以用telnet 需要监控的memcache服务器ip地址 memcache端口(默认11211)

在命令行窗口输入stats监控memcache

也可以通过工具phpmemcache来监控。


Viewing all articles
Browse latest Browse all 6262

Trending Articles