Skip to content
This repository has been archived by the owner on Jul 8, 2020. It is now read-only.

console.log is not meant to be used on prod #9

Open
eugef opened this issue Feb 21, 2018 · 4 comments
Open

console.log is not meant to be used on prod #9

eugef opened this issue Feb 21, 2018 · 4 comments

Comments

@eugef
Copy link

eugef commented Feb 21, 2018

console.log is synchronous and should be avoided in production - here is an explanation why: https://nodejs.org/docs/latest-v6.x/api/process.html#process_a_note_on_process_i_o

Probably getting rid of console.log might help to fix unexpected slow-downs on Lambdas.

@singingwolfboy
Copy link
Contributor

Do you have a suggestion for how to do logging properly on Lambda?

@eugef
Copy link
Author

eugef commented Feb 21, 2018

I am not very familiar with Lambda specifics, but maybe this solution can work for you http://www.daveeddy.com/2012/12/06/high-performance-nodejs-logging-with-consolelog-buffering/

@eugef
Copy link
Author

eugef commented Feb 21, 2018

Other option would be to try pino https://github.com/pinojs/pino

@singingwolfboy
Copy link
Contributor

I don't think that the issue we're seeing on Lambda is related to console.log. As I mentioned in yesterday's presentation, the problem we're seeing is that after all the work in the Lambda function is done, sometimes the function continues to run for the full 5 seconds. It happens rarely, inconsistently, and after all the other work is done, including all the logging. Even if using console.log is slow, it wouldn't explain that behavior.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants