High Memory Usage

Hello, So I’m running a NodeJS app that doesn’t use much ram But in the dashboard the avg memory usage is always very high (~173 MB/232 MB). and I made sure it’s not from the app itself. I SSH into my app and installed htop and the memory usage is always around ~88mb with 13H uptime. And I do get OOM Issues otherwise I wouldn’t have cared. been using fly.io for more than 2 weeks now and I really like it. this is the only problem I have.

I took a look at your VM and it looks like node.js is consuming 170MB of RSS memory.

Node.js has various defaults for memory usage which assume it has plenty of available memory to work with.

A 256MB VM is rather small in this respect :slight_smile: This is fine though! We love apps running in 256MB VMs here.

Here are some ideas:

NODE_OPTIONS="--max-old-space-size=192"
2 Likes

I don’t know which one you looked at, But I meant the one with the name ‘Klein’,
also do you mind telling me how you got this RSS memory? shouldn’t the dashboard read the same as htop and ‘free’? that’s what confuses me.

I already had the idea of enabling swap, but I would have to implement it in my code since I don’t use docker. Thanks for the other Idea. I will set it up and see what happens.

I think the “mem used” metric in our dashboard includes RSS, caches and buffers. Because the query is just total - free:

 avg(fly_instance_memory_mem_total{app="flyio-web"}) - avg(fly_instance_memory_mem_free{app="flyio-web"})

You’re saying this klein app OOMed before? Without setting max-old-space-size to something lower, node.js will happily use way more than it should given the VM’s constraints.

Your node.js process should be able to use as much memory as is available. Looks like 124MB are available to be freed in that VM right now.

I wrote one up for our Node app on Fly, here: serverless-dns/swap.js at ecaafa2060472b6a34f34db5af5541bbcd4d62fa · serverless-dns/serverless-dns · GitHub

swap="auto" in [experimental] would be nice (: RAM limits for deploys - #3 by ignoramous

1 Like