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

Performance and stability requirement #12

Closed Camille92 closed 7 years ago

Camille92 commented 7 years ago

Hello Carles,

I've recently tried the manual installation instead of the Docker one. It has been working quite good just for one point, when I check "forever list" the uptime is always very low about 2 to 5 hours (which would be fine is the EWMA and apr values were not reseted after a crash).

So I wanted to ask you how do you achieve a good stability of your system? I think it is RAM related, do I need to limit the ram usage of Mongod or tribeca itself ?

Config: Mean by Bitnami on AWS EC2 instances. I tried a few things without great success, removing the swap of the instance and moving from a t2 micro (1gb ram) to a t2 small (2gb).

Any tip welcome!

ctubio commented 7 years ago

Hello Camille'¡ is true that only the history of trades is saved in the database. We can change that to save also ewma, and to use the stored ewma values on boot if those are fair recent.

For me the application runs continuosly without crash for weeks; im using a 50/50 splitted t2.micro (1GB) in AWS were i run 2 instances of tribeca, each one takes maximum 200Mb, so i still have 300Mb free in each splitted instance. In this 300Mb im running MongoDB, InfluxDB and Grafana nicely, were MongoDB takes only less than 5Mb of memory because only trades are saved.

I had problems of apps crashing until i added swap memory to the t2.micro instance. After adding 8Gb of swap memory (http://stackoverflow.com/questions/17173972/how-do-you-add-swap-to-an-ec2-instance [remember also to set a swapiness of 10 instead of 60 to avoid to aggressively use the swap like in http://askubuntu.com/questions/103915/how-do-i-configure-swappiness]) i end up with a maaaaaybe a slower machine on peaks, but most important with a non crashing machine on peaks.

Since you are running the same application as me, im pretty sure you dont need more than 200Mb of RAM to run tribeca, but maybe you have other apps running together that are taking the resources?

Storing the ewma values in the database may help, but is not a real solution of the underlying problem, and also ewma values are only useful if those are fair recent (so ewma values stores in the database really have a very short lifetime that im not sure it worth the effort to store them), but let me know if you think the opposite'¡

In the frontend of tribeca, i see a used memory of 150Mb maximum, what value shows in yours?

Let me close the issue because is not fixable in the code of the app, but feel free to add any comments of log files that you consider, i will love to help!

ctubio commented 7 years ago

im also running http://www.iredmail.org/ in the very same AWS instance, and it takes more than 500Mb of RAM, so im pretty sure tribeca+mongodb does not need more than 500Mb to run, in practice, even less than 250Mb is OK.

do you have any relevant output in tribeca.log or in dmesg? thanks'¡

Camille92 commented 7 years ago

Thank you for your detailed answer. It is amazing all the stuff you keep on one instance!

I'm adding 2go of swap to see if it fix the issue:

I now have two instances one with docker (amazon linux) and one using manual install (mean).

On the docker one, i can easily access the page, tribeca shows 110Mb on the frontpage and I still have a lot of free ram.

However I can't barely access the web Ui on the other one (before chrome tells me that the page is not responding), but there is apparently still some ram left.

I don't have anything else running on the instances.

I'm going to try a clean install on a bitnami nodejs instance to see if I maybe messed up something.

I'll let you know and thank you again for the help!

Camille92 commented 7 years ago

Well I think I'll just go back to Docker ahah.

I spent already too much time trying to understand what is not an actual problem.

Good day!