I have a simple node application hosted on the free plan with 256 MB of RAM. However, about every 10 minutes, the application restarts due to running out of free memory. Is anyone else having this problem? When I run the application locally it never uses this much RAM, but, like clockwork, it’s exceeding memory usage on Fly.io.
I’m not sure a generic answer is possible without seeing your application, but perhaps adding a swapfile could help. You can do that by adding the following to your CMD/ENTRYPOINT.
An easy way to do that would be to add a small shell script that does the above commands and then whatever you currently have as your CMD, and then modify the CMD to run that script.
Feel free to modify the 256M and name of the swapfile as you see fit.
In my case, it was a different situation, my app almost instantly gets OOM killed and when casually looking at the memory stat via docker stats it seemed innocent that the memory consumption was less than 100mb. However I discovered the real issue was my ENTRYPOINT which was npm run start in turn, it was something like tsc && [actual running server via node command], taking the tsc step outside of ENTRYPOINT and put it into the building step fixed the issue.