[Node] agent causing high memory usage

Node Agent causing high memory usage

We are using NewRelic to monitor our backgrounds jobs (with startBackgroundTransaction), and we were experiencing memory spikes in long processes.

await newrelic.startBackgroundTransaction("myJob", "job", async () => {
	const jobProcessor = require("path/to/myJob")
	return await jobProcessor.process(job)
})

We eventually found out that the agent seems to keep every TraceSegment in memory during the execution of the job.
Removing startBackgroundTransaction resolved the issue for us.

Is it the expected behavior? It does not seem to fit with very long processes that calls other background processes
Is there another workaround to this? Right now we would only remove startBackgroundTransaction for our known long processes but obviously it is not a long term solution.

  • APM Agent Version: 8.6.0
  • Run on Heroku
  • Main frameworks used: Parse, BullQueue

Hey there @francois3 ,

Thanks for reaching out to the New Relic Community! I think I might be able to shed some light on your situation through this doc HERE which should go into much greater detail on your issue.

If you have any questions or extra details to add in the meantime, then please don’t hesitate to reach out.

Cheers

Hi @eschwall ,

I did went through the documentation and I found nothing to help me with. Those 2 questions still remain:

Is it the expected behavior? It does not seem to fit with very long processes that calls other background processes
Is there another workaround to this? Right now we would only remove startBackgroundTransaction for our known long processes but obviously it is not a long term solution.

@francois3 Hello there,

I am looking into those two questions you listed above. I’m curious what tier are you using on Heroku to host your application?

Could share a link to your application in New Relic One? Only those on your account and New Relic Admins will be able to view your application. To create a permalink within the New Relic, you can use the ‘Share’ button in the top right corner under your user profile or share the full URL from any page.

I also have this link here you could check out in the mean time: Troubleshooting large memory usage (Node.js)