Early look: PostgreSQL on Fly. We want your opinions.

It’s a little more complicated than that, but doable! You need to add replicas in the new region:

  1. Create two new volumes in the region you want to move to:
    1. flyctl volumes create pg_data --size <gb> --region <new_region>
    2. flyctl volumes create pg_data --size <gb> --region <new_region>
  2. Scale to 4 instances: flyctl scale count 4
  3. flyctl regions add <new_region>

If you run flyctl status now, you should see 4 instances running (or two new ones booting up).

The next step is to change the primary_region setting. For this, you’ll actually need to pull the configuration down and edit it.

  1. Create a new directly, cd into it
  2. Run flyctl config save -a <postgres-cluster-name>

This gives you a fly.toml, you will need to make a couple of edits:

  1. Edit fly.toml and change the PRIMARY_REGION environment variable
  2. Make sure the experimental block looks like this:
    [experimental]
    private_network = true
    enable_consul   = true
    auto_rollback   = false
    metrics_port    = 9187
    metrics_path    = "/metrics"```
    
    

That last step is a pain, sorry about that.

Once you have the fly.toml setup, run flyctl deploy -i flyio/postgres-ha.

This is something that we hope to make simpler!

2 Likes