flyctl icon indicating copy to clipboard operation
flyctl copied to clipboard

Fix initial pg machine config for scaling to zero

Open jacobwegner opened this issue 11 months ago • 1 comments

Change Summary

What and Why:

I was kicking the tires on Fly Postgres and this caught my eye:

In the single-instance “Development” config, you’ll also be given the option to activate “automatic scale to zero”. It’s not magic: it’s just how our apps work. If you have an app that connects to your database, make sure that it also scales to zero (otherwise the connection remaining open will prevent it from “going to sleep”

But, it didn't look like my single-instance cluster was ever actually scaling down to zero.

I found this post on community.fly.io that recommended editing the fly.toml to set auto_stop_machines = true.

Making the change to fly.toml and re-deploying worked for me, so I headed to Github to make this PR.

How:

I looked at the changes in https://github.com/superfly/flyctl/pull/2282 and believe that setting Autostop along with Autostart should do the trick.

I tried to look at the GraphQL schema to see if Autostop was a valid input, but it looks like the config input is as far as the schema goes:

image

I did not yet attempt writing an integration / "preflight" test (my Go is a bit rusty), but would happy to do so if desired.

Related to:

  • https://community.fly.io/t/postgres-apps-not-scaling-to-zero/13311
  • https://github.com/superfly/flyctl/pull/2282
  • https://community.fly.io/t/scale-to-zero-postgres-for-hobby-projects/12212

jacobwegner avatar Mar 09 '24 01:03 jacobwegner

@DAlperin: Pinging you as I saw you had commented on a related discussion thread:

https://community.fly.io/t/scale-to-zero-postgres-for-hobby-projects/12212/13

Is there anything else I could do to help get this reviewed / merged?

jacobwegner avatar May 15 '24 14:05 jacobwegner