JKorf / Binance.Net

A C# .netstandard client library for the Binance REST and Websocket Spot and Futures API focusing on clear usage and models
https://jkorf.github.io/Binance.Net/
MIT License
1.02k stars 420 forks source link

Performance issues #1357

Open KostyaLocal opened 3 months ago

KostyaLocal commented 3 months ago

Hello, I am using Bybit and Binance packages. Binance consumes almost 10 times more CPU time, profiler shows the time in waiting for data in sockets. Can you check ?

JKorf commented 3 months ago

Hi, both libraries use the same websocket mechanic under the hood, assuming you're using the latest versions. Could it be that Binance just processes more data? If you can provide some more context I can have a look:

Library version numbers? Which subscriptions are you using on both libraries? Is this happening immediately or after some time?

KostyaLocal commented 3 months ago

Could it be that Binance just processes more data?

No. I am using Binance UsdFuturesApi's SubscribeToUserDataUpdatesAsync + SubscribeToKlineUpdatesAsync, the last one has update frequency 250ms

Bybit: SubscribeToOrderUpdatesAsync, SubscribeToPositionUpdatesAsync, SubscribeToWalletUpdatesAsync (V5PrivateApi), SubscribeToCandleUpdatesAsync (V5LinearApi) Bybit has 100ms frequency updates on candles

Versions are latest from nuget: binance 9.6.1, bybit 3.6.1

KostyaLocal commented 3 months ago

I can't figure out what the function is. The load is immediately high after subscribing to updates. On a normal pc/laptop cpu usage is not felt, but when the application runs in the cloud on 1 shared CPU, the difference is noticeable Screenshot_9

upd: Connected the debugging symbols [External Call] System.Threading.PortableThreadPool+WorkerThread.WorkerThreadStart() 2379 (34,93 %) 1150