Bitcoin Forum
September 16, 2026, 09:14:37 AM *
News: Latest Bitcoin Core release: 31.1 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: UNICORN Binance WebSocket API: picows support — up to 2× throughput  (Read 14 times)
alice_bob (OP)
Sr. Member
****
Offline

Activity: 323
Merit: 250



View Profile WWW
September 13, 2026, 04:55:15 PM
 #1

I’ve added optional [`picows`](https://github.com/tarasko/picows) support to the UNICORN Binance WebSocket API (UBWA).

The goal was simple: find out whether replacing the pure-Python `websockets` implementation with the Cython-based picows actually makes a difference inside the full UBWA stack.

For small Binance messages, it does.

Some benchmark results:

```
aggTrade
websockets: 201,912 msgs/s
picows:     403,316 msgs/s
speedup:    2.00x

kline
websockets: 195,460 msgs/s
picows:     371,019 msgs/s
speedup:    1.90x

depth20
websockets: 153,187 msgs/s
picows:     259,960 msgs/s
speedup:    1.70x
```

I also ran both implementations for 24 hours in parallel against live Binance:

* ~138 million messages per implementation
* ~50 GB received each
* picows: 9.5% average CPU
* websockets: 12.8% average CPU
* no picows-specific stalls or unrecoverable streams
* picows ended with 23 MB lower RSS

The benchmark also uncovered several issues in UBWA itself, including unnecessary work in the hot receive loop and some proxy/failure-path bugs. Those were fixed as part of the work.

`websockets` remains the default for now.

The reason isn’t performance — picows clearly performs well. The reason is production history. A 24-hour soak and 138 million messages are useful evidence, but not yet equivalent to months of usage across many different systems.

So picows is opt-in while more real-world feedback comes in.

Full write-up, methodology and results:

https://blog.technopathy.club/picows-in-unicorn-binance-websocket-api-up-to-2-the-throughput-opt-in-for-now

GitHub discussion / feedback:
https://github.com/oliver-zehentleitner/unicorn-binance-websocket-api/issues/477

If anyone here runs high-volume Binance WebSocket workloads, I’d be especially interested in independent CPU/memory numbers.

Creator of the UNICORN Binance Suite — 6 open source Python libraries for automated trading systems on Binance. Built and maintained entirely solo since 2019.
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!