json,serialize,msgpack比较
2014-01-03 21:46 轩脉刃 阅读(2195) 评论(0) 编辑 收藏 举报速度
在redis中存入同样的压缩数据,取操作执行两个操作:
1 从redis中取
2 解压
3 统一json压缩后放出
ab测试:
[yejianfeng@openstack ~/httpd/usr/bin]$ ./ab -n 10000 -c 10 'http://10.16.15.118:7701/location/testGet?type=json'
Requests per second: 265.11 [#/sec] (mean)
Requests per second: 267.58 [#/sec] (mean)
Requests per second: 275.48 [#/sec] (mean)
Requests per second: 263.11 [#/sec] (mean)
Requests per second: 264.99 [#/sec] (mean)
[yejianfeng@openstack ~/httpd/usr/bin]$ ./ab -n 10000 -c 10 'http://10.16.15.118:7701/location/testGet?type=serialize'
Requests per second: 297.52 [#/sec] (mean)
Requests per second: 322.57 [#/sec] (mean)
Requests per second: 303.59 [#/sec] (mean)
Requests per second: 289.89 [#/sec] (mean)
Requests per second: 317.26 [#/sec] (mean)
[yejianfeng@openstack ~/httpd/usr/bin]$ ./ab -n 10000 -c 10 'http://10.16.15.118:7701/location/testGet?type=msgpack'
Requests per second: 288.07 [#/sec] (mean)
Requests per second: 306.73 [#/sec] (mean)
Requests per second: 313.61 [#/sec] (mean)
Requests per second: 289.49 [#/sec] (mean)
Requests per second: 307.84 [#/sec] (mean)
压缩比例:
[yejianfeng@test34x-nova /tmp]$ ll -h test*
-rw-r--r-- 1 server server 29K Jan 3 21:40 testjson
-rw-r--r-- 1 server server 22K Jan 3 21:40 testmsgpack
-rw-r--r-- 1 server server 31K Jan 3 21:40 testserialize
[yejianfeng@test34x-nova /tmp]$ ll test*
-rw-r--r-- 1 server server 28942 Jan 3 21:40 testjson
-rw-r--r-- 1 server server 21993 Jan 3 21:40 testmsgpack
-rw-r--r-- 1 server server 31537 Jan 3 21:40 testserialize
msgpack是serizalize的69%
json是serizalize的91.8%
实时了解作者更多技术文章,技术心得,请关注微信公众号“轩脉刃的刀光剑影”
本文基于署名-非商业性使用 3.0许可协议发布,欢迎转载,演绎,但是必须保留本文的署名叶剑峰(包含链接http://www.cnblogs.com/yjf512/),且不得用于商业目的。如您有任何疑问或者授权方面的协商,请与我联系。