What's MessagePack?

Fast and Compact Serialization

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.

Typical small integer (like flags or error code) is saved only in 1 byte, and typical short string only needs 1 byte except the length of the string itself. [1,2,3] (3 elements array) is serialized in 4 bytes using MessagePack as follows:

> require 'msgpack'
> msg = [1,2,3].to_msgpack  #=> "\x93\x01\x02\x03"
> MessagePack.unpack(msg)   #=> [1,2,3]

Scalable RPC

MessagePack-RPC is cross-language RPC library for client, server and cluster applications. Because it releases you from complicated network programming completely and provides well-designed API, you can easily implement advanced network applications with MessagePack-RPC.

require 'msgpack/rpc'
class MyHandler
  def add(x,y) return x+y end
end
svr = MessagePack::RPC::Server.new
svr.listen('0.0.0.0', 18800, MyHandler.new)
svr.run
require 'msgpack/rpc'
c = MessagePack::RPC::Client.new('127.0.0.1',18800)
result = c.call(:add, 1, 2)  #=> 3

Serialization + Desrialization Speed Test

MessagePack Serialization + Desrialization Speed Test

In this test (source code), it measured the elapsed time of serializing and deserializing 200,000 target objects. The target object consists of the three integers and 512 bytes string.

RPC Feature Comparision

MessagePack-RPC Thrift Avro
Asynchronous RPC OK OK OK
Parallel Pipelining OK NG NG
Thrift IDL OK OK NG
Dynamic Typing OK NG OK
Connection pooling OK NG NG
Delayed return OK NG NG
Event-driven I/O OK NG NG

Information of these related projects are available from: JSON, Protocol Buffers, Thrift, Avro.

Getting Started

Ruby

> gem install msgpack
> gem install msgpack-rpc

Ruby implementation supports zero-copy facility.

Python

> easy_install msgpack-python

More details for the package is available at the PyPI page.

Perl

> cpan Data::MessagePack
> cpan AnyEvent::MPRPC

C/C++

port install msgpack  (MacPorts)

Download msgpack-0.5.4.tar.gz and build it. RPC for C++ is at msgpack-rpc-0.3.0.tar.gz. C/C++ implementation supports zero-copy facility.

Java

Maven2 repository is located here. See javadoc for actual APIs. IDL may be greatly useful with Java.

Source code is available from here, and test cases will give you a sample usage.

Haskell

> cabal install msgpack
> cabal install msgpack-rpc

See hackageDB page (msgpack, msgpack-rpc) for details.

Learn More

Serialize Design

More details about design of MessagePack-RPC.

RPC Design

More details about design of MessagePack.

Articles and Presentations

Articles and slides about the designs and comparisons.

Serialize Spec

MessagePack format specification.

RPC Spec

MessagePack-RPC protocol specification.

IDL Quick Start

Start MessagePack-RPC Interface Definition Language.

Mailing Lists

If you use MessagePack, please subscribe to the MessagePack mailing list. If you'd like to contribute to MessagePack, please subscribe to the MessagePack developers mailing list.


Google Groups
Subscribe to MessagePack
Email:
Visit this group

Google Groups
Subscribe to MessagePack Developers
Email:
Visit this group

Chat

Many of the MessagePack developers and community members hang out in the #msgpack channel on irc.freenode.net. If you are new to IRC and don't have a client, you can use a web-based client.

Issues

Issues are managed on Redmine (Issues). Note that you need to create an account on the registration page to add issues.

Sources

Sources are located at github. Send pull requests to msgpack account.