Running a dedicated Synapse media repository worker

A dedicated media worker moves upload, download and thumbnailing off the main Synapse process. This page explains the required routes, the background media job instance, storage choices and what to confirm before you split it out.

On this page

When a dedicated Synapse media repository worker makes sense

A dedicated media repository worker separates media upload, download and thumbnailing from the rest of the Synapse process. Picture a team whose homeserver slows down whenever people share images, files and voice notes, while text messages stay fast. In a monolithic deployment, the same process handles that media work alongside client sync, event sending and federation, so large transfers and thumbnail generation compete with everything else for CPU, memory, database connections and I/O. Splitting media onto its own worker is the step that lets those requests stop competing with the rest of the traffic.

The split is worth planning when media is a visible share of the load, not merely when it is large in absolute terms. Look for slow responses on media endpoints that correlate with sync latency, heavy upload activity in particular rooms or from particular user groups, and thumbnail requests that spike after a busy day of sharing. Confirm your own load profile by measuring request counts and latency per endpoint before you commit to the change. The Synapse workers documentation describes how media routes are assigned to workers, so the decision should rest on which routes your traffic actually hits.

A media worker is one part of the broader worker model, not a standalone fix. It still needs Redis to relay replication between the main process and the other workers, and the routing layer in front of them must send media paths to the media worker and everything else to the appropriate generic workers. Plan these pieces together, because a media worker with incorrect routing or an unreachable replication listener will fail in ways that look like general server slowness. Ask your Synapse operator or partner to confirm the exact set of routes and worker configuration against the version you run before any change goes to production.

Which media routes the worker must serve

A media worker takes over a fixed set of HTTP routes, and those routes come in two families: client media paths used by Matrix apps and federation media paths used by other homeservers. Both families must reach the same worker, because media IDs and stored files are tied to that process's media store. Copy the exact route list from the current Synapse workers documentation rather than from memory, since the list changes between releases.

Client media upload and creation routes

These routes handle files sent from Element and other clients, including the upload path and the path for creating a media ID before the upload. They are the write side of the media store, so every upload must land on the worker that will later serve the file. Check whether your reverse proxy also needs an explicit upload size limit that matches the homeserver's max_upload_size setting. Confirm the exact patterns in the current workers documentation before writing any routing rules.

Synapse workers docs

Client media download and thumbnail routes

Download and thumbnail paths serve files and generated previews to clients. Thumbnail requests trigger image processing on the worker, so the CPU cost of resizing lands on this process rather than the main one. Route both the authenticated and the older unauthenticated media paths that your current Synapse release still exposes, and test each one with a real upload. Missing a download pattern usually shows up as broken images in rooms rather than as a clear error.

Federation media routes

Other homeservers fetch media from your server through federation paths, so these requests arrive on the federation listener, not the client port. If they reach the main process while uploads land on the worker, remote users see missing images and files in rooms they share with your users. Confirm which federation media paths your Synapse version serves and make sure the federation listener and its routing match the documented list. Consider the port 8448 federation traffic and delegation setup as part of the same test.

Federation docs

Why both families share one worker

Media IDs point to files in a single media store, and the worker that accepts an upload records where that file lives. If a client upload goes to one worker and a federation request for the same ID reaches another, the second process may not find the file. Keep the media repository in one designated worker, or use shared storage that every media-capable process can read, and document which choice you made. Test a federated download from a second server before you call the split complete.

Background media jobs need a single instance

Some media work, such as cleaning up remote media and deleting old thumbnails, runs as a background job rather than as a request. Only one process should run these jobs, so the background task setting must point to exactly one designated instance. Two processes running the same cleanup can delete files that the other is still serving. Name the instance that owns this work in your worker map, and confirm the setting in the configuration manual for your release.

Route inventory and verification

Build a table that lists each media route, the listener it arrives on, the worker that serves it and the test that proves it works. Include a test for a large upload, a thumbnail, a remote file fetched through federation and a deletion by an admin. Keep this table with your reverse proxy configuration so that the next upgrade can be checked against it. Ask your team or partner to repeat the table after each Synapse upgrade, because route patterns are the most common thing to break silently.

How client and federation media requests reach the worker

The diagram starts at the reverse proxy, which is the only component on the public listener. It sends media paths to the media repository worker and other client and federation traffic to the generic workers. The main process handles the remaining work. Redis relays replication between all Synapse processes over the private network, and the media worker and the main process both read and write the shared media store. When you check the setup, confirm that every media route reaches the worker, that no Synapse listener is exposed beyond the proxy, and that all processes point to the same store.

Media paths go to the worker, while Redis carries replication on a private network.

What the background media job instance does

Some media housekeeping in Synapse runs as background jobs rather than as request handling, and these jobs should run on exactly one designated instance, not on every media worker. Examples of this kind of work include cleaning up expired or remote media and generating thumbnails for remote files in the background. If several processes run the same job, you get duplicate work, lock contention on the database and harder-to-read logs. The decision you need to make early is which process takes this role, and whether that process is a dedicated media worker or a separate background-tasks worker that also handles other housekeeping.

Synapse controls this with worker configuration options that name a single instance to run background tasks and make the other workers skip them. The option names and the exact media-related behavior change between releases, so confirm them in the Synapse configuration manual for the version you run before writing any worker YAML. Check how each worker is declared in your configuration, that only one worker carries the background role, and that no worker has been copied from another with the role still set. Pick one worker, document it in your runbook, and make the choice part of your change process so a later scale-out does not quietly add a second instance.

Verify the setup after each change. Confirm in the logs of each media worker that no background media jobs start on the workers that are not designated, and that the designated instance starts them on its schedule. Watch database load and media storage growth during the first retention cycle, since a misconfigured role is easiest to spot as duplicated deletions or stalled cleanup. Ask your implementation partner or your own team to record the designated instance, its restart procedure and the rollback steps for the role, because a worker that is restarted during an upgrade must come back with the same role.

Choosing media storage for a split worker setup

A shared filesystem mounts the same media directory on every host that runs a media worker and on the main process that serves media. Synapse then reads and writes files through ordinary paths, so the media repository configuration points each process at the same location. This model is simple to reason about because there is one directory tree, but every worker depends on the mount being available, consistent and fast enough for both uploads and downloads. Confirm with your storage vendor how the shared volume handles file locking, concurrent writes from several hosts and failover, since those behaviors decide whether two workers can safely write thumbnails for the same media.

  • Shared visibility: every worker must mount the same path with the same permissions, and a missing mount on one host shows up as failed media requests only on that host.
  • Backup and restore: a consistent backup needs the database and the media directory captured close together, so plan a quiesce or snapshot step for the volume.
  • Cleanup: remote and local media purge jobs run against the directory, so confirm that the job host has write access and that deletions are visible to all workers.
  • Capacity measurement: track growth of the media directory, inode counts and latency on the volume during uploads and thumbnail generation.
  • Operational coupling: storage maintenance on the shared volume affects every media worker at once.

Before committing, ask the storage team to confirm the mount semantics and snapshot behavior for the volume you plan to use.

Media worker configuration options and when each fits

This table compares the main decisions for splitting Synapse media handling onto its own worker, from where media runs to how files are stored and whether federation media shares the same process. Read each row for the condition that favors it and the cost it adds, then confirm option names in the Synapse configuration manual before you write any config.

