Starting with flyctl v0.0.520 you’ll be given the option to have your db scale to zero if you are creating a shared-cpu-1x single node cluster. The idea behind this is that you can have hobby projects scale to zero when you aren’t using them to save you some so you can keep building neat stuff.
The way it works for now is after one hour, if there are no open connections, it shuts down and waits until something tries to connect again. If there are open connections it tries again in another hour.
Caveats
You’ll have to configure your app to scale to zero as well (e.g this article) otherwise your pg will never scale down
This is only offered for new shared-cpu-1x flex databases using flycast
The one hour timeout is not yet configurable
We’ll be writing more about how to use this for your hobby projects in the coming weeks but we wanted to get it into folks hands to play with. Go forth and build!
Am I right in thinking that when something attempts to connect when it is at 0 it’ll scale to 1 to accept the connection? Roughly what is the latency on this first connection?
I set this up for my Ruby on Rails project, and I’m not sure how to undo it. My app loads too quickly and thus the database doesn’t start fast enough, crashing the app How do we undo picking this option when starting a new app?
I noticed that my Postgres app failed to start even though the app was attempting to connect multiple times over a 24 hour period. I’ve had to remove the FLY_SCALE_TO_ZERO variable to get it working again.
I see that the fly.toml file for the Postgres app contains FLY_SCALE_TO_ZERO, but does not contain
I’m having trouble with this setting too. When I deployed my app using a Dockerfile about 3 weeks ago, it was set as the default and everything was running smoothly. However, since last week, the app no longer starts up on its own with the FLY_SCALE_TO_ZERO setting. I need to run the machine restart command, otherwise, it doesn’t work. I tried adding auto_start_machines = true , but it didn’t fix the problem. Any suggestions?