ctubio / tribeca

Self-hosted crypto trading bot (automated high frequency market making) in node.js, angular, typescript and c++
https://127.0.0.1:3000
Other
95 stars 26 forks source link

Ressources consumption ? #75

Closed Camille92 closed 7 years ago

Camille92 commented 7 years ago

Hello there,

I realized that now that I use Tribeca in different markets, it can happen that I run out of "Credit CPU" on my instances.

Do you think an option "limited use of resources" can be possible?

I don't know what can be done and what is not necessary but I was thinking of: Auto cleaning Pong (& ping?) every x hours "Not loading the web UI if no one is connected (I don't know if it's possible). _ No graphs/stats (I don't know if it actually uses a lot of resources)

The goal is to limit the server cost by maximizing the number of instances per VPS. :)

Well I don't know if it's actually possible to do so please tell me :)

beegmon commented 7 years ago

I do notice that when running multiple instances of Tribeca the CPU utilization of each instance increases over time.

I have not checked with a single instance running, but so far 3 Tribeca instances start off at 2 -3% CPU utilization each, and slowly creep up until they eat through ALL the CPU available on my AWS instance.

I am wondering if this might have something to do with the addition of uWS a day or so ago, which replaced WS in Tribeca as I haven't seen this issue since pulling master a few days ago.

If you are running ubuntu this will walk you through how to use cpulimit to enforce a limit on the percentage of CPU utilization on a process - http://www.ubuntugeek.com/cpulimit-limit-the-cpu-usage-of-a-process.html

You can use cpulimit on centos/debian as well. However, this is not really a solution. Once the limit is hit, the process will be paused, and Tribeca won't be able to process new information. It also might screw with Garbage collection in nodejs enough to crash the process, or make Tribeca super out of sync with the websocket data...either giving you super bad trades, or causing it to loose connectivity and have to re-establish a connection...which is bad in my opinion.

If I get some time I might hook up a profiler to see what the CPU is spending its time on when it gets high, but this seems like a recent thing and am pointing at uWS being added as the last major change that might have caused this. Will update here if I find anything though.

ctubio commented 7 years ago

for me each running instance gets 8% of cpu :blush:

ctubio commented 7 years ago

since https://github.com/ctubio/tribeca/commit/29f091212f768d6674cd7d34aeeb608e9227b943 we dont have multiple proceses writing to the same file, maybe was some iowait in there? :sunflower: