Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/studio-ousia/mprpc
A fast Python RPC library
https://github.com/studio-ousia/mprpc
Last synced: about 2 months ago
JSON representation
A fast Python RPC library
- Host: GitHub
- URL: https://github.com/studio-ousia/mprpc
- Owner: studio-ousia
- License: other
- Archived: true
- Created: 2013-10-14T03:15:41.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2022-12-27T07:13:23.000Z (over 1 year ago)
- Last Synced: 2024-07-26T13:28:28.835Z (2 months ago)
- Language: Cython
- Homepage: http://mprpc.readthedocs.org
- Size: 541 KB
- Stars: 337
- Watchers: 19
- Forks: 57
- Open Issues: 16
-
Metadata Files:
- Readme: README.rst
- License: LICENSE
Awesome Lists containing this project
README
mprpc
=====⚠️ **NOTICE:** This library is not actively maintained. Please consider using other alternatives such as `gRPC `_.
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:
.. code-block:: bash
$ pip install mprpc
Alternatively,
.. code-block:: bash
$ easy_install mprpc
Examples
--------RPC server
^^^^^^^^^^.. code-block:: python
from gevent.server import StreamServer
from mprpc import RPCServerclass SumServer(RPCServer):
def sum(self, x, y):
return x + yserver = StreamServer(('127.0.0.1', 6000), SumServer())
server.serve_forever()RPC client
^^^^^^^^^^.. code-block:: python
from mprpc import RPCClient
client = RPCClient('127.0.0.1', 6000)
print client.call('sum', 1, 2)RPC client with connection pooling
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^.. code-block:: python
import gsocketpool.pool
from mprpc import RPCPoolClientclient_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
^^^^^^^.. image:: https://raw.github.com/studio-ousia/mprpc/master/docs/img/perf.png
:width: 550px
:height: 150px
:alt: Performance Comparisonmprpc
~~~~~.. code-block:: bash
% python benchmarks/benchmark.py
call: 9508 qps
call_using_connection_pool: 10172 qpsOfficial MesssagePack RPC
~~~~~~~~~~~~~~~~~~~~~~~~~.. code-block:: bash
% pip install msgpack-rpc-python
% python benchmarks/benchmark_msgpackrpc_official.py
call: 4976 qpsZeroRPC
~~~~~~~.. code-block:: bash
% pip install zerorpc
% python benchmarks/benchmark_zerorpc.py
call: 655 qpsDocumentation
-------------Documentation is available at http://mprpc.readthedocs.org/.