Testing gRPC performance in Python

Measuring the performance of the Python gRPC implementation with a simple asyncio client and server

tl;dr Python gRPC implementation appears to be slower than websockets. You can find the results here.

Yesterday I had some fun playing a little bit with gRPC. I've created a simple asyncio client and a server in Python that was supposed to be similar to the ones I've written for websockets.

I must say that I've really liked implementing it, as gRPC is very easy to work with. You essentially get most of the implementation out of the box. You only need to worry about implementing the interfaces for the functions, and you get compression and serialization for free. The performance side of things isn't that bad either, I mean processing 90k messages (100 bytes each)/s in Python with a single process is still something that is satisfactory in most cases. I suspect that with a bit of optimization it can surpass websockets, though that might require usage of Cython/C lib calls.

Of course, there are some differences between gRPC and websockets, especially around defining long lived connections and the ability to forward traffic from HTTP to web sockets. I think gRPC gives you better abstraction layer, as usually with websockets you end up writing something similar to what gRPC solves out of the box.

To summarize, I would recommend you to check out for yourself gRPC, as it is a really nice and useful tool in a programmer's toolbox.