MCache压力测试-3

<section class="post-108 post type-post status-publish format-standard hentry category-work-diary tag-mcache-">
   <div class="title">

MCache压力测试-3

04.10.2012, [Work diary](http://tan.im/s/work-diary "查看 Work diary 中的全部文章"), by [jarit](http://tan.im/aauthor/jarit "由 jarit 发布").
</div>
<div class="entry">

经过调整几个参数,GC的表现越来越理想了。


实践发现,对象的大小对TPS影响明显,压128~500k之间随机大小时TPS 2w,压128~10k之间随机时TPS达到40+w(后面补个对比图)。


现在稳定的数据是:


测试参数:

curl “localhost:8088/perf.do?method=mcache&times=90000000000&min=128&max=10240&key=1000000&expire=3000&threads=5&t=2000″

TPS情况:

get/s:478087
hit rate: 97.21%
put/s:13328
CPU 20% Load 1.5
CMS GC 50分钟一次

配置如下:

-Xmx2g
-Xms2g
-Xmn1g
-verbose:jni
-verbose:gc
-Xloggc:./log/gc.log
-XX:SurvivorRatio=8
-XX:MaxTenuringThreshold=15
-XX:+PrintGCDateStamps
-XX:+PrintGCTimeStamps
-XX:+PrintGCDetails
-XX:+PrintTenuringDistribution
-XX:+PrintCommandLineFlags
-XX:+PrintTenuringDistribution
-XX:+HeapDumpOnOutOfMemoryError
-XX:-OmitStackTraceInFastThrow
-XX:+DisableExplicitGC
-XX:+UseConcMarkSweepGC
-XX:ParallelCMSThreads=4
-XX:+CMSClassUnloadingEnabled
-XX:+UseCMSCompactAtFullCollection
-XX:CMSInitiatingOccupancyFraction=80
-XX:MaxDirectMemorySize=2g

同时,发现了设计上的缺陷:


之前的测试,都是在命中率97%左右的情况,对象数增长被限制,OLD大概100M左右恒定回收不掉,但是不影响。


通过扩大key的随机范围(足够大),将命中率降到0.5%,意味着,操作是以put为主,这样,很快OLD区就占满了,然后开始FGC,压测指标直速下降,并且,FGC并不能释放内存。


测试数据:

curl “localhost:8088/perf.do?method=mcache&times=90000000000&min=51200&max=51200&key=10000000000&expire=3000&threads=5&t=1000″

运行情况:

12/04/10 15:08:55 hit:0.00% gps:82092 put/s:82085 in:3.93g out:200.00k
12/04/10 15:09:31 hit:0.19% gps:80922 pps:80771 in:3.86g out:7.42m
12/04/10 15:10:41 hit:0.54% gps:64848 pps:64495 in:3.11g out:17.38m
12/04/10 15:10:42 hit:0.53% gps:57139 pps:56838 in:3.12g out:16.94m
12/04/10 15:10:52 hit:0.51% gps:5860 pps:5830 in:2.53g out:13.23m
12/04/10 15:11:00 hit:0.40% gps:1624 pps:1618 in:644.29m out:2.59m
12/04/10 15:13:44 hit:0.49% gps:1998 pps:1988 in:821.09m out:4.05m
12/04/10 15:14:33 hit:0.55% gps:239 pps:238 in:573.24m out:3.17m
12/04/10 15:17:06 hit:0.30% gps:2309 pps:2302 in:670.36m out:2.05m

上边的数据跟JVM GC数据一致,OLD内存一直涨到1G,开始FGC,并且释放不掉


解决办法:


中间对象长驻内存不能释放,就是内存泄露了。MCache同要有一种清理过期的对象并释放,让GC有机会回收。


假设过期对象能及时回收,堆的大小至少要大于过期时间内活跃对象总大小。关键点还是会回到堆内存大小、单个中间对象大小、过期时长几个因素上来了。

</div>
<div class="post-meta">
                    标签:[MCache 压力测试](http://tan.im/t/mcache-%e5%8e%8b%e5%8a%9b%e6%b5%8b%e8%af%95)<div class="clear"></div>
</div>

个人资料
0_0
等级:7
文章:111篇
访问:5.0w
排名: 6
上一篇: 基于管道模式的容器设计
下一篇:MINA网络通信框架
猜你感兴趣的圈子:
阿里中间件技术交流圈
标签: xx、hit、mcache、pps、gps、面试题
隐藏