Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

re-enable logging #10

Open
mmmaaatttttt opened this issue Jun 10, 2020 · 5 comments
Open

re-enable logging #10

mmmaaatttttt opened this issue Jun 10, 2020 · 5 comments
Labels
refactor Refactor of existing functionality
Milestone

Comments

@mmmaaatttttt
Copy link
Collaborator

there's a function that used to be part of the project which would log every request (

function logRequest(req) {
) and occasionally write these logs to a file. There were also two endpoints that would reveal summary statistics based on these log files: https://github.com/rithmschool/numbers_api/blob/master/app.js#L143-L149

However, the logging was consuming >100% CPU, mostly likely because the files were getting quite large and so reading / writing was expensive. Would be nice to bring this feature back, but we should think about how to better support it at current scale. (Redis? DB? something else?)

@mmmaaatttttt mmmaaatttttt added the refactor Refactor of existing functionality label Jun 10, 2020
@mmmaaatttttt mmmaaatttttt added this to the Version 1.1 milestone Jun 10, 2020
@maxnawa31
Copy link
Collaborator

maxnawa31 commented Jun 26, 2020

would it be possible to write logs to a db, and have some sort of cron job that deletes from the table at some time period? This is under the assumption that we don't need to be saving every single log. Or mabye log to a file first, then batch send it to a db at some point later in time?

@mmmaaatttttt
Copy link
Collaborator Author

@maxnawa31 yup for sure, originally it would write to a file and then occasionally just make a new file, but the file i/o operations were taking up a ton of cpu. i'm fine with adding a persistence layer, i just don't want to spend a bunch of money on it.

@maxnawa31
Copy link
Collaborator

could we maybe remove the file altogether, and instead write to an in-memory store (i.e. Redis) and then at some point write to the database? I suppose this would follow a 'Write-Back' protocol

@mmmaaatttttt
Copy link
Collaborator Author

yeah i'd be super down to explore this option @maxnawa31

@mmmaaatttttt
Copy link
Collaborator Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactor Refactor of existing functionality
Projects
None yet
Development

No branches or pull requests

2 participants