1,今天在hacknews上看到很多人对messagepack的争论。首先了解什么是messagepack:messagepack is a binary-based efficient object serialization library. it enables to exchange structured objects between many languages like json. but unlike json, it is very fast and small.
2,messagepack的主要用途,作者解释说有两大用途:一是space-efficient storage for memcache entries (pinterest),节省空间类型的mamcache应用;另一个是用于rpc传输, this use case is fairly close to my original intent. when one is designing an rpc system, one of the first tasks is to specify and implement a communication protocol. this process can get pretty hairy as you need to worry about a lot of low-level issues like endian-ness. by using messagepack, one can skip designing and implementing a communication protocol entirely and accelerate development.
3,争议的地方是messagepack的benchmark说,他比protocolbuffer,json快很多倍。但是有人不相信,做个javasript下的测试(json与messagepack)。发现messagepack仅是压缩后的数据比json少10%左右,而压缩和解压时间则和json的解析器比起来要费时很多。
4,“msgpack vs. json: cut your client-server exchange traffic by 50% with one line of code”这篇文章使用了messagepack做服务器的优化,降低服务器的数据量,更加合理的利用带宽。作者强调了他们宁愿浪费客户端的0.5ms—1ms,但是服务器使用ruby的messagepack解析器,效率能够比json快5倍。
the difference to is, that msgpack is binary-based - this gives the possibility to make the exchanged data a) smaller and use less bytes, i guess we all know the advantages of that, however there is an even bigger advantage: b) it is faster to parse and encode, having a parser parse 40 bytes takes about twice as long as parsing 20 bytes.
messagepack作者也认为messagepack may not be the best choice for client-side serialization as described by the blog author.引用2的作者有点小悲剧。
5,bson是json的二进制形式,但是与json有语法不兼容的地方。但是messagepack保证语义上能够做到一致。
6,场景需求不同,导致技术的应用有所差异。
php试用messagepack
it's like json. but fast and small.
这句吸引了我,去瞧了下。
官网:http://msgpack.org
官方的安装方法忽悠人,msgpack目录下根本没php目录...只看到csharp,erlang,go,java,ruby等目录。
1,官方网站
2,
hn评论地址:
hn评论地址:
hn评论地址:
如对本文有疑问, 点击进行留言回复!!
*HDU1024.Max Sum Plus Plus(DP+滚动数组优化)
荐 「PHP」不依赖集成环境,使用Nginx手动配置Thinkphp运行环境
网友评论