Mattermost, Inc.

Mattermost Recipe: Hot Standby with Database Replication

Hi all,

A customer had an interesting architecture design challenge: They wanted two Mattermost servers, each with their own PostgreSQL database in a hot-standby configuration. Because they needed to make changes on their standby server while the main server was down, traditional streaming replication with read-only replicas wouldn’t work.

After some research I found Bucardo, which keeps two or more PostgreSQL databases in sync. To handle the automatic fail over I use HAProxy to route traffic to the standby server in case the main server is down.

You can find more detailed setup instructions and a Vagrant machine in my Github repo.