Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

https://github.com/healeycodes/websocket-benchmarker

Benchmark a WebSocket server's message throughput ⌛
https://github.com/healeycodes/websocket-benchmarker

benchmark python websockets

Last synced: about 1 month ago
JSON representation

Benchmark a WebSocket server's message throughput ⌛

Lists

README

        

[![Build Status](https://travis-ci.org/healeycodes/websocket-benchmarker.svg?branch=master)](https://travis-ci.org/healeycodes/websocket-benchmarker)

## :radio: WebSocket Benchmarker :watch:

*Message throughput* is how fast a WebSocket server can parse and respond to a message. Some people consider this to be a good reference of a framework/library/server's performance. This tool measures the message throughput under load by mocking concurrent clients.


![](https://github.com/healeycodes/websocket-benchmarker/blob/master/images/header.png)


---

###### 2019.01.26

Now with 100% more bleeding edge :zap: [asyncio](https://docs.python.org/3/library/asyncio.html) goodness.

---


### Installation

Python 3.6.5+.

`pip install -r requirements.txt`


### Usage

This program expects the host to be an echo server and measures the time between sending a message and recieving the same message back from the host. It performs this for a number of client connections simultaneously and is designed to produce repeatable results.

`python bench.py` will launch the benchmark and print statistics to stdout. If the log file path is to a non-file then one will be created otherwise results will be appended to the existing file.

The raw results are in CSV format with each line representing a client's roundtrip times.

E.g., `0.1, 0.1, 0.1` for one client performing three roundtrips.


| Arg | Description | Default |
| ----- |:---------------------------------------|:----------------|
| `--h` | Host address of WebSocket server | `localhost:3000`|
| `--n` | Number of clients to create | `1000` |
| `--c` | Number of concurrent clients | `64` |
| `--r` | Roundtrips per client | `5` |
| `--s` | Message size in characters | `30` |
| `--l` | Path to create or append to a log file | `./log.txt` |


### Tests

Full end-to-end testing via unittest.

```
python -m unittest
...
----------------------------------------------------------------------
Ran 3 tests in 8.371s

OK
```


### License

MIT (c) 2019 healeycodes.

Inspiration taken from the unmaintained JavaScript project [websocket-benchmark](https://github.com/cargomedia/websocket-benchmark).