Skip to main content

A fast MessagePack RPC library

Project description

https://badge.fury.io/py/mprpc.png https://travis-ci.org/studio-ousia/mprpc.png?branch=master

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.

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)
print client.call('sum', 1, 2)

RPC client with connection pooling

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)

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

Performance Comparison

mprpc

% python benchmarks/benchmark.py
call: 9508 qps
call_using_connection_pool: 10172 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

Documentation

Documentation is available at http://mprpc.readthedocs.org/.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mprpc-0.1.9.tar.gz (81.5 kB view details)

Uploaded Source

File details

Details for the file mprpc-0.1.9.tar.gz.

File metadata

  • Download URL: mprpc-0.1.9.tar.gz
  • Upload date:
  • Size: 81.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for mprpc-0.1.9.tar.gz
Algorithm Hash digest
SHA256 b1b0ac7ee7acb6b4a8888434a2bef9d2790438e2410f4a79ce5f27e9e5900c90
MD5 3aff2d69df0c198c54921082db311609
BLAKE2b-256 0122111f632daf147fe9a34ed8878a66c428f962e9c8d9e6e71c55145dc06270

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page