DecisionOptionTrade-offWhen it fits
Where media runsMain process handles mediaSimplest setup with no extra worker, but uploads and thumbnailing compete with sync and event trafficSmall deployments with light media use and few concurrent uploads
Where media runsDedicated media repository workerIsolates heavy media I/O from client traffic, adds routing rules and another process to monitorServers where uploads, downloads or thumbnailing slow down normal client requests
Background media jobsSingle background media instanceOne place runs cleanup and thumbnail generation, which keeps job ordering simple but can become a bottleneckDeployments with moderate media volume and one designated maintenance process
Background media jobsSeveral background media instancesSpreads work across processes, but requires the set of instances to be defined carefully and tested togetherLarge media volumes where one background process cannot keep pace
Media storageLocal shared filesystemLowest setup effort, but every worker that reads or writes media must reach the same mount, and the mount becomes a single point of failureSingle-host or small clusters with reliable shared storage already in place
Media storageShared object storageScales storage independently of hosts, but needs a Synapse media storage provider and a clear plan for backups and retentionMulti-host deployments or teams that already operate S3-compatible storage
Federation mediaSame worker serves federation and client mediaFewer moving parts, but federation download traffic from other servers shares capacity with local usersSmall federation footprint or a first worker split that keeps routing simple
Federation mediaSeparate worker for federation media routesLimits the load and firewall exposure of remote requests, but needs careful routing for the federation listenerPublic servers that federate widely and need to isolate remote traffic

Setting up the media worker step by step

This sequence moves media upload, download and thumbnailing from the main process to a dedicated worker, with background media jobs on one designated instance and a shared store for every process that handles media. Each step ends with a check you can run before moving to the next.

  1. Confirm Redis replication is already working

    Before adding anything, confirm that the main process and your existing workers connect through Redis and exchange replication traffic. Check the Synapse logs for successful replication connections on each process, and send a test message in a room to see that it reaches a client through a worker. Do this on the current deployment, not after the change, so any later fault can be traced to the media work. If replication is not stable, fix it first, because a media worker depends on the same replication path. The step is done when every process reports a healthy replication connection and the test message arrives.

  2. Define the media worker configuration

    Create a separate worker configuration file for the media process with its own worker name, a worker_app set to the media repository application, and a private HTTP listener that only the reverse proxy and the main process can reach. In the main process configuration, set enable_media_repo to false so the main process stops serving media. Confirm with the Synapse workers documentation that the listener resources and keys match the version you run. The step is done when the worker starts without configuration errors and its listener is bound to the private address you chose.

  3. Route client and federation media paths

    At the reverse proxy, send the client media paths under the Matrix media API prefix to the media worker's listener. Send the federation media paths, served on port 8448 by default, to the same worker, and keep the rest of the federation traffic on its existing routes. Confirm the exact path list against the current Synapse documentation for your version, since path sets change across releases. The step is done when a request to an upload or download path appears in the media worker's access log and not in the main process's log.

  4. Designate the background media instance

    Set media_instance_running_background_jobs in the shared configuration to the name of the media worker, so that scheduled media jobs such as remote media cleanup run on one instance only. Running these jobs on several processes at once can cause duplicate work and conflicts. Confirm in the workers documentation that this option applies to your version. The step is done when, after a restart, the log shows background media jobs starting on the designated worker and not on the main process or other workers.

  5. Mount shared media storage on every media process

    Place the media store on storage that every process handling media can read and write, and point media_store_path at the same location on each host. Set file ownership so the Synapse service user can write new media and read existing files. Ask your storage team to confirm that the mount is available at boot and that locking and latency meet the needs of your workload. Local disk works only when all media traffic goes to one host, so confirm your topology before choosing it. The step is done when a file written through one media process can be read through another.

  6. Verify client uploads, downloads and thumbnails

    Restart the affected processes in the order your deployment process requires, then test the client path with an access token. Upload a small image through the upload endpoint, download it by its media URI, and request a thumbnail at a set width and height. Confirm each request returns a successful response and that the media worker's log records each one. Check the media store for the new file and its thumbnail. The step is done when all three operations succeed through the proxy and the main process handles none of them.

  7. Verify federation media from another server

    Use a second homeserver you control, or a federated test account, to fetch media from your server over the federation path. Test a download and a thumbnail through port 8448 or the delegated endpoint, depending on how your server name is delegated. Check that the request is served by the media worker and that the remote server receives the expected content type. Repeat the test with a file uploaded from the other server to confirm inbound caching works. The step is done when both directions return the expected media and the worker's logs show the federation requests.

