Matrix high availability

A practical guide to making a self-hosted Synapse deployment survive component failures, covering workers, Redis, PostgreSQL, media storage, load balancing, verification and handover.

On this page

Matrix high availability starts with knowing which component can fail

High availability in Synapse is a set of separate decisions, not one switch. Teams need it when a single node or database outage would stop messaging for people who depend on the server for daily work, incident response or regulated communication. A default Synapse install runs as one homeserver process that handles client sync, federation, event persistence and background tasks. That single process is the constraint: running more copies of a plain server does not spread the load or the failure risk, because the copies must share one consistent event stream, one database and one view of room state. Synapse solves this with worker processes, but each worker added makes the topology more complicated to run.

The components fail in different ways. The main process holds responsibilities that cannot be duplicated freely, so losing it affects writes and coordination. Redis relays replication between processes, so its outage can stall workers even when every worker is healthy. PostgreSQL holds all durable state, and its failover depends on your replication and backup design, not on Synapse. Media storage is a separate path with its own durability and access model. The load balancer sits in front of everything and can route client and federation requests to the wrong place if it is misconfigured. Client traffic and federation traffic also arrive on different listeners and ports, so a design that protects one path can leave the other exposed. Before choosing a design, list each component, its failure mode and the users who would notice, then confirm the exact main process and worker responsibilities for your Synapse version in the Synapse workers documentation.

Which Synapse components carry availability

A Synapse deployment that serves users is a chain of processes, databases and network paths, and one weak link can stop messaging even when the rest is healthy. The cards below cover each component that carries availability, what it does, and what users see when it fails. Confirm the worker types supported by your exact Synapse version before you map roles to processes.

Main process and its role

The main process handles writes to the event stream and coordinates the workers that run alongside it. Every worker connects to it, so its health sets the ceiling for the whole deployment. If it stops, new messages and room state changes can stall even while read traffic continues on other processes. Check how your version assigns main process duties and whether a restart path is documented for your layout.

Synapse workers docs

Generic workers for client traffic

Generic workers handle client, federation and event traffic, so adding them spreads load across processes. Losing one reduces capacity and can drop in-flight requests, which clients retry. Plan at least two instances of each worker type that matters to your users, and confirm which worker types your Synapse version supports before splitting roles.

Redis as the replication relay

The main process and all workers connect to Redis, which relays replication between them. A Redis outage interrupts replication, so processes lose the events they depend on to stay in sync. Treat Redis as a tier with its own monitoring, restart behavior and failover plan, not as a cache that can be ignored.

PostgreSQL as the shared store

Synapse recommends PostgreSQL for production, and every process reads and writes the same database. A database failure stops nearly all messaging, so replication, backups and failover belong in the availability design from the start. Ask whether your team can restore to a point in time and rehearse that restore.

Synapse upgrade notes

Media repository storage

The media repository stores uploaded files and images. If it is unavailable, text messages still flow, but users cannot send or open attachments and avatars may fail to load. Decide whether media sits on shared storage that every media-serving process can reach, and test what a storage outage does to uploads already in progress.

Reverse proxy in front

The reverse proxy terminates client connections and routes requests to the right worker. A single proxy is a single point of failure for every user, even when the backend is fully redundant. Confirm how your proxy health checks workers, how it routes federation and client paths, and how a proxy failover would change the address clients and remote servers use.

Decisions that shape a highly available Synapse

This table compares the main topology and storage choices for a Synapse deployment that must keep messaging running through component failures. Read each row as a decision: when the option fits, what it asks your team to operate, and which failover and upgrade steps you must rehearse before going live.

