RAM limits for deploys

Hey folks!

Was wondering if you had any suggestions for this issue I’m having…

I’m trying to deploy a clojure app (java jar) on a free tier instance (256mb). The deploy seems to crash all the time due an an out of memory error:

2022-09-13T17:50:27.199 app[88320b3f] ord [info] Starting init (commit: 249766e)...

2022-09-13T17:50:27.243 app[88320b3f] ord [info] Preparing to run: `java -Dclojure.main.report=stderr -cp target/uberjar/basha.jar clojure.main -m basha.core` as root

2022-09-13T17:50:27.273 app[88320b3f] ord [info] 2022/09/13 17:50:27 listening on [fdaa:0:926e:a7b:9ad9:8832:b3f:2]:22 (DNS: [fdaa::3]:53)

2022-09-13T17:50:38.528 app[88320b3f] ord [info] [ 11.399610] Out of memory: Killed process 515 (java) total-vm:2045912kB, anon-rss:202220kB, file-rss:0kB, shmem-rss:0kB, UID:0 pgtables:604kB oom_score_adj:0 

This makes sense, since when I run the jar locally (in docker) the container uses up to 430mb of memory.

The strange thing is though, is that if I restrict the allowed container memory using docker, I can get the app running fine down to 200mb of memory and 0mb of swap.

I’ve tried tuning the JVM opts to restrict memory during the deploy using the -Xmx flag, but I can’t seem to get it to the point where I can both: stop the out of memory error - and - get the app spun up successfully.

I was curious if there was a setting or deploy config to restrict the memory usage on the deployed VM, instead of shutting it down if it goes over. I’d prefer to try to fit my app on the 256mb instance than scale up to 512.

Thanks!

It’s worth trying with 512MB of memory to see if the problem goes away.

Most of the time when it works in Docker, but not on Fly, it’s because memory spikes once and goes into swap before it settles back down. Fly VMs don’t have swap AND don’t share memory with other system components, so it’s a more constrained environment than Docker.

1 Like

Calling for an experimental swap=auto fly.toml entry: .net 5/6 app killed because of memory usage; no cgroup limit being the reason? - #18 by ignoramous