json,serialize,msgpack比较

丈夫欲遂平生志,一载寒窗一举汤。这篇文章主要讲述json,serialize,msgpack比较相关的知识,希望能为你提供帮助。
速度
在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 Jan3 21:40 testjson
-rw-r--r-- 1 server server 22K Jan3 21:40 testmsgpack
-rw-r--r-- 1 server server 31K Jan3 21:40 testserialize

[yejianfeng@test34x-nova /tmp]$ ll test*
-rw-r--r-- 1 server server 28942 Jan3 21:40 testjson
-rw-r--r-- 1 server server 21993 Jan3 21:40 testmsgpack
-rw-r--r-- 1 server server 31537 Jan3 21:40 testserialize

msgpack是serizalize的69%
【json,serialize,msgpack比较】json是serizalize的91.8%

    推荐阅读