OptionWhen it fitsOperational costFailover and upgrade needs
Single node with managed backupsSmall user base with tolerance for downtime while a host is restored from backupLow moving parts: one Synapse process, one PostgreSQL instance, scheduled backups and restore testingRehearse a full restore onto a fresh host; confirm the restore time you can accept with stakeholders
Single main process with workersGrowing load where one process is the bottleneck but a single site is acceptableRedis and replication settings to operate; worker configuration files to keep in step with the main processUpgrade main process and workers together; check that every worker runs the same Synapse release
Worker layout separating client and federation trafficFederated deployments where federation spikes should not degrade client syncSeveral worker roles to define, route and monitor at the load balancer; more Redis and replication dependenciesTest routing rules after each upgrade; confirm which endpoints reach which worker type
Self-managed PostgreSQL primary with a standbyTeams with database administration skills who want control over replication and failoverReplication monitoring, failover tooling, fencing and regular restore tests owned internallyRehearse promotion of the standby and reconnection of Synapse; check schema changes before any failover drill
Managed PostgreSQL serviceTeams that prefer the provider to run replicas, patching and backupsRecurring service fees; confirm the supported PostgreSQL versions, backup retention and failover behavior in writingCheck that the provider version meets the minimum Synapse requires; plan maintenance windows around Synapse upgrades
Shared media storageSeveral Synapse nodes or workers must serve the same uploaded filesObject or network storage to size, secure and back up; access latency to monitorConfirm all nodes read the same store before failover; restore media and database backups to matching points in time
Per-node media storageSingle node deployments or setups where media loss on one host is acceptableSimpler setup, but each node holds its own files and needs its own backupsMedia on a failed node may be unavailable until restored; document this trade-off for users and auditors

How to build the cluster in sequence

This sequence moves a single Synapse homeserver into a worker-based layout where the main process, workers, Redis, PostgreSQL, media storage and the load balancer each have a defined role and a verified check before the next step begins. Each step builds on the one before it, so a failure can be isolated to the component just changed.

  1. Confirm the server name and delegation plan

    Before any component changes, fix the server_name, because it determines how user IDs such as @user:example.com and room identifiers are formed and cannot be changed later without rebuilding identity. Decide how federation will reach the server: port 8448 directly, or delegation so that the domain serves on port 443 while the federation host sits elsewhere. Your network team confirms DNS records, certificates and the public endpoints the load balancer will expose. Close this step by resolving the well-known delegation and federation endpoints from outside your network and confirming they return the expected server name. Record the plan in your runbook so every later change references the same names.

  2. Move Synapse from SQLite to PostgreSQL

    The Synapse documentation recommends PostgreSQL for production, while SQLite is supported but is not the platform for a multi-process layout. Provision a PostgreSQL instance on a supported major version (Synapse 1.143.0 and later require PostgreSQL 14 or newer, so confirm the version against the release you plan to run), then follow the upgrade and database migration notes for your target release. Run the migration in a maintenance window with a full backup of the SQLite files taken first, since rollback after schema changes can be difficult. Close this step when the single-process Synapse starts against PostgreSQL, serves a login, and a test room message is stored and delivered to a second client.

  3. Enable Redis for worker replication

    Synapse workers coordinate through Redis, which relays replication traffic between the main process and every worker. Deploy Redis on a private network segment reachable only by Synapse hosts, enable authentication and restrict the port with host firewall rules. In the homeserver configuration, enable the Redis replication settings and restart the main process so it connects. Close this step when Synapse logs show a successful Redis connection and a test from the Redis side confirms the expected client connection count. Confirm your Redis sizing and persistence choices with the vendor documentation for the version you deploy, since this document does not set figures for them.

  4. Split the main process and add a generic worker

    Move background and singleton tasks to the main process and start a generic worker that handles client sync, federation and event traffic. Each worker gets its own configuration file, its own replication listener name and its own worker type declaration, which the workers documentation describes in detail. Keep the main process reachable only on the internal network. Start with one generic worker to validate the split before adding more. Close this step when both the main process and the generic worker report as connected in the logs, and a client sending a message through the worker produces an event visible to a client connected to the main process.

  5. Route client and federation paths at the load balancer

    Configure the reverse proxy or load balancer so client API paths, federation paths and media paths go to the correct process or worker, following the endpoint routing in the workers documentation. Sync and event endpoints must reach a worker that is designed for them, and paths that write to singleton streams must stay on the main process. Set up health checks per backend so a failed worker is removed from rotation. Close this step by running a client login, a sync request and a federation version request through the load balancer and confirming each one lands on the expected backend in the access logs.

  6. Add a second worker and test failover

    Scale out by starting a second generic worker with the same type and a distinct name, then add it to the load balancer pool. Stop one worker deliberately during a test window and confirm that client sessions reconnect through the remaining worker without losing messages. Repeat the test for the main process only in a non-production environment, because main process loss stops singleton tasks until it returns. Close this step when a test message sent during the stop reaches a client that was connected to the stopped worker after reconnection.

  7. Configure PostgreSQL replication and tested backups

    Set up streaming replication from the primary PostgreSQL instance to at least one standby, and configure continuous backups with point-in-time recovery according to your PostgreSQL platform's guidance. Decide with your team whether failover is automatic or manual, because Synapse connects to one database endpoint and promotion must be reflected in its configuration or in a virtual address that points to the new primary. Verify that the standby is streaming with replication lag visible to monitoring, then perform a restore of a recent backup into a separate environment and start Synapse against it. Close this step only when the restored copy serves a login and reads the test room history.

  8. Place media on shared or replicated storage

    Synapse stores uploaded media on local disk by default, which breaks when more than one host serves media requests. Move the media store to shared or replicated storage that every media-capable worker can read and write, and confirm the storage platform's consistency and failover behavior with its vendor. Add media backup to the same schedule as the database backups, because a database restore without its matching media files leaves broken references. Close this step by uploading a file through one worker, downloading it through another, and confirming the file hash matches and the restore test includes the media files.

