You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Performance degradation in Binance Pro watch_trades() under high message rates #30944
I am using CCXT Pro with Binance USD-M Futures and consuming trade ticks via watch_trades().
Under low message rates, the data is delivered without noticeable delays. However, when the incoming trade rate increases to thousands of ticks, significant delays appear between WebSocket message reception inside the library and delivery of the corresponding trades to the application through watch_trades().
This is not exchange-to-WebSocket network latency. The delay occurs inside the CCXT processing pipeline under high load.
To investigate this, I implemented an alternative WebSocket consumer with an interface similar to watch_trades(). In comparative tests, it delivered trade ticks approximately 3–5 times faster under the tested conditions.
Questions
Is there a way to optimize the built-in watch_trades() processing path for high message rates?
Could the bottleneck be related to synchronous message processing, trade-cache operations, or batch extraction?
Would it make sense to provide an optional high-throughput mode that prioritizes low delivery latency, alongside the existing behavior?
I can share further benchmark details to help identify the bottleneck.
The buffered messages are processed synchronously in a loop. The subsequent path includes JSON decoding, Binance-specific message routing, trade normalization, ArrayCache updates and batch extraction in watch_trades().
Under high message rates, I suspect that synchronous processing and/or cache extraction may cause a growing backlog and delay delivery to the consumer, potentially affecting other tasks sharing the event loop.
My alternative implementation:
asyncdefwatch_trades(self, symbol):
awaitself._ensure_symbol(symbol)
awaitself.start()
state=self._streams[symbol]
# Wait for data, then drain the symbol's queue.
...
A shared aiohttp WebSocket transport handles incoming trade messages, parses the required fields and puts normalized trades into per-symbol asyncio.Queue instances. The consumer retrieves available trades directly from its queue, without CCXT's trade-cache and slicing path.
In my comparative tests, this implementation delivered ticks approximately 3–5 times faster under the tested conditions.
This suggests that the difference may lie in message processing, buffering or batch delivery rather than network latency alone. The exact contribution of each CCXT stage still needs to be isolated by profiling.
Could the receive-buffer processing and ArrayCache extraction paths be reviewed for high-throughput workloads? Would an optional low-latency mode with a lighter processing path be feasible?
Activity
algosfox commentedon Oct 21, 2026
Additional findings: CCXT Pro vs. a lightweight WebSocket consumer
I reviewed the trade-delivery path in CCXT Pro and compared it with my alternative implementation.
CCXT Pro processing path:
The buffered messages are processed synchronously in a loop. The subsequent path includes JSON decoding, Binance-specific message routing, trade normalization,
ArrayCacheupdates and batch extraction inwatch_trades().Under high message rates, I suspect that synchronous processing and/or cache extraction may cause a growing backlog and delay delivery to the consumer, potentially affecting other tasks sharing the event loop.
My alternative implementation:
A shared
aiohttpWebSocket transport handles incoming trade messages, parses the required fields and puts normalized trades into per-symbolasyncio.Queueinstances. The consumer retrieves available trades directly from its queue, without CCXT's trade-cache and slicing path.In my comparative tests, this implementation delivered ticks approximately 3–5 times faster under the tested conditions.
This suggests that the difference may lie in message processing, buffering or batch delivery rather than network latency alone. The exact contribution of each CCXT stage still needs to be isolated by profiling.
Could the receive-buffer processing and
ArrayCacheextraction paths be reviewed for high-throughput workloads? Would an optional low-latency mode with a lighter processing path be feasible?