Dedicated Synapse workers for background tasks, user directory and appservices

Moving background jobs, user directory updates and application service traffic onto their own Synapse processes reduces load on the main process, but the single-instance options and Redis wiring need careful planning.

On this page

When dedicated Synapse workers for background tasks and appservices make sense

Dedicated workers for background tasks, the user directory and appservice traffic make sense when your main Synapse process spends a measurable share of its capacity on work that is not serving clients. Typical signs are slow client responses at times when scheduled housekeeping runs, directory updates that lag behind room changes, or heavy traffic to bridges and other application services. Before you move anything, confirm the pattern in your own metrics and logs. Work out which of these duties actually load the main process, because the fix differs for each. The supplied facts do not give sizing numbers for this, so treat any threshold you read elsewhere as a starting hypothesis to test in your environment.

Some of this work cannot be spread across instances. Background tasks, such as scheduled database maintenance, must run on one process only, or two workers would perform the same job at the same time. Synapse handles this by letting you name the instance that runs them through the run_background_tasks_on setting. The user directory and appservice notifications also depend on designated handling, so a dedicated worker only takes over a duty when you configure it to. Read the Synapse workers documentation for the single-instance options that apply to your Synapse version, and confirm the exact configuration keys against the version you run before you change production.

This step is part of a wider move to workers, not a standalone fix. Every process in a worker deployment connects to Redis for replication, so the first decision is whether you are prepared to run Redis, secure its replication path and monitor it. Ask any implementation partner to price the Redis service, the extra configuration and testing, and the monitoring you will need to see whether the change helped. Those costs recur as long as the deployment runs, and they grow with the number of workers. If your metrics show the main process is already struggling with client traffic, the case for background or appservice workers alone may be weaker than a broader plan.

Which background jobs can move to their own process

A Synapse homeserver splits its work across a small set of worker roles, and each role has different rules about how many instances may run. Some tasks can be spread across processes, while others must run on exactly one instance at a time. Confirm these constraints against the workers documentation for your Synapse version before you assign roles.

Background task runner

The run_background_tasks_on option names the one worker that runs scheduled background jobs, such as database housekeeping and cleanup tasks that would otherwise compete for the main process. Only one process should run these jobs, so set the option on a single worker and do not assign it to several. Confirm which named jobs the docs list for your version before you move any of them.

Synapse workers docs

User directory updates

The user directory is kept current by a background process that reads the event stream and updates search results. Synapse documents that this work must not be duplicated, so it belongs on a designated single instance rather than on each generic worker. Ask your team to confirm the current single-instance rule in the workers docs, and to check how stale directory results would appear to users during a restart.

Application service notifications

Application services such as bridges receive events through a dedicated pusher path that runs in the background. Map which process sends these notifications, confirm whether that role is single-instance, and make sure the bridge is reachable from that process. Bridge outages often look like message delays, so test delivery after any change to the assignment.

Generic worker for client traffic

A generic worker handles client, federation and event traffic, and unlike the singleton roles it can usually run as several identical instances behind a load balancer. Routing rules decide which requests reach it, so the choice of endpoints directly controls its load. Confirm with the docs which endpoints a generic worker may serve before you route any of them there.

Redis replication between processes

Every worker connects to the main process through Redis, which relays replication messages between processes. A background role that is misplaced or duplicated will show up as missing or repeated events, so the replication layer is the first place to check after a role change. Confirm the Redis configuration and the replication secret in the workers guide before you start more than one copy of any singleton role.

Worker options for background tasks, user directory and appservices

This table compares the settings that move background tasks, user directory updates and appservice notifications off the main process, along with the default and generic worker options. Read each row for what it controls and where it fits, then confirm exact key names and worker naming in the Synapse configuration manual before you edit anything. The main takeaway is that each single-instance option assigns one job to one named process, so the choice depends on how much load that job carries and how you will handle a worker outage.

