Any good tools/services for debugging production NestJS (node) memory usage issues?
Posted by ilikeguac@reddit | ExperiencedDevs | View on Reddit | 7 comments
Like the title says I've been looking into this for some time now and haven't found any real solutions. I've tried out Sentry's profiling but it basically just showed overall memory usage which was nowhere near granular enough.
The main use case is when we have operations that use too much memory, I would like an easier way to identify what specifically is using that excess memory. Similarly, would like an easier way to identify the cause of memory leaks (even if its just pointing me in the right direction).
Any ideas would be appreciated. Thanks!
Irish_and_idiotic@reddit
OTel with profiling is what you need. Loads of ways to do it
Suepahfly@reddit
If you can replicate it on your local machine you can point chrome’s devtools to your node instance iirc.
ilikeguac@reddit (OP)
The issue is thats it generally hard to recreate locally unless we know what area of code is causing it.
Internal_Outcome_182@reddit
Add observability tools/monitoring/logging
ilikeguac@reddit (OP)
Already having logging and observability tools but don't have one that specifically helps with this issue which was the reason for the post
se-podcast@reddit
I have used Datadog's Continuous Profiler in the past. For NodeJS, you'll likely be interested in their `Heap Live Size` statistic:
"The amount of heap memory allocated by each function that has not yet been garbage collected. This is useful for investigating the overall memory usage of your service and identifying potential memory leaks."
https://docs.datadoghq.com/profiler/profile_types/?tab=nodejs
If you're a startup, you can get a good amount of free usage using their offering here: https://www.datadoghq.com/partner/datadog-for-startups/
ilikeguac@reddit (OP)
Thanks yeah was starting to look into that