How client, federation and media requests reach the right process

The diagram starts with clients and remote servers reaching the load balancer, which separates traffic by listener. Client requests and federation traffic go to generic workers, while media requests go to a dedicated media worker. The main process and workers exchange replication events through Redis, and all of them write to the PostgreSQL primary, which streams changes to its standby. Check that the federation listener and client listener are firewalled separately and that the trust boundary sits in front of every internal component.

Listener routing, replication and database flow across the public and internal boundary.

What drives the effort and cost of Matrix high availability

This table lists the factors that raise or lower the work of making Synapse highly available, with the reason each one matters and how to keep it contained. Read it before scoping a partner engagement or estimating internal time, since the same driver can add modest or large effort depending on your environment. Most of the effort comes from the number of components you must run, replicate and test, not from any single setting.

DriverWhy it raises effortHow to keep it down
User count and room activityMore concurrent clients and busy rooms push more events through the main process and workers, which increases worker count, Redis load and database work.Size from measured peak activity, add workers only where monitoring shows a bottleneck, and confirm capacity with a load test before go-live.
Number of federated domainsEach federated server adds inbound and outbound traffic, key checks and delegation to maintain, and more failure modes when a remote server misbehaves.Restrict federation to a short partner list where your policy allows, and document each delegation and listener change.
Number of environmentsStaging, production and disaster recovery each need matching worker layouts, database replicas, media storage and configuration, so changes must be applied and tested in every copy.Keep one configuration source, template environments from the same code, and limit disaster recovery to what your recovery objectives require.
Media volume and retentionUploaded files grow storage, backup size and restore time, and media served through workers adds I/O and bandwidth work.Set retention rules early, move media to shared object storage where supported, and confirm backup and restore times with your own data volumes.
Identity integrationSingle sign-on through OIDC, SAML or CAS, or through Matrix Authentication Service, adds an external dependency that must also be highly available for logins to survive a component failure.Use one identity provider with its own redundancy, confirm login behavior when it is down, and test failover of the login path separately.
Bridges that add loadBridges to Slack, IRC or other platforms create bridge users and high event volumes, and they run as separate services that also need restarts, monitoring and failover.Limit bridged rooms to those needed during a migration or coexistence period, and add bridge services to the same monitoring and recovery plan.
Compliance evidence requiredAssessors expect documented architecture, tested backup and restore records, failover test results and access logs, which takes time to produce and keep current.Agree the evidence list before build, automate configuration and backup reporting, and schedule recurring failover tests so records accumulate.
Team skills in PostgreSQL and RedisReplication, failover, backup verification and Redis tuning are specialist tasks, so a team new to them needs more training, review time or outside help.Assess existing database and cache experience first, assign named owners for each component, and ask any partner to document runbooks the team can follow.