OptionWhat it controlsWhen it fitsTrade-off
Default (main process)Runs background tasks, user directory updates and appservice notifications on the main process when no worker options are set.Small deployments with light traffic and no workers yet.Background load competes with client and federation requests on the main process.
run_background_tasks_onMoves background tasks, such as scheduled database maintenance, onto a named worker instance.Main process latency rises during background jobs and you can spare a separate process.Background work depends on that worker. Its Redis and database access must be correct.
update_user_directory_from_workerSends user directory updates to one named worker instead of the main process.Large servers where many accounts or room memberships change often.Only one worker handles the job. If it stops, directory results can lag until it recovers.
notify_appservices_from_workerSends application service event notifications from one named worker.Servers with busy bridges, bots or integrations that need frequent event delivery.A single sender. Delays affect every bridge until the worker restarts or catches up.
Generic workerHandles client, federation and event traffic through routed endpoints, and can run alongside the single-instance roles.You need more capacity for request traffic and want background roles on separate processes.More routing and monitoring work. Each worker must receive only the endpoints assigned to it.
Redis replicationRelays replication between the main process and all workers so stream and cache updates reach each process.Any deployment that splits these roles across processes.Redis becomes a dependency for every worker. Plan its sizing, authentication and monitoring.
Single-instance checkConfirms that each single-instance role is assigned to exactly one named worker in the configuration.Before every restart and after every change to worker names.Duplicate or missing assignments cause jobs to run twice or not at all. Verify against the manual.

How the main process, Redis and workers share this work

The main process and every worker connect to Redis, and Redis relays replication between them, so each process sees the same stream of events and state changes. Moving a background job onto a worker does not move its data. The worker still reads and writes through the same PostgreSQL database as the main process, and it learns about changes made elsewhere from the replication stream that Redis carries. Before you move anything, confirm that every process can reach the same Redis instance and the same database, and that the replication listener is reachable only on your private network. A worker that cannot reach Redis will fall behind or fail to start, and the symptoms can look like a slow server rather than a connectivity fault.

Background tasks are the work the main process would otherwise run for itself. The run_background_tasks_on setting names the one worker that runs them, so the main process stops doing that work once you set it. Some jobs must never run on more than one process. User directory updates and application service notifications are examples: two processes working on the same rows can race each other or send duplicate notifications. For these, the single-instance worker options assign each job to one named worker. Decide which worker owns each job before you write the configuration, and record that decision in your runbook so that later changes are deliberate.

Ownership errors are easy to miss because nothing fails loudly. If the designated worker is down, directory updates or appservice notifications can stop while the rest of the server looks healthy. If two processes both believe they own a job, the damage appears as duplicates or inconsistent data. After each change, restart the affected processes, then check the logs of the owning worker and the main process to confirm which one runs each job. Add an alert for the owning worker's availability. Confirm the exact option names and their restart requirements against the Synapse workers documentation for the Synapse version you run, because configuration keys change between releases.

How background, directory and appservice workers connect to Synapse

Client and federation traffic enter through the reverse proxy and reach the generic worker and the main process, which share state through PostgreSQL. Redis relays replication between all processes, so background, directory and appservice workers receive stream updates without a direct path to clients. Check that the replication listener sits inside the private network boundary, and that exactly one process runs each singleton task.

Traffic path and replication boundary for the background, directory and appservice workers.

Setting up dedicated workers step by step

