Tucsky / aggr

Cryptocurrency trades aggregator
https://charts.aggr.trade/
GNU General Public License v3.0
864 stars 247 forks source link

high cpu usage #65

Closed adaamz closed 3 years ago

adaamz commented 3 years ago

Hi, is there any recommendation on what settings should lower cpu usage? I have 5s chart refresh time, show only liquidations tab and the v3 application page takes 10-20% cpu, that is insane for almost static page :)

Tucsky commented 3 years ago

Hi @adaamz I'm sorry this app is too demanding for your CPU power.

For trade feed you can try lowering rendered trade count (but default is already low) or disabling animations. Chart is a very high cpu consumer as well but if you say you already have it set to 1 update every 5s this is already extremely low. Not much you can do, sorry

Tucsky commented 3 years ago

Aggr not static at all, quite the opposite actually Unlike most platforms (tv, tradinglite, exo etc) that use their own centralized server to dispatch aggregated / compressed market data, aggr connect directly to the exchanges api processing thousand RAW trades per sec. Default settings lead to 14 concurrent websocket connections each handling multiple channel subscriptions. On average if you let it run for 1 day it will process about 10M trades.

I put A LOT of time and attention to performance, even tho I tend to agree you need a decent computer to run this thing smoothly. All the processing there is done for a reason, at this stage I'm afraid there is not much room for improvement (in the code itself that is)

Tucsky commented 3 years ago

https://webmshare.com/Pbe40

Here I let it run for on default settings, see the CPU usage I get

Tucsky commented 3 years ago

Also, setting more reasonable thresholds and longer aggregation might help since more trades will get "merged" image image default threshold are too degen imo

adaamz commented 3 years ago

Thanks for your replies, really appreciate it. Without chart and aggregation changed to 1000ms (never thought it's editable) it takes 5-10% cpu, which is better 👍🏻. In this case when you don't have any own backend then it is sure thing that client must do the calculations on itself and cpu consumption is much higher than static page, seems logic to me. I will close this issue as you provided some hints which can decrease cpu usage, thx again.