Security risks of exposing the media worker

A media worker accepts untrusted uploads and serves files to other servers, so it widens the attack surface of the homeserver. The cards below pair each exposure with the control that limits it, and each control should be checked on the running server, not only in the configuration file.

Public exposure of media routes

Only the media endpoints that clients and remote servers need should be reachable from the internet. Client media routes and federation media routes are served on different listeners, so the reverse proxy should forward only those paths to the media worker and return errors for everything else. Check the proxy configuration against the route list in the Synapse workers documentation, and test that unlisted paths do not reach the worker.

Synapse workers docs

Admin media API off public routes

The media admin API can list, quarantine and delete media for any user, so it must never be reachable through the public listener. Route its paths only on an internal address that administrators reach over a VPN or bastion host. Confirm with a test request from outside the network that these paths return an error at the proxy.

Replication listener on a private network

Workers talk to the main process and to Redis over the replication listener. If that listener is exposed, an attacker who reaches it may be able to inject replication traffic into the cluster. Bind the listener to a private interface, restrict it with firewall rules, and protect the replication secret. Verify from an external host that the port is closed.

File type and size limits

Uploads can carry executables, archives or files crafted to exploit a viewer, and oversized uploads consume disk and memory. Set a maximum upload size that matches the business need, and decide which content types clients may send. Document the limit and test it with an oversized file and an unexpected type, since the server enforces only what is configured.

Storage access controls

Media stored on local disk or in an object store is readable by anyone with access to that storage, including backup operators. Limit the Synapse service account to the media path or bucket, encrypt data at rest where your platform supports it, and separate credentials from the server configuration. Ask your storage team to confirm who holds read access to the bucket.

Quarantine and retention of media

Media from abusive or malicious users must be quarantined quickly, and retained media must follow your retention policy. Confirm that moderators can quarantine files through the admin tools, that quarantined files are not served to other servers, and that deletion jobs run on the worker designated for background tasks. Record who performs these actions.

Questions teams ask before splitting out media

Can our in-house team split media onto a dedicated Synapse worker?

Yes, if your team already runs Synapse with a reverse proxy, Redis and PostgreSQL, and at least one engineer who can read the worker documentation and change routing safely. The work is mostly configuration, proxy rules and testing, so the main risk is an untested cutover. Before you start, check whether your current deployment is still a single process, whether you have a recent tested backup, and whether you can run a staging copy with production-like traffic. If any of those is missing, a fixed-scope engagement from DeployOpen can cover the planning, build, testing and documentation, with the written scope agreed before work starts.

What makes a Synapse media worker project take longer?

Four factors drive the effort most: how many media-handling workers you run, which storage backend holds the media, how much your reverse proxy routing has to change, and what monitoring you add to watch the new processes. More workers mean more instance names, more replication and more places to verify. Shared storage that several hosts must read adds access, permission and backup work. Routing changes touch every media path that clients and remote servers use, so each route needs a test. The Synapse workers documentation explains how processes connect through Redis, which is where most of the configuration design starts.

Does moving Synapse media to its own worker require downtime?

It can be done with little or no user-visible interruption, but the answer depends on how your current layout is wired and how you cut traffic over. Adding worker processes usually means restarting Synapse after configuration changes, and the proxy must send media requests to the new process at the right moment. Teams that stage the change, verify each media route on a copy, and switch routing in one controlled step tend to keep interruption short. Teams that edit production configuration live without a rollback path are more likely to see failed uploads or broken remote media. Confirm the restart behavior for your Synapse version against the upgrade and workers documentation before you schedule a window.

What skills does the team need to run a media worker?

