DEV Community

Cover image for I have built Zero: Fast and high performance Python RPC framework to build microservices
Azizul Haque Ananto
Azizul Haque Ananto

Posted on

I have built Zero: Fast and high performance Python RPC framework to build microservices

Zero is actually a RPC like framework that uses ZeroMQ under the hood for communication over tcp. That's why it's fast and super lightweight.

Without going into details let's just get started, cause one of the philosophy behind Zero is Zero Learning Curve 😃


Ensure Python 3.8+

  • Install Zero
pip install zeroapi
Enter fullscreen mode Exit fullscreen mode

Sadly the zero package is already there 🙁

  • Create a
from zero import ZeroServer

def echo(msg: str):
    return msg

async def hello_world():
    return "hello world"

if __name__ == "__main__":
    app = ZeroServer(port=5559)

Enter fullscreen mode Exit fullscreen mode

Please note that server RPC methods' args are type hinted. Type hint is must in Zero server.

See the method type async or sync, doesn't matter. 😃

  • Run it
python -m server
Enter fullscreen mode Exit fullscreen mode
  • Call the rpc methods
from zero import ZeroClient

zero_client = ZeroClient("localhost", 5559)

def echo():
    resp ="echo", "Hi there!")

def hello():
    resp ="hello_world", None)

if __name__ == "__main__":

Enter fullscreen mode Exit fullscreen mode

This is it! Tell me about the learning curve 😉

A bit of background

After working on large systems (with 50M+ users) over the years, one of the realization is - we waste a good amount of time writing boilerplate code and clients when working on microservices. And also we mostly use HTTP to communicate among them. This is really fine and usual but http has some overheads (headers, separate tcp connection every request etc). In case of microservice communications we can avoid these to get better performance.
Another thing is usual web frameworks are bulky and has a learning curve. So I was looking for something to reduce these costs and overheads.

Zero is still an idea, though the package is there already 😜 Zero solves the boilerplate code problem by using RPC like structure, you can just focus on the business logic. And use ZeroMQ rather HTTP to solve the overhead and reconnection problem. Though not both of them are solved explicitly, Zero is still a baby to learn more.

Pros and Cons of Zero over Flask or FastAPI


  • Inter-service communication is faster as using ZeroMQ and raw TCP under the hood.

  • Simple and easy to learn and use.

  • Extremely lightweight.

  • Super flexible zero can be used only for network communication and you can structure your codebase independently.


  • Not an HTTP framework, not so much traditional like Flask of FastAPI. People need to understand the actual usage. Like if you have fairly large microservice architecture and there are independent services that communicate among them, zero is a good substitute to reduce network overhead and other framework complexity. But if you only have a few services that communicate directly with the client/frontend, zero is not that much of a use.

  • Only Python based framework. Zero server can only be connected with Python zero client for now. (I have plan to introduce Go, in distant future btw)

  • You always need another HTTP framework as a gateway if your frontend communicates over HTTP, which is the usual and extremely common way.

I will be back!

There are more, I will write more about Zero in coming weeks. For now I will be looking towards comments, opinions and suggestions 🙏


Oldest comments (0)