Big memory usage
I have a nodejs app running some tasks and it seems like the ram is increadibly high in the railway charts. I tested it locally and I did not get this behaviour. I also added logs about heap usage every 2 seconds (using
process.heapUsed
) and they stayed constantly between 0.7 and 1.1 GB, while railway charts rapidly growed up to 4GB of usage (reaching also 22GB in another deployment) before I stopped it.16 Replies
Project ID:
4900bb8f-ad4a-4e22-bbe9-115063046480
4900bb8f-ad4a-4e22-bbe9-115063046480
I'm not part of the railway team but I had a similar issue on a Python app that the railway team helped diagnose. Do you happen to be reading the max about of CPUs anywhere in your code to spawn workers? In my case that was happening and even on the hobby plan it made an app that normally takes 300mb take up 3gb of ram. Realized I needed to be explicit for the workers spawning. The deploy logs could possibly help to narrow down what could be causing it.
ok thanks, how do I do that
who from the railway team helped you diagnose that because neither me or coffee work for railway lol
fedev, with the wonderful information faolain has provided please try to do research around the topic yourself too
I assumed you worked at railway?
nope
You can tap the deploy logs tab on the UI when you click into the service that's using all the memory
So same thing hehe, maybe it would be good @Brody if this was on the Railway documentation somewhere? since it seems like a lot of people come across
yes it would be good, where would it go though
maybe under Troubleshoot in a new section or under Fixing Common Errors
https://docs.railway.app/troubleshoot/fixing-common-errors maybe a section of big memory usage, showing the steps from above to triage what could be causing it (checking deploy logs, if your code reads the max default workers)
well ideally, it just wouldnt be a problem lol
agreed I think you mentioned you escalated to the railway dev team right?
yep they know
it looks like this can be solved with passing
--cpuset-cpus="0-7"
to the docker run command, of course this isnt something a user can do