The team needs four working skills: Synapse configuration, reverse proxy routing, Redis and PostgreSQL administration, and storage administration for wherever media is kept. Someone must understand which URL paths carry client media and which carry federation media, because both must reach a media-capable process. DNS, TLS and the federation listener also matter, since remote servers reach your media through the same public names and ports as your homeserver. Monitoring skills are needed to watch the new processes after go-live. Ownership should be written down, including who reviews Synapse upgrade notes and who approves a rollback.

How do we tell media is the bottleneck on our Synapse server?

Measure before you split anything. Media is likely the bottleneck when slow responses concentrate on upload and download paths while the main process and database look healthy, and when disk input and output rise during uploads, downloads or thumbnail generation. Compare proxy access logs for media paths against logs for sync and event traffic over the same period. Look at CPU and memory per process, and at the Synapse metrics your version exposes, which you should confirm in the configuration manual. If the main process is busy with event handling or sync, the first worker you add may be for a different traffic type, so the measurements should decide the order.

How do Synapse upgrades affect a media worker layout?

Each Synapse release can change configuration, database schema or supported platforms, so a worker layout that works today may need changes after an upgrade. Read the upgrade notes for every version between your current release and the target, not only the latest one. Synapse 1.143.0 and later require PostgreSQL 14 or newer, and 1.142.0 and later require Python 3.10 or newer, so check those floors before you plan. The upgrade notes also warn that rolling back can be difficult because of database schema changes, so take a database backup and test the upgrade on a copy that includes the worker processes. Keep a written record of which process handles which media route so an upgrade does not silently move traffic.

Should Synapse media use local disk or shared object storage?

The answer depends on where your workers run. If every media-handling process runs on the same host, local disk may be enough, provided backups, retention and disk capacity are planned. If workers run on several hosts, they must all see the same media, which pushes you toward shared or networked storage. The choice also affects backup scope, restore time, retention and how media is cleaned up after deletion. Confirm which storage options your Synapse version supports in the configuration manual, and ask your storage team how they will back up and restore media alongside the database. Test a media restore before you rely on the design.

Does a media worker change our security and data protection duties?

Media is user content, so a media worker does not remove any duty you already have, and it adds new paths you must control. Review which routes are exposed publicly, which are reachable only by remote servers, and which processes can read or delete files. Keep administrative and replication endpoints on private networks, and make sure access logs do not record more personal data than your policy allows. Retention and deletion rules must cover media as well as messages, and your backups should follow the same rules. If you need evidence for an assessment, the Matrix compliance and hardening guidance in this library lists the controls to document.

How DeployOpen scopes and delivers a Synapse media worker

DeployOpen plans and implements the media repository split inside your own infrastructure, so the routing, storage and background job decisions are documented before any change reaches production. Each step is written against your domain layout, federation policy and existing worker setup, and handed over so your platform team can operate it.

How we scope

  • We inventory your current Synapse version, worker layout, reverse proxy and whether federation media routes are already in use.
  • The written scope names the media routes to move, the worker instances, the storage backend and the monitoring you need.
  • Engagements are fixed-scope, with deliverables and timelines agreed in writing before any configuration change starts.

How we build

  • We configure the media worker, its replication settings and the reverse proxy rules for client and federation media paths.
  • We separate the background media job instance from the media worker and confirm which process runs cleanup and thumbnail tasks.
  • We test uploads, downloads, thumbnails and cross-server media fetches on a staging copy before any production cutover.

How we hand over

  • You receive the configuration files, routing map and a record of every decision on storage location and access paths.
  • We document the rollback steps, including which settings to revert if media requests fail after the split.
  • Your team gets a runbook covering media cleanup, storage growth checks and the logs that show worker health.

How we support

  • Ongoing support, upgrades and continuous testing are available as a retainer, covering Synapse version changes that affect media routes.
  • Before each Synapse upgrade, we review the upgrade notes for changes to media settings and worker requirements in your setup.
  • Confirm with us during scoping whether your team needs retesting after storage or reverse proxy changes outside this project.

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.