parse-server icon indicating copy to clipboard operation
parse-server copied to clipboard

Too Many Logs

Open dplewis opened this issue 9 years ago • 9 comments

I've been using AWS for 8 months now. In the beginning I used up 10GB of block space and Parse Crashed. I figured out via SSH that the log files took up all the space.

I read that there was log file rotation but I now have a month full of logs taking up 27GB. My immediate solution is to buy more disk space to prevent crashing or manually delete the files via SSH.

Can winston be configured to keep 3 days of log files, do I need a cron job, or can parse server detect running out of disk space and stop making logs?

screen shot 2017-06-14 at 5 56 35 pm

dplewis avatar Jun 14 '17 23:06 dplewis

I'm not sure this is the exact solution you're looking for. We used to have the same problem as you. Specially when we got ddos or spamming.

To solve this problem, we move our parse-server to elasticbeanstalk and let it handle the logs rotation. Since then we never have this problem again. Also, if you already host your parse-server at AWS, the additional cost should be minimal (cloudwatch & etc ..)

pungme avatar Jun 15 '17 09:06 pungme

To solve this problem, we move our parse-server to elasticbeanstalk and let it handle the logs rotation.

It does handle log rotation for nginx, healthd, and nodejs. I don't think it rotates parse server logs /var/app/current/logs

the additional cost should be minimal

I have two instances currently paying $10 / month for each on just these log files and it will grow as our user base grows.

@pungme just out of curiosity how much block storage space do you have on AWS? How much of that is parse server logs?

dplewis avatar Jun 15 '17 15:06 dplewis

What being on elasticbeanstalk gives you is when your server crashes cause its out of disk space, you'll get a new one and not even know it happened ;)

What we use is a cron job that runs once a day and deletes logs that are older than x days old.

It would be a nice thing to add https://www.npmjs.com/package/winston-logrotate to parse-server and make the look back days configurable with a reasonable default (14 days?). Would be a great pull request if anyone were interested in trying it out ;)

acinader avatar Jun 15 '17 16:06 acinader

What being on elasticbeanstalk gives you is when your server crashes cause its out of disk space

It creates new instances but you have to pay for them. I think I found a solution. You can figure nginx to add parse logs to its log rotate. I'll give it a few days to see it if actually works and post the solution here.

What we use is a cron job that runs once a day and deletes logs that are older than x days old.

Does this run on parse locally?

It would be a nice thing to add https://www.npmjs.com/package/winston-logrotate

This looks great. I can look into it

dplewis avatar Jun 15 '17 17:06 dplewis

yes, I have a cron.txt file that is part of my file distribution to the server, which also includes the parse config, cloud code, etc. So yes, it is a cron job running on the parse server.

In my case:

55 2 * * * root /usr/bin/find /usr/src/parse-server/logs -type f -mtime +14 -exec rm -f -- {} \;

acinader avatar Jun 15 '17 17:06 acinader

cron.txt Where can I get that file and how do I test it.

dplewis avatar Jun 15 '17 17:06 dplewis

:).

If what you're asking is "how do I setup cron on my box"....

I think you indicated that you ssh into your parse server, so you can just ssh in, type crontab -e and then paste my line above, just making sure to change the path /usr/src/parse-server/logs to match the directory where your log files are.

acinader avatar Jun 15 '17 17:06 acinader

@acinader Thanks a lot man.

dplewis avatar Jun 15 '17 18:06 dplewis

i am using elasticbeanstalk with parse 2.6.4 i do not have this issue but yesterday suddenly my server was down for 10 min and elasticbeanstalk removed my old instance and created new instance now my old server is no more. can any one suggest how can i find what was the issue as i don't have old logs . its look like this is log issue only. do you think creating cron job is the best option for log issue as this set up is not at elasticbeanstalk . so do you guys able to find any solution which can be fit on elasticbeanstalk so if server removed new server have this cron info.

agwl-saurabh avatar Dec 13 '17 08:12 agwl-saurabh