This is a fork of the mprpc library maintained by the Lab for Social Machines at the MIT Media Lab. It contains two changes:
- Integrates Unix domain socket support from a-sk/unix_socket_support.
- Updates the msgpack dependency and usage to be the maintained msgpack library, rather than msgpack-python.
mprpc is a lightweight MessagePack RPC library. It enables you to easily build a distributed server-side system by writing a small amount of code. It is built on top of gevent and MessagePack.
To install mprpc, simply:
$ pip install mprpc
Alternatively,
$ easy_install mprpc
from gevent.server import StreamServer
from mprpc import RPCServer
class SumServer(RPCServer):
def sum(self, x, y):
return x + y
server = StreamServer(('127.0.0.1', 6000), SumServer())
server.serve_forever()
from mprpc import RPCClient
client = RPCClient('127.0.0.1', 6000)
print client.call('sum', 1, 2)
import gsocketpool.pool
from mprpc import RPCPoolClient
client_pool = gsocketpool.pool.Pool(RPCPoolClient, dict(host='127.0.0.1', port=6000))
with client_pool.connection() as client:
print client.call('sum', 1, 2)
mprpc significantly outperforms the official MessagePack RPC (1.8x faster), which is built using Facebook's Tornado and MessagePack, and ZeroRPC (14x faster), which is built using ZeroMQ and MessagePack.
% python benchmarks/benchmark.py
call: 9508 qps
call_using_connection_pool: 10172 qps
% pip install msgpack-rpc-python
% python benchmarks/benchmark_msgpackrpc_official.py
call: 4976 qps
% pip install zerorpc
% python benchmarks/benchmark_zerorpc.py
call: 655 qps
Documentation is available at http://mprpc.readthedocs.org/.