mysql与sphinx查询性能对比试验

在同一台机器对sphinx和mysql的查询进行了一个对比试验。
通话历史记录共有6212249条,查询2009-01-01至2009-03-01某座席的记录,sql如下:
select SQL_NO_CACHE id from t_toll_universal 
where begintime >= '2009-01-01' and begintime < '2009-03-01' and  agentid='xxxx @infobird.cn'  and calldirection =  1
 
注意:在通话记录表中的agentid字段建有索引。
 
做了两组试验,第一组是100个并发,10000次请求。第二组是单个进程10000次请求。
 
 
一、单进程,请求10000次的结果数据
1.1、mysql
Time taken for tests:   139.393 seconds
Requests per second:    71.74 [#/sec] (mean)
Time per request:       13.939 [ms] (mean)
 
Percentage of the requests served within a certain time (ms)
  50%     14
  66%     14
  75%     14
  80%     14
  90%     14
  95%     14
  98%     14
  99%     14
 100%     16 (longest request)
 
 
1.2、sphinx
Time taken for tests:   60.452 seconds
Requests per second:    165.42 [#/sec]
Time per request:       6.045 [ms]
 
Percentage of the requests served within a certain time (ms)
  50%      6
  66%      6
  75%      6
  80%      6
  90%      6
  95%      6
  98%      6
  99%      7
 100%      7 (longest request)
 
二、100个并发,请求10000次的数据结果
 
2.1、mysql:
Time taken for tests:   103.656 seconds  //总时长
Requests per second:    96.47 [#/sec] (mean) //每秒完成请求次数
Time per request:       10.366 [ms] //平均每个请求所耗时长(ms)
 
Percentage of the requests served within a certain time (ms) //请求所耗时长分布状况
  50%    743 //百分之五十的请求在743ms之内完成
  66%    927
  75%   1066
  80%   1227
  90%   2151
  95%   3665
  98%   5047
  99%   7054
 100%  19609 (longest request)
 
 
2.2、sphinx:
Time taken for tests:   59.788 seconds
Requests per second:    167.26 [#/sec] (mean)
Time per request:       5.979 [ms]
 
Percentage of the requests served within a certain time (ms)
  50%     26
  66%     28
  75%     31
  80%    244
  90%    355
  95%   3022
  98%   3169
  99%   9026
 100%  45253 (longest request)
 
 
 
 
三、结果分析
分析之前先声明一点,做这个试验的机器是一台基本上废弃了的笔记本电脑,所以数据的绝对值基本上没有意义。在此仅对mysql和sphinx在数据查询上的性能进行简单的分析。
 
3.1、试验不足之处
a、由于硬件条件限制,可能导致mysql或者sphinx的性能没有完全发挥
b、没有统计任务执行过程中系统资源的消耗情况
c、使用无线局域网,为了减少网络对试验的影响,发起请求的工具ab、sphinx和mysql部署在同一台机器上
 
3.2、结果的简单分析
a、不论是单进程查询还是多进程查询,sphinx都比mysql要快近 2
b、比较单进程查询和多进程查询,sphinx表现得更平稳
c、比较请求消耗的时间分布,在并发的情况下,sphinx有90%的请求在355ms内完成,而mysql是2151ms,相差近7倍
 
4、结论
对百万记录级别的数据进行检索时,使用sphinx做查询比直接使用mysql得到较大的性能提升。

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值