My project runs locally on less than 2 GBs of RAM. Less than 1GB even. However, it doesn’t even boot up in fly unless I assign it extra resources. My team assigned extra resources to the app so it would boot up correctly, but once it does it doesn’t use that extra ram at all.
We are getting billed for this extra machine power that our program does not need. Can someone from fly support help us migrate the app to a less powerful machine while still being able to run it?
Additionally, we are having frequent fly outtages in our region. Thanks in advance.
You are using the hardware though, it’s just that your app isn’t making use of all the resources.
I’m curious what your app is that requires all the extra RAM on bootup.
Have you tried swap_size_mb in your fly.toml?
The thing is, my app doesn’t even seem to require all that extra ram on bootup. If I assign it 2GB, the deploy stops saying it has “excess capacity”. The ram usage graph is as follows:
The only way my app boots is to increase its machine resources, which of course results in extra billing, but my app could run without them.
excess capacity isn’t an error, it’s Fly auto-shutting down your app when it doesn’t have any traffic. This is expected behavior. If you want your app to not auto shutdown, you need to configure your fly.toml
If your app’s ram usage is different locally vs on Fly, you’ll need to investigate why. Does your app really need to consume 1.5GB of RAM that early?
You’ll have to monitor your memory usage more than a 5-min window. Looks like it’s loading all that data in memory… so it’ll only go uphill from here and you may need 4GB of RAM in the long run.
@khuezy first of all, thanks for your patience and guidance. Me and my team have more thoroughly tracked the ram usage locally, and it was indeed spiking in the 4GB numbers. Once this index building process ends, the app continues to run on less than 500mb of ram.
Would adding a big swap partition with swap_size_mb = 4096 and having just one gig of ram for the machine be a viable option? Is such a swap size even allowed by fly? We have already tried using swap_size_mb = 1024 but the line seems to get deleted during fly launch, I’m not sure what’s wrong.
Thank you in advance!
That should work. I’m not sure what the max swap size is though. I think 512MB as your base RAM would be ideal, then you’ll just pay for any additional RAM your machine swaps. If that causes latency, then stick with 1024MB. You need 4GB of swap size since your system is consuming that when it indexes or w/e.
Are you doing fly launch each time? You should be doing fly deploy.
Yeah we were using fly launch every time since we were messing around with the ram settings, but the swap_size_mb line gets apparently deleted in the process and the machine ends up without that setting… maybe with fly deploy it will be different? I will get back to you later
@guillermo-st can you build your index on another machine? You could have one with 4 gb of ram just for index building, keep it down (you are not charged for suspended machines), launch it only when you need, and then use that index on smaller machines with 512 mb of ram.
Think about it like an on demand background worker
That’s a great idea, but I have no idea how to do it. Do you think it’s better than the swap approach?
swap_size_mb = 4096 is not being respected by fly anyways… I add that line, save the file, run fly deploy aaaaaannd… nothing happens. The machine fails and the settings don’t show any added swap memory. Does anybody know what could be the problem? Maybe I should create a separate thread for this issue