How the HA design differs by deployment model

A single node runs Synapse, PostgreSQL, Redis if workers are used, and media storage on one host. There is no automatic failover. Recovery means restoring the database, the media store, and the configuration onto a replacement host and starting the services again, so messaging is down for the length of that restore. The value of this model lies in simplicity and in the quality of the backups.

  • Failover path: none automatic. A failed host is replaced and restored from the latest backup.
  • Replicated or shared: nothing is replicated. Backups of PostgreSQL, the media directory, and the signing keys and configuration files are the recovery material.
  • Manual work: restore tests, backup retention decisions, and host rebuilds, all performed by the operator.
  • Data gap risk: anything written after the last backup is lost unless the operator accepts that gap.
  • Upgrade risk: the upstream upgrade notes warn that rollback can be difficult because of schema changes, so a pre-upgrade snapshot is part of the plan.

Confirm with your own recovery test how long a full restore takes in your environment before accepting this model for a business-critical channel.

Protecting the HA layers without weakening availability

A highly available Matrix deployment has more listeners, data stores and secrets than a single homeserver, and each one is a potential exposure. The cards below cover the controls that keep federation, replication, Redis, PostgreSQL, backups and media locked down while the failover paths still work. Check each control against your failover tests so that hardening does not block the components that need to take over.

Firewall the federation listener

Synapse federates on port 8448 by default, and the configuration docs recommend firewalling the federation listener in addition to any application-level restriction. Decide which addresses must reach it, including every load balancer or worker that terminates federation traffic, and block the rest. Confirm that delegation to port 443 still resolves for your server_name after the rules are in place.

Synapse federation docs

Keep replication and metrics internal

Worker replication listeners and metrics endpoints expose internal state and should never be reachable from outside the cluster network. Bind them to internal interfaces, then restrict access to the specific hosts that run the main process and workers. Verify with a scan from an external network that these ports do not answer, and check that your monitoring system can still scrape them.

Keep Redis and PostgreSQL private

Redis relays replication between the main process and all workers, and PostgreSQL holds the full homeserver state, so neither should have a public interface. Bind both to private addresses, require authentication, and allow connections only from the Synapse hosts and the database replica or backup hosts. Review these rules after every topology change, because a new worker pool can quietly need a new allow entry.

Manage database and Redis credentials as secrets

Database passwords and the Redis password belong in a secrets store, not in plain configuration files copied to every worker. Rotate them on a schedule that your change process can execute without a homeserver outage, and confirm that each worker picks up the new value on restart. Limit each service account to the rights Synapse needs, and record who can read the secret store.

Control access to backups

Backups of PostgreSQL and media storage contain the same message history and attachments as the live system, so they need the same access rules. Restrict who can list, restore or delete backup sets, and keep restore credentials separate from day-to-day administration. Test a restore into an isolated environment so that the people who need access in an incident are known in advance.

Protect media storage

Uploaded files are stored outside the database and are often the largest and most sensitive data set on the homeserver. Apply access controls to the storage bucket or volume, enable encryption at rest where your platform supports it, and confirm that media served through the load balancer does not expose internal storage paths. Check that media replicas and backups follow the same permission model as the primary store.

How to test that failover works and fails safely

The point of this section is that a Matrix high availability design is only proven when you have broken its components on purpose and watched what users experience. Run each test in a staging environment that mirrors production topology (the same number of workers, the same Redis arrangement, the same PostgreSQL standby pattern and the same load balancer rules) before any production upgrade or topology change. Record the baseline first: send test messages between two accounts on different workers, sync a client, and upload and download a media file, so that every later test has a clear before and after.

