A lightweight MessagePack RPC library using Python gevent
Project description
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 the top of gevent and MessagePack.
Installation
To install mprpc, simply:
$ pip install mprpc
Alternatively,
$ easy_install mprpc
Examples
RPC server
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()
RPC client
from mprpc import RPCClient
client = RPCClient('127.0.0.1', 6000)
client.open()
print client.call('sum', 1, 2)
RPC client with connection pooling
import gsocketpool.pool
from mprpc import RPCClient
client_pool = gsocketpool.pool.Pool(RPCClient, dict(host='127.0.0.1', port=6000))
with client_pool.connection() as client:
print client.call('sum', 1, 2)
Performance
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.
Results
mprpc
% python benchmarks/benchmark.py
call: 9061 qps
call_using_connection_pool: 9790 qps
Official MesssagePack RPC
% pip install msgpack-rpc-python
% python benchmarks/benchmark_msgpackrpc_official.py
call: 4976 qps
ZeroRPC
% pip install zerorpc
% python benchmarks/benchmark_zerorpc.py
call: 655 qps
Environment
OS: Mac OS X 10.8.5
CPU: Intel Core i7 2GHz
Memory: 8GB
Python: 2.7.3
Documentation
Documentation is available at http://mprpc.readthedocs.org/.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file mprpc-0.1.tar.gz
.
File metadata
- Download URL: mprpc-0.1.tar.gz
- Upload date:
- Size: 5.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d078709da6a6eebc7f6c881d1d61c60e752dc700620546941bef7439d260c628 |
|
MD5 | eddb28e52731be6deeee6b1057784e09 |
|
BLAKE2b-256 | c40a8aba6a0f1718cd680f5f78e4b293086cb74865fd30b8a3ba6eb9aaa013c2 |