This sequence moves background tasks, user directory updates and appservice notifications onto dedicated Synapse worker processes, with each step ending in a check that confirms the change worked. Run it on a staging copy first, because the single-instance options must be set exactly once across the whole deployment.

  1. Confirm the version and platform floors

    The platform owner reads the Synapse upgrade notes for the target release and compares them with the PostgreSQL and Python versions on the servers. Recent releases raise the minimum PostgreSQL and Python versions, so confirm both before changing anything. Record the running Synapse version and take a verified database backup. The step is done when the versions meet the notes, the backup restores in a test environment, and the rollback limits described in the notes are understood by the change owner.

  2. Enable Redis and the replication secret

    The Synapse administrator enables the Redis settings in the main homeserver configuration and sets a worker replication secret that every process must present. Redis relays replication between the main process and the workers, so it should be reachable only from the private network that hosts Synapse. Confirm the exact key names in the configuration manual for the installed release. The step is done when Redis answers a ping from a Synapse host and the main process starts without replication errors in its log.

  3. Define each worker and its config file

    The administrator creates one configuration file per worker process, giving each a unique worker name, a worker type and a replication listener on a private address and port. Worker types for background duties differ between Synapse releases, so match the type to the release notes and the workers documentation. The main configuration must list the worker's listener in its instance map. The step is done when every file parses, every name is unique, and each worker starts without listing a port already used by another process.

  4. Assign single-instance duties to one worker

    The administrator sets run_background_tasks_on to the name of one designated worker and enables the single-instance options for the user directory and appservice notifications on that same worker. These duties must run in exactly one process, so no other worker or the main process may also be configured for them. Keep a written record of which worker holds each duty. The step is done when a search of all configuration files shows each option set once, and the designated worker name matches the file that defines it.

  5. Register the appservice configuration path

    The administrator adds each application service registration file to the main configuration and confirms that the appservice notifications route to the worker chosen in the previous step. The registration file holds the tokens and namespaces the bridge or bot uses, so restrict read access to the file. Check the bridge's own documentation for the endpoints it expects. The step is done when the homeserver loads the registration file without errors and the bridge reports a successful connection after the restart.

  6. Restart processes and confirm worker connections

    The operator restarts the main process first, then the workers, and reads each process log from start to finish. Every worker should announce that it has connected to replication through Redis and should not report authentication failures. Each worker's logs should show the name it was given in its config file. The step is done when all expected workers appear as connected, Redis shows active connections from each of them, and no process is restarting in a loop.

  7. Verify that background jobs run once

    The operator triggers a user directory change and a test message to an appservice-bridged room, then checks which process logs the work. Background jobs should appear only in the designated worker's logs, and the main process and other workers should not repeat them. Watch the logs for duplicate directory updates or repeated appservice transactions over a normal operating period. The step is done when each job appears in one process only, the test changes show up in the directory and the bridge, and the results are recorded for the change record.

Security and operational risks of separate worker processes

Moving background tasks, the user directory and appservice traffic into their own processes adds listeners, shared secrets and routing rules that a monolithic Synapse does not have. The cards below cover the places where a worker split can widen exposure or duplicate work, and what to verify before go-live. Broader controls are covered in the Matrix homeserver hardening group.

Replication listener on a private network

Workers talk to the main process and to each other through a replication listener, and that listener carries internal event traffic that should never be reachable from the internet or from client-facing networks. Confirm that the replication port is bound to a private interface, that host firewall rules block it from outside the worker subnet, and that the reverse proxy never forwards replication paths. Treat any reachable replication port as a full compromise path for the homeserver.

Synapse workers docs

Worker HTTP listeners exposed by mistake

Each worker that serves HTTP, such as a background or user directory process, opens a listener on its own port. A proxy rule that matches too broadly can send admin, replication or internal routes to those ports, or leave them reachable from outside the cluster. Check that only the routes your routing map assigns to each worker are proxied, that worker ports are not published on public addresses, and that a test request to each internal route fails from an external host.

Appservice token handling

Application services such as bridges authenticate to Synapse with registration files that hold an as_token and an hs_token. Those tokens grant broad powers over the users and rooms the bridge controls, so they should be stored with restricted file permissions, rotated when a bridge is retired, and kept out of shared configuration repositories. When appservice traffic is routed to a dedicated worker, confirm that the registration file is readable only by the Synapse service account and that the worker logs do not print token values.

Duplicate background jobs from repeated single-instance options

Background jobs such as database maintenance, the user directory refresher and media cleanup are meant to run in one process at a time. If the same single-instance option is set on more than one worker, or the main process still runs a job that a worker also claims, the job can run twice and compete for locks or rewrite the same rows. Audit every worker file for run_background_tasks_on and the single-instance options, keep a written map of which process owns each job, and check logs after each restart for duplicate job start messages.

Admin API access through worker routes

Admin endpoints under the /_synapse/admin path can change users, rooms and media, and they should only be served by the main process or a restricted admin worker. If a generic or background worker accepts those paths, anyone who reaches that worker may gain administrative reach. Confirm which processes answer admin routes, restrict those routes to the administrator network or a bastion, and test that a non-admin client receives a refusal from every worker port.

Questions teams ask before moving background work to Synapse workers

What does it cost to move background tasks onto Synapse workers?

The cost is mostly the engineering time to split one process into several, plus the Redis, PostgreSQL and monitoring work that comes with it. Effort rises with the number of worker types you add, how many hosts or containers run them, and how much of your current configuration is hand-edited. The one-time work covers planning the process layout, writing the worker YAML files, configuring the replication secret, testing failover of background jobs and updating monitoring. Recurring work is smaller: reviewing each Synapse upgrade, since the upgrade notes can change worker behavior, and keeping the worker list aligned with the main configuration. Ask any partner for a written quote that lists each of these items separately, with the test environment and rollback steps included.

What drives the duration of a background worker project?

Duration depends on how much the current deployment already matches the documented layout, how many environments must be changed, and how many change windows the team can use. A single production homeserver with a staging copy usually takes longer than a lab install, because each step must be proven in staging first. Other drivers include whether Redis and a private network for the replication listener already exist, whether monitoring already reports per-process metrics, and how quickly approvals come through. Upgrades to the Synapse release in use, and the platform floors that come with them, can add time if the host or PostgreSQL version must change first. Ask for a schedule that separates planning, staging, production cutover and a post-change review, and confirm which of those the team will own.

What must our team provide before the work starts?

Plan to provide Linux hosts or containers for each worker process, network access between those hosts and the existing PostgreSQL database, and Redis reachable from the main process and every worker. You will also need a change window for each restart, because the main process and workers must be restarted after the configuration changes. Access to the Synapse configuration files, the reverse proxy and the monitoring stack is required, along with a staging environment that mirrors production as closely as possible. Confirm the PostgreSQL and Python versions against the Synapse upgrade notes before the project starts, since Synapse drops support for versions once they reach upstream end of life. Keep the replication listener on a private network, and confirm who approves firewall changes.

Can an internal team move background tasks to workers without outside help?

Yes, a team with Linux, PostgreSQL and reverse proxy experience can make this change alone if it reads the worker documentation, tests in staging and keeps a rollback plan. The risk is in the details: a background-task instance and a singleton worker must not run in more than one place, and the configuration must match across processes. Teams with no Redis or replication experience usually take longer, because they must learn how worker replication behaves before making production changes. An outside partner adds value when the team lacks time, wants a second review of the configuration, or needs the work documented for an audit. Decide early which parts your staff will own after the handover, such as upgrades and failover tests.

How is this different from a full worker migration?

A full worker migration moves client traffic, federation, event persistence, media and push onto many worker processes. Moving only background tasks, the user directory and application service notifications is a narrower change: you dedicate a few processes to singleton jobs and leave most client traffic on the main process or existing generic workers. The narrower scope usually means fewer routing rules, fewer sticky-session decisions and less Redis traffic to tune. It still requires the same replication setup, the same Redis access and the same restart discipline. Ask any partner to confirm which worker types are in scope, and to list the routes and endpoints that will not change, so that the project does not quietly expand into a full migration.

Do Synapse Pro or Element Server Suite change this approach?

Synapse Pro and Element Server Suite change the licensing and the deployment method, but the worker concepts remain the same. ESS Pro is deployed on Kubernetes with Helm charts and includes Synapse Pro, Matrix Authentication Service, LDAP and SCIM integration and auditing, so the worker layout is managed through that deployment rather than by hand-editing files. Community Synapse is licensed under AGPL-3.0, and you configure its workers yourself. Before choosing, compare the operational load of hand-tuned workers against the features of the commercial route, and ask Element to confirm which licence and support terms apply to your deployment. Do not assume the commercial route removes the need for planning, testing and monitoring of background jobs.

What breaks most often when background workers are configured incorrectly?

The most common failures are duplicate background jobs, a singleton task that runs on two processes at once, and missing replication configuration that leaves a worker unable to receive events. Symptoms include user directory results that lag or disappear, application service traffic that stops, and database load that spikes after a restart. Verify each worker's role in its log output after every change, confirm that only one process runs each singleton task, and check that Redis connections succeed from every host. Run the same checks after each Synapse upgrade, since the upgrade notes can change how workers behave. Keep the previous configuration files so the change can be reverted quickly.

Where to verify worker options before you change production

Before you change a production Synapse config, confirm every worker option against the documentation for the exact release you run. The authoritative references are the Synapse workers documentation, which describes how run_background_tasks_on, notify_appservices_from and update_user_directory_from are meant to be assigned, the Synapse configuration manual, which gives each key's accepted values and defaults, and the upgrade notes for release-specific changes. Treat the latest pages as a starting point only, since they describe the newest release and may differ from the version your servers run.

Option names and behavior change between Synapse releases, so a key that worked on one version may be renamed, deprecated or require a different worker type on another. Record the Synapse version you run, then read the configuration manual and upgrade notes for every release between that version and your target before editing homeserver.yaml or the worker config files. Ask your platform team to confirm the exact key names, the accepted worker names in the instance_map and whether the single-instance options still apply to your release, and keep the old and new configs side by side so you can compare them during the change.

Upgrade notes also warn that rollbacks can be hard because of database schema changes, so confirm the worker layout in a staging environment that runs the same release and database version before production. The Synapse upgrade notes are the place to check whether a new release changes worker behavior, and the record of what you verified should travel with your change ticket so the next operator can see which version the settings were checked against.

How DeployOpen delivers Synapse worker deployments

DeployOpen plans, builds and hands over Dedicated Synapse workers for background tasks, user directory and appservices inside infrastructure you control. Each engagement starts with a written scope that names which processes take which jobs, how Redis and PostgreSQL are involved, and how the result will be verified and operated.

How we scope

  • We confirm your current Synapse version, deployment method and whether the homeserver already runs with workers or as one process.
  • The written scope lists each background, user directory and appservice worker, its role and the configuration keys it depends on.
  • We agree in writing which Redis, PostgreSQL, monitoring and routing changes are included, and which are your team's responsibility.

How we build

  • We stage the worker layout in a non-production Synapse environment that matches your database version and Python runtime.
  • We configure run_background_tasks_on and the single-instance worker options, then confirm that only the intended process runs each singleton job.
  • We test appservice delivery, user directory updates and background database work under realistic load before any cutover to production.

How we hand over

  • You receive the worker configuration, process map, replication and firewall notes, and a record of every change made to the homeserver.
  • We document the upgrade checks for each Synapse release, including reading the upgrade notes for schema and rollback limits before you upgrade.
  • Your team gets a walkthrough of how to confirm each worker is healthy and how to restart a single worker without disrupting the others.

How we support

  • Engagements are fixed-scope, so changes after handover are quoted against a written change request.
  • Ongoing support, upgrades and continuous testing are available as a retainer if you want DeployOpen to keep the worker layout current.
  • Before each Synapse upgrade, we can review the release notes against your worker configuration and retest appservice and directory behavior.

Sources and further reading

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.