Start with the stateless tier. Stop one generic worker or one synchrotron or federation sender worker, then confirm through the load balancer health checks that new client requests move to the surviving processes and that the test messages still send and arrive. Next, interrupt the Redis connection for a short, defined window. Redis relays replication between the main process and workers, so expect delayed or stalled events rather than lost ones. Your acceptance criteria should state what a user sees during the window (a pending send, a reconnect, or an error), how long recovery takes, and whether any message is missing once Redis returns. Confirm the exact replication and Redis settings with the Synapse workers documentation before you write those criteria.

Database and media tests need the most care. In a rehearsal, promote the PostgreSQL standby and compare row counts and recent event IDs on both sides, then send a message and confirm Synapse reconnects to the new primary. Check that the restored backup can start a homeserver on its own. Finally, take one media node or storage path out of service and confirm that existing media remains downloadable and that new uploads either succeed or fail with a clear error. The failure mode you are testing for is a failed failover that leaves users with explicit errors, such as send failures, sign-in prompts or unavailable media, rather than silent data loss or messages that appear sent but never reach the room. Document every such case and the operator action that resolves it.

What to monitor, back up, upgrade and document after go-live

A highly available Matrix deployment only stays available if someone watches it, restores it and changes it safely. The four areas below connect because a failure in one, such as a lagging replica or an untested backup, often shows up later as a messaging outage during an upgrade or failover.

Monitor replication, workers and PostgreSQL

Track replication lag between the main process and workers, the health of each worker process, and the state of the PostgreSQL primary and its replicas. Redis is the relay for replication traffic, so watch its availability as well. Set alerts on lag that keeps growing, since a worker that falls behind can delay message delivery for users on its traffic. Confirm which metrics your Synapse version exposes and how your monitoring stack scrapes them.

Synapse workers docs

Back up PostgreSQL and media

The message store lives in PostgreSQL, while uploaded files live in the media store, so both need backups taken on a schedule that keeps them consistent with each other. A backup you have not restored is an assumption, not a recovery plan. Run restore tests into a separate environment on a regular cadence, time how long the restore takes, and confirm that a restored server starts and serves existing rooms and media.

Upgrade within the minimum versions

Before each upgrade, check the Python and PostgreSQL minimums in the latest Synapse upgrade notes, because Synapse drops support for versions that reach upstream end of life. Plan on a staging copy of production data and test workers and clients against the new release. Treat rollback as difficult: the upgrade notes warn that database schema changes between releases can make it hard to return to an earlier version, so take a verified backup immediately before each change.

Synapse upgrade notes

Document topology, runbooks and owners

Record the current topology: which hosts run the main process, each worker type, Redis, the PostgreSQL primary and replicas, the load balancer and the media store. Write runbooks for failover, restore and worker replacement, and name a failover owner and a backup owner for each, with an on-call path. Keep the federation and server_name settings in the same record, since changing them later is disruptive. Review the document after every upgrade and every topology change.

Questions teams ask before running Matrix high availability

How much effort does Matrix high availability take, and what drives it?

Effort depends mostly on how many components you split out and how many of them you must run redundantly. A single Synapse process with one PostgreSQL server is simple to operate. Adding workers, a Redis instance that relays replication between the main process and workers, a load balancer, replicated PostgreSQL and shared media storage multiplies the parts that need monitoring, patching and failover testing. The main drivers are the number of user sessions and rooms, the number of worker types you run, how often you upgrade, and how strict your recovery time targets are. Ask any partner to break the effort into design, build, failover testing and ongoing operations, and to state which of those are one-time and which recur.

Can our own team build Matrix high availability without a partner?

Yes, if your engineers already run PostgreSQL replication, Redis, reverse proxies and Linux services in production. The Synapse workers documentation describes how the main process, workers and Redis fit together, so the design is documented. The harder parts are operational: knowing which worker handles which endpoint, testing failover without losing messages, and keeping configuration consistent across processes during upgrades. Check whether your team has someone who can own Synapse upgrades, since the upgrade notes warn that rolling back can be difficult because of database schema changes. A partner can be useful for the design review, the failover tests and the runbooks, while your team keeps day-to-day ownership.

What does the work need from our staff and infrastructure?

You need named owners and infrastructure that can host each component on separate hosts or failure domains. On the staff side, plan for someone who manages PostgreSQL backups and replication, someone who owns the reverse proxy and DNS, and someone who can watch Synapse logs and metrics. On the infrastructure side, confirm that you have enough machines or nodes for redundant workers, a Redis deployment you can monitor, shared or replicated media storage, and network paths that let federation traffic reach the federation listener if you federate. Confirm supported versions first: the upgrade notes say Synapse 1.143.0 and later require PostgreSQL 14 or newer, and 1.142.0 and later require Python 3.10 or newer, so older database or Python hosts may need work before you start.

How long does Matrix high availability take, and why does it depend on scope?

Duration depends on how many components are in scope and how much of the environment already exists. A deployment that needs only worker separation on an existing Synapse server takes less time than a full build that adds replicated PostgreSQL, Redis, load balancing, shared media storage and tested failover. Other factors include how many environments you need (test, staging, production), whether you must integrate identity through SSO, whether federation is open or limited to partner domains, and how many failover scenarios you want to prove. No timeline is given here because none is supplied for this topic. Ask any partner for a written schedule tied to a defined scope, and ask which dependencies, such as access approvals or hardware lead times, sit outside their control.

Does high availability remove the need for backups?

No. Replication and redundant workers keep messaging running when one component fails, but they do not protect you from a bad schema change, accidental deletion, corruption that replicates to standby servers, or a ransomware event that encrypts the primary database. Replicas copy mistakes as quickly as they copy good data. You still need point-in-time PostgreSQL backups stored separately from the running cluster, a tested restore procedure, and a plan for media storage, since uploaded files live outside the database. Define recovery objectives for each data type and test restores on a schedule. Treat backups as a separate control from availability, with its own owner and its own test records.

How do federation choices change the high availability design?

Federation affects both traffic volume and the network paths you must keep available. Synapse federates on port 8448 by default, and delegation can serve user IDs on your domain from another host on port 443, so the listener and DNS records must stay reachable from other servers in every failover scenario. Open federation means more inbound and outbound events for workers to handle, while a federation_domain_whitelist limits traffic to listed domains and an empty list disables federation. The Synapse documentation recommends firewalling the federation listener as well. Decide federation policy before designing the worker layout, because it determines which worker types you need, how many, and which endpoints the load balancer must route, and it changes what you must test during failover.

How DeployOpen scopes, builds and hands over Matrix high availability

DeployOpen plans and builds Matrix high availability inside your own cloud accounts, data centers or air-gapped networks, starting from a written scope. We test the failover paths, document the runbooks and hand the platform to your team with the evidence your reviewers need.

How we scope

  • Map which Synapse processes, PostgreSQL nodes, Redis instances, media storage and load balancers must survive a single component failure.
  • Agree the availability target, recovery expectations and maintenance windows with your operations and risk owners before design starts.
  • Confirm the Synapse version, Python and PostgreSQL versions and hosting platform so the design matches what you will actually run.

How we build

  • Split the main process, generic workers and federation or media workers across hosts, with Redis carrying replication between them.
  • Configure PostgreSQL replication and tested backups, and verify that a restored database brings the homeserver back to a working state.
  • Test failover for each component, including load balancer health checks, media storage access and a forced restart of the main process.

How we hand over

  • Deliver architecture diagrams, configuration files, network rules and a component inventory with the version of each piece recorded.
  • Provide runbooks for failover, backup restore, rolling restarts and the upgrade steps that need worker and client retesting.
  • Train your platform and on-call staff on the failure scenarios tested, and record the results in a handover report.

How we support

  • Engagements are fixed-scope, with scope, deliverables and timelines agreed in writing before work starts.
  • Ongoing support, upgrades and continuous testing are available as a retainer, covering Synapse releases that change the database schema.
  • Retesting after each significant change to workers, Redis, PostgreSQL or storage, so availability claims stay backed by current evidence.

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.