@@ -23,7 +23,7 @@ The processes communicate with each other via a Synapse-specific protocol called
2323feeds streams of newly written data between processes so they can be kept in
2424sync with the database state.
2525
26- When configured to do so, Synapse uses a
26+ When configured to do so, Synapse uses a
2727[ Redis pub/sub channel] ( https://redis.io/topics/pubsub ) to send the replication
2828stream between all configured Synapse processes. Additionally, processes may
2929make HTTP requests to each other, primarily for operations which need to wait
@@ -66,23 +66,31 @@ https://hub.docker.com/r/matrixdotorg/synapse/.
6666
6767To make effective use of the workers, you will need to configure an HTTP
6868reverse-proxy such as nginx or haproxy, which will direct incoming requests to
69- the correct worker, or to the main synapse instance. See
69+ the correct worker, or to the main synapse instance. See
7070[ reverse_proxy.md] ( reverse_proxy.md ) for information on setting up a reverse
7171proxy.
7272
73- To enable workers you should create a configuration file for each worker
74- process. Each worker configuration file inherits the configuration of the shared
75- homeserver configuration file. You can then override configuration specific to
76- that worker, e.g. the HTTP listener that it provides (if any); logging
77- configuration; etc. You should minimise the number of overrides though to
78- maintain a usable config.
73+ When using workers, each worker process has its own configuration file which
74+ contains settings specific to that worker, such as the HTTP listener that it
75+ provides (if any), logging configuration, etc.
7976
77+ Normally, the worker processes are configured to read from a shared
78+ configuration file as well as the worker-specific configuration files. This
79+ makes it easier to keep common configuration settings synchronised across all
80+ the processes.
8081
81- ### Shared Configuration
82+ The main process is somewhat special in this respect: it does not normally
83+ need its own configuration file and can take all of its configuration from the
84+ shared configuration file.
85+
86+
87+ ### Shared configuration
88+
89+ Normally, only a couple of changes are needed to make an existing configuration
90+ file suitable for use with workers. First, you need to enable an "HTTP replication
91+ listener" for the main process; and secondly, you need to enable redis-based
92+ replication. For example:
8293
83- Next you need to add both a HTTP replication listener, used for HTTP requests
84- between processes, and redis config to the shared Synapse configuration file
85- (` homeserver.yaml ` ). For example:
8694
8795``` yaml
8896# extend the existing `listeners` section. This defines the ports that the
@@ -105,7 +113,7 @@ Under **no circumstances** should the replication listener be exposed to the
105113public internet; it has no authentication and is unencrypted.
106114
107115
108- ### Worker Configuration
116+ ### Worker configuration
109117
110118In the config file for each worker, you must specify the type of worker
111119application (` worker_app`), and you should specify a unqiue name for the worker
@@ -145,6 +153,9 @@ plain HTTP endpoint on port 8083 separately serving various endpoints, e.g.
145153Obviously you should configure your reverse-proxy to route the relevant
146154endpoints to the worker (`localhost:8083` in the above example).
147155
156+
157+ # ## Running Synapse with workers
158+
148159Finally, you need to start your worker processes. This can be done with either
149160` synctl` or your distribution's preferred service manager such as `systemd`. We
150161recommend the use of `systemd` where available : for information on setting up
@@ -407,6 +418,23 @@ all these to be folded into the `generic_worker` app and to use config to define
407418which processes handle the various proccessing such as push notifications.
408419
409420
421+ # # Migration from old config
422+
423+ There are two main independent changes that have been made : introducing Redis
424+ support and merging apps into `synapse.app.generic_worker`. Both these changes
425+ are backwards compatible and so no changes to the config are required, however
426+ server admins are encouraged to plan to migrate to Redis as the old style direct
427+ TCP replication config is deprecated.
428+
429+ To migrate to Redis add the `redis` config as above, and optionally remove the
430+ TCP `replication` listener from master and `worker_replication_port` from worker
431+ config.
432+
433+ To migrate apps to use `synapse.app.generic_worker` simply update the
434+ ` worker_app` option in the worker configs, and where worker are started (e.g.
435+ in systemd service files, but not required for synctl).
436+
437+
410438# # Architectural diagram
411439
412440The following shows an example setup using Redis and a reverse proxy :
0 commit comments