A lean Ruby client for the MessagePack-RPC protocol
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


MsgpackRpcClient CircleCI

A lean Ruby client for the MessagePack-RPC protocol

Use this gem to achieve reliable, fault-tolerant RPC with your microservices.

Differences from the "official" implementation (the msgpack-rpc gem)

The official implementation:

  • depends on the cool.io gem, labeled "retired" on the homepage.
  • does not re-establish connections.
  • designed to be asynchronous
  • displayed instability under high load in production
  • does not support JRuby

This implementation:

  • has no dependencies but the msgpack gem
  • is under 200 lines in one class
  • automatically re-establishes connections in the case of inevitable network errors, service restarts, deploys, and so on.
  • supports SSL
  • threadsafe
  • reliable
  • high load tested
  • used in production, with up to a 1000 requests per second in a single frontend request.
  • supports MRI from version 1.9.3 - for those who have a huge legacy app that you're dying to factor into microservices!
  • supports JRuby (but see installation notes)

However, this implementation does NOT support asynchronous calls - if you require this feature, it is not for you. However, from my experience, almost no Ruby applications require asynchronous communication.


Add this line to your application's Gemfile:

gem 'msgpack_rpc_client'

And then execute:

$ bundle

Or install it yourself as:

$ gem install msgpack_rpc_client


There was a bug in the jruby msgpack implementation that was fixed in this PR. Until it's released as a stable version (>1.0.0), you need to use the HEAD version of the msgpack gem:

gem 'msgpack_rpc_client'
# TODO remove once msgpack v1.0.1 or later is released
gem 'msgpack', git: 'https://github.com/msgpack/msgpack-ruby.git'


require 'msgpack_rpc_client'

client = MsgpackRpcClient.new(host: '', port: 12345)
response = client.call('HelloWorld', name: 'Ruby')
# You should re-use the client for all subsequent calls to the same server.
# It's never necessary to re-connect, and the client is threadsafe.

See the examples directory for a complete server-client example.


Bug reports and pull requests are welcome on GitHub at https://github.com/brightbytes/msgpack_rpc_client.


The gem is available as open source under the terms of the MIT License.