How to “add” a postgres DB to an existing (python) fly app?
Or is this not how it works? Should a new postgres app be created and used with the existing (python) one?
I triewd to a simple flyctl postgres create which gets stuck on:
Provisioning 1 of 1 machines with image flyio/postgres...
Not sure what to do with this. Is this what it’s supposed to do? I thought I get some infos like username/password etc.
Once you get a PG provisioned, you can use the fly pg attach to connect it to an existing app.
Postgres cluster silent-cloud-3622 is now attached to myapp
Yay, thanks! Is this how you supposed to do this or can you “combine” the postgres app with the existing pyhton app somehow? Just asking to better understand the reason of seperating these.
Yeah, that’s how it’s supposed to work. If you launched a new app and attached a database during the setup process, it would do the exact same thing
As for why it works this way, it makes things a lot easier when your database (or other services) are kept separate. For example, if you needed to scale your database to have three nodes spread geographically, for latency reasons or redundancy, you could do that separate from you app.
Or, let’s say, an app suddenly gets a ton of traffic. You’d probably want to increase the number of hosts for that app, without necessarily scaling the database in the exact same way.
There are a couple of other reasons, like not needing to update the base app image with postgres updates for example, but overall it just tends to make things easier and more flexible.