Live data from Hacker News

We migrated our PostgreSQL database with 11 seconds downtime

gds.blog.gov.uk

71–80 of 210 posts

Re: We migrated our PostgreSQL database with 11 seconds downtime

#71

Minor detail but did anyone else notice they are using eu-west-1? Kind of weird for the UK to be hosting there sites in another country (Ireland). I'm sure this isn't super sensitive data but still.

They've been on AWS since before eu-west-2 was added, it's still not at the scale of eu-west-1. Capacity issues are still a thing (but getting much better), and only recently have they become pretty much feature parallel.

Re: We migrated our PostgreSQL database with 11 seconds downtime

#72
post #52
post #45

Earlier quoted context omitted.

I don't think you have any idea just how much it costs to run infrastructure at the reliability levels provided by AWS, and just how much investment it would require to get the ball rolling on this. A lot of people have a very unrealistic picture of what government budgets are like.

> I don't think you have any idea just how much it costs to run infrastructure at the reliability levels provided by AWS my $12/year VPS does better than us-east-1

Where do you get a 12 dollar a year vps. Hetzner charges me 4 bucks a month and it feels like a steal

Re: We migrated our PostgreSQL database with 11 seconds downtime

#73

Note that the enemy of low/zero downtime migrations like this is long running queries. Ie. a single update query which takes 30 mins. You either have to kill and roll back that query, or suffer 30 mins of unavailability. As far as I know, there is no way to migrate a currently in progress query.

It's hard for me personally to imagine a 30-minute update query that is not written extremely inefficiently, or else a one-time huge data migration.

There are a lot of the former in the wild to be sure. I've had a lot of run turning minutes-hours into milliseconds. :)

Re: We migrated our PostgreSQL database with 11 seconds downtime

#74
post #15

Earlier quoted context omitted.

How would you feel if the US government ran on servers from a European company, which also works very hard to avoid paying taxes in US soil? All those reasons to go AWS hold for a private company, not for a government service of a first world country and G7 member. AWS has a lot of compliant services, but it's not like they're doing rocket science one of the top 5 richest countries in the world cannot afford to devel…

I would be surprised if they aren't deploying to the London data center, so I would think it is within the UK

eu-west-2 is a bit misleading, most of its nowhere near London, they've got DC's right up into the midlands. One of their newer ones for example is out in Didcot Oxfordshire, they've also got a few up towards Peterborough. All classed as 'London' despite being a fair distance away from it.

Re: We migrated our PostgreSQL database with 11 seconds downtime

#75
Lovely! We just migrated from postgres 14 to 16 for 3 postgres clusters (servers) on RDS containing about 2TB of data across 8 databases. We were down from 00:00 to 04:00. Steps we took:

  * enabled our fallback "maintenance mode" site. It's a super lightweight version of our site running on CF workers.
  * scaled down all apps using the db to 0 in terraform
  * hit the upgrade button in the aws web ui, which runs pg_upgrade. 14->15
  * waited for it to finish
  * hit the upgrade button again. 15->16
  * waited for the dbs to start accepting connections (they do before they're marked as ready, I think aws does more stuff than pg_upgrade)
  * Started `VACUUM ANALYZE; REINDEX DATABASE CONCURRENTLY`. The idea is to avoid performance issues between versions and make use of performance improvements from new versions.
  * Started spinning up the apps again
  * Waited until all apps had a handful of containers running
  * Started accepting traffic (disabled maintenance site)
  * Went to bed
The REINDEX CONCURRENTLY happily chugged along for the biggest db for another 18 hours without blocking anything. Next time we're doing aws blue/green deploys to avoid downtime. We didn't this time since we weren't on 14.9 yet (the minimum minor version of 14 supported by blue green).

If I was doing this myself I wouldn't pay the AWS tax, instead do blue/green myself with logical replication and a load balancer.

Re: We migrated our PostgreSQL database with 11 seconds downtime

#76

We did a similar migration (somewhat larger database) with ~20 seconds of downtime and much less work... using the magic of AWS RDS Blue-Green Deployments [1]. Surprised they aren't mentioned in the thread yet. Basically, you spin up a new Blue Green deployment with any desired changes (in our case, we were upgrading Postgres major from 13 to 15). While your blue configuration continues to serve traffic, AWS uses log…

+1 for B/G. That said, I imagine they couldn’t use it due to the cross-account shift. I’ve used it for both MySQL (with much higher QPS than TFA, by two orders of magnitude) and Postgres, and they both went flawlessly. Read the docs, especially the limitations. Re-read them. Do a test run in the dev environment, under load. Do it again in staging. Or just YOLO into prod ‘cause it’ll probably be fine, I guess.

We definitely did a dry run with a parity configuration a couple nights before. It gave us a lot more confidence.

Re: We migrated our PostgreSQL database with 11 seconds downtime

#77

We tried to work with DMS to migrate mysql to postgres, and it was a nightmare. Support was useless, and would often just not get back to us without prodding. Then them giving us canned responses unrelated to our queries. The whole thing is nigh on un-debuggable. Stay away.

We also tried to use DMS for a few things (Rackspace to AWS migration, replication out to data lakes, etc) and it has been consistently undersupported, buggy and ate months of time before we went to other solutions. While a lot of AWS support has been good; not for DMS. It feels entirely half baked .

Re: We migrated our PostgreSQL database with 11 seconds downtime

#78

We tried to work with DMS to migrate mysql to postgres, and it was a nightmare. Support was useless, and would often just not get back to us without prodding. Then them giving us canned responses unrelated to our queries. The whole thing is nigh on un-debuggable. Stay away.

Surprised by that. I've used AWS DMS quite a lot to do both on-prem to AWS and AWS (MySQL) to AWS Postgres migrations and long term ongoing replication. Whilst there is some complexity/gotchas there it's always been more than up to the task. Takes a little bit of validation/testing to understand but it's very well documented too. What sort of issues did you hit? In all honesty I'm not sure I've been more impressed by…

One issue we hit were any schema changes totally messed it up. I don't have my notes in front of me, but we were constantly hitting data that wouldn't migrate, or that things suddenly broke whenever things changed.

Re: We migrated our PostgreSQL database with 11 seconds downtime

#79
post #68

Earlier quoted context omitted.

The risk is hiring a team of ineffective sysadmins, especially if your organization can’t assess sysadmin competence.

That would indeed be a risk, but the circular logic of this means no new company could ever have any competence outside of its founders. Which feels shortsighted. Anyway, I am a former sysadmin. I am confident that I can identify competence in the requisite areas.

Governments tend to be far less competent at determining technical competence. Due to a wide variety of factors, governments tend to be completely uncompetitive in salary for technical positions meaning they're already hiring from the lower end of the pool (not including a few altruistic folks willing to forgo their market value).

At a company if a department isn't working out you just restructure and move on, but in the government, that team is going to retire in your org and collect pension from you, and there's very little you can do about that.

Re: We migrated our PostgreSQL database with 11 seconds downtime

#80
post #50

We tried to work with DMS to migrate mysql to postgres, and it was a nightmare. Support was useless, and would often just not get back to us without prodding. Then them giving us canned responses unrelated to our queries. The whole thing is nigh on un-debuggable. Stay away.

I worked on migrating our MySQL system to PostgreSQL using pgloader ( https://pgloader.io/ ). There were some hiccups, things that needed clarification in documentation, and some additional processes that needed to be done outside of the system to get everything we need in place, it was a amazing help. Not sure the project would've been possible without it. Data mapping from PostgreSQL to PostgreSQL as in the article…

We also ended up using pgloader. Its not without its friction either. For example the concurrency/number of rows setting seems broken out the gate, and its like playing darts with a blindfold on to get it to run without running out of memory. But being able to read the source, github actions, and overall at least I could debug my problems, or find others who had the same issue.

Would recommend pgloader.

Post reply on HN