Chinaunix首页 | 论坛 | 博客
  • 博客访问: 94544
  • 博文数量: 25
  • 博客积分: 10
  • 博客等级: 民兵
  • 技术积分: 316
  • 用 户 组: 普通用户
  • 注册时间: 2012-08-02 00:39
文章分类

全部博文(25)

文章存档

2013年(25)

我的朋友

分类: Mysql/postgreSQL

2013-04-22 15:30:14

 

1.测试语句

select a.bm,a.gs,a.fpsj,a.lb,b.xm from ydserver.wdtmfw1 a
                        left join ydserver.ywy b on a.gs=b.gs and a.bm=b.bm
                     where QSH <= :b1 and ZZH >= :b2 and length(QSH) = 13 and length(ZZH) = 13 order by a.lb




2.测试环境

50,100,300,500,1000用户数并发测试基于物理表和内存表的场景




3.系统监控

通过vmstat 2 检测系统资源消耗情况




4.测试结果概述

传统表在100用户并发的情况下系统等待已经非常严重,负载在130以上,所以停止了后续更多用户的测试
内存表在1000用户并发的情况下仍然性能非常出色,没有出现系统等待




5.具体测试结果 --系统情况

50用户-物理表  --可以看出现在没有等待进程,cpu到达100%

r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa st
50  0  42416 3795180  61372 415532    0    0     0     0 1135 2524  1 41 58  0  0
56  0  42416 706200  61372 415532    0    0     0     0 1057  249 37 63  0  0  0
 5  0  42416 3288128  61372 415532    0    0     0     0 1078  252 99  1  0  0  0

100用户-物理表 --可以看出大量进程等待,大量内存交换,大量io read,同时cpu 100%

r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa st
0 101 256272  41388    368  69892  214 87758  6794 87758 2050 1676  2 24 18 56  0
0 102 453264  40804    372  66980   96 98496  1004 98496 1863 1023  0 16  0 84  0
1 100 673460  40776    372  66132   32 110098  1338 110098 2007 1145  0 17  0 83  0
1 100 825076  43780    232  68788  160 75828  1704 75828 1601  723  0 16  0 84  0
 

100用户-内存表  --可以看出没有进程等待,几乎没有物理读,cpu利用率不大

r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa st
34  0  42416 5617732  61476 415552    0    0     0     0 1073  227 55  0 44  0  0
 0  0  42416 5610540  61476 415552    0    0     0     0 1107  499 19  1 80  0  0
 0  0  42416 5610540  61484 415544    0    0     0    18 1123  501  0  0 100  0  0

300用户-内存表  --可以看出几乎没有进程等待,几乎没有io read,cpu利用率100%

r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa st
11  0 1321848 6119248   1628  14156  238    0   240     0 1154 2966 69  3 27  2  0
16  0 1321848 5620148   1628  14220   72    0    72     0 1171 7242 86  8  5  1  0
13  0 1321848 4954392   1636  14228    0    0     0    32 1251 1215 90  9  0  0  0
88  0 1321848 4063328   1636  14252    0    0     0     0 1286  748 90 10  0  0  0

500用户-内存表  --可以看到几乎没有进程等待,几乎没有io read,cpu利用率100%

 r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa st
240  0 1320204 6036864   1736  13816  434    0   434     0 1301 14330 10  5 80  5  0
211  0 1320204 4990428   1744  14560   70    0    70    48 1232 3097 86 12  1  0  0
140  0 1320204 4621776   1744  14596    6    0     6     0 1290 1103 94  5  0  0  0
89  0 1320204 3840700   1744  14680    0    0     0     0 1248  721 90 10  0  0  0

1000用户-内存表 --可以看到几乎没有进程等待,几乎没有io read,cpu利用率100%

r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa st
34  0 1319492 5974440   1956  15956   14    0    14    70 1319 1315 94  4  2  0  0
132  0 1319492 5667416   1956  15964    0    0     0     0 1293 3159 92  5  3  0  0
69  0 1319492 5056716   1956  15980    0    0     0     0 1296 1242 90 10  1  0  0




6.具体测试结果 --mysql情况

50用户-物理表
      
Statistics for the Userload:
User Load TPS kBPS Avg. Response Time (sec) Avg. Transaction Time (sec) Total Executions Total Rows Total Errors
50 25.00 1.600 0.955 0.955 250 500 0

100用户-物理表 由于系统负载太高所以停止测试


50用户-内存表  --每秒事务数35.72,平均执行时间0.249秒

Statistics for the Userload:
User Load TPS kBPS Avg. Response Time (sec) Avg. Transaction Time (sec) Total Executions Total Rows Total Errors
50 35.72 2.286 0.249 0.249 250 500 0

100用户-内存表  --每秒事务数71.44,平均执行时间0.245秒

Statistics for the Userload:
User Load TPS kBPS Avg. Response Time (sec) Avg. Transaction Time (sec) Total Executions Total Rows Total Errors
100 71.44 4.572 0.245 0.245 500 1000 0


300用户-内存表  -每秒事务数100.02,平均执行时间1.040秒

Statistics for the Userload:
User Load TPS kBPS Avg. Response Time (sec) Avg. Transaction Time (sec) Total Executions Total Rows Total Errors
300 100.02 7.601 1.040 1.040 1500 3000 0

500用户-内存表  --每秒事务数172.68,平均执行时间1.392秒

Statistics for the Userload:
User Load TPS kBPS Avg. Response Time (sec) Avg. Transaction Time (sec) Total Executions Total Rows Total Errors
500 172.68 11.051 1.392 1.392 2500 5000 0

1000用户-内存表  --每秒事务数227.36,平均执行时间0.963秒

Statistics for the Userload:
User Load TPS kBPS Avg. Response Time (sec) Avg. Transaction Time (sec) Total Executions Total Rows Total Errors
1000 227.36 14.551 0.963 0.963 5000 10000 0  




7.测试结果分析

内存表可以相对物理表提高不少性能,主要可以避免磁盘IO,增加反应时间,但是不能减少cpu的消耗,因为数据文件的扫描会耗费cpu,无论数据放在物理磁盘还是内存中
,内存表可以完全消除数据库的buffer pool lru链最近最常用算法的影响,因为本身就已经在内存中,可以实现各个不同session的结果集共享

需要确保内存表和原表的数据同步,可以写过程如

begin

insert into wdtmfw_new select * from wdtmfw a on duplicate key update fpsj=a.fpsj,lrsj=a.lrsj,fpry=a.fpry,ywy=a.ywy,xgbz=a.xgbz;

end;
/

类似于oracle merge into,对和primary key或者unique key不冲突的,插入新值,对于违反约束的,更新原有旧值




阅读(935) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~