Testing websockets performance in Python

Measuring the performance of the websockets Python library with a simple server and a client.

tl;dr Python has a really good websockets library, see the performance benchmark.

I was curious about the performance of the websockets library, so I have decided to write a simple server and a client using pure Python.

The tool could be used to test your assumptions about what setup would work best in your environment (i.e. how big the batches should be, whether to use compression).

I have only shared the results from a local test, so they are predictable. The fastest method is to just use a large enough batch size with no compression. As soon as the network becomes an issue, I would recommend to use a decent enough compression algorithm.

As shown, GZIP is not that bad, but it could be better. I would recommend to do more testing with some other compression algorithms, ideally ZSTD, as it should be faster than LZ4.

Overall, I deem the results to be satisfactory and would happily recommend to people to use the websockets library.