Set default machine memory for apps during creation

I’m currently using the Fly GraphQL API to create apps for our pull request preview environments.
Unfortunately, our apps crash because the memory exceeds the default machine memory of 256 Mb. Is there a way to increase the default machine memory to 512 Mb during app creation or after? Or can it be done using the Fly Launch configuration file?
The equivalent of flyctl scale memory 512 -a xxx.

@marcus-sa have you got this working? We need something similar. Our script still uses the scale command but this does not work with machines, or so it seems.

Nope, unfortunately we still have to use the scale command every time an app is created/updated.

Ok thanks!

Then this question is more directly for the fly.io team I guess. We are a bit in a loop: the app cannot deploy because there is not enough memory, and I also fail to set the memory with the fly machine update command, which gives an error about the machine not having enough memory to update the memory…

This is how we start the app:

flyctl deploy \
    --access-token $ACCESS_TOKEN \
    --app $APP_NAME \
    --vm-memory $MEMORY \
    --image $IMAGE

Where the --vm-memory flag receives 2048 as input. Still, the deploy app runs on a machine with 256mb RAM, which is not enough.

Any tips?

hi @jeroen1

The --vm-memory option only works on new Machines created by the fly deploy command. So, if the app is scaled to zero Machines before deploy, then you should get the specified memory. You can also use fly scale memory 2048 after deploy to increase the memory.

Why not just add an option to set the default memory for all VMs during app creation…?
It’s obviously bothering a lot of people.

Well we tried scaling, but the app fails to deploy in the first place because it runs OOM… seems to be a chicken/egg problem here, no? I still can not get this working.

So that app has never deployed and you have no Machines to scale? You could try creating a new app fly launch --vm-memory 2048.

Once the Machines are created, then they should keep the same memory/size on subsequent deploys (unless you scale to zero).

Well, we use the deploy command in our CI/CD stack, with the --vm-memory param we found in the docs (see my post above) but it does not work…

Ok I double checked and in the Ci/CD pipeline we first call fly create and then fly deploy. Should we replace the create call with a launch call?

How do launch and deploy compare to each other? It’s not 100% clear from the docs…

Thanks!

fly launch creates and deploys a new app that you manage with our Fly Launch features (like a fly.toml file for config and deploying with fly deploy and scaling with fly scale).

Since you run fly create and then fly deploy I guess you have a fly.toml config file that you reuse for each new app?

Assuming you actually want to create a brand new app each time, instead of two commands, you could use fly launch to create and deploy in one step. You’ll have to tweak things and look up the options, but something like this would create and deploy a new app using an existing fly.toml file:

fly launch \
    --copy-config \
    --name $APP_NAME \
    --region $REGION \
    --org $ORG \
    --now \
    --image $IMAGE \
    --vm-memory $MEMORY

I’m not sure if right now you have different actions for create and deploy, but you can re-deploy the same app with fly deploy. As long as the app hasn’t been scaled down to zero, the memory settings are retained for the Machines.

Thank you for the insight. Reading the second part of your comment, I realized that the --vm-memory on the deploy action probably did not do much, since the machine was already created. I destroyed the app and started fresh, with a working app now. Thanks!

2 Likes