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

[QUESTION] Performance and async_hooks #322

Closed
tfalvo opened this issue Jul 3, 2020 · 2 comments
Closed

[QUESTION] Performance and async_hooks #322

tfalvo opened this issue Jul 3, 2020 · 2 comments
Assignees
Labels
question Further information is requested

Comments

@tfalvo
Copy link

tfalvo commented Jul 3, 2020

Thank you guys for your good job with this library.
Pino is a great logger, and nestjs-pino provides a very nice integration for NestJS.

However, I'm interested to know your point of view about performance question we can read about async_hooks which is still in experimental status, and with the main reason of performance impact.
In addition to this (or linked with this), async_hooks is not recommended for production deployment.

As you mentioned in nestjs-pino docs, REQUEST scope can have performance issues. It's true and I fully agree.
But async_hooks have also some performance impact too.

It will be very friendly if you could share your opinion on this topic.
Thank you very much.

@tfalvo tfalvo added the question Further information is requested label Jul 3, 2020
@iamolegga
Copy link
Owner

Hi, I actually don't know what to say. As a short answer I personally didn't reach some limitations, but my projects aren't highload. So if you have some you are free to use something else or make some improvements to this lib 🙂 If you want to see some benchmarks and compares of different implementation (async hooks vs request scope), sorry, but I don't have enough time for them, but they are more then welcome. Main goal of this lib is possibility to track logs from different contexts, and it's obvious it has some overhead, as any other functionality. When creating this lib I've chose async hooks instead of request scope because from my point of view unexpected creation of services depended on logger on every request is a wrong behaviour and could lead to bugs in some situations when you have some side effects on creation.

About not recommended for production deployment: it depends on project's limitation and requirements. This lib is based on cls-hooked which is quite popular, and from that fact I can say that it's performance (and async hooks's one) is satisfying a lot of projects including mine. Moreover when nodejs#12 will be unsupported I'm planning to replace it with AsyncLocalStorage.

i hope this info is helpful to you 🙂

@tfalvo
Copy link
Author

tfalvo commented Jul 6, 2020

👍 Thank you for your answer @iamolegga. I really appreciate.
I don't have any experience yet with async_hooks, it's why I was a little worried about performance after some readings.
Maybe, I should take in account this performance topic, but without overestimating it.

Thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants