@@ -23,7 +23,7 @@ The processes communicate with each other via a Synapse-specific protocol called
23
23
feeds streams of newly written data between processes so they can be kept in
24
24
sync with the database state.
25
25
26
- When configured to do so, Synapse uses a
26
+ When configured to do so, Synapse uses a
27
27
[ Redis pub/sub channel] ( https://redis.io/topics/pubsub ) to send the replication
28
28
stream between all configured Synapse processes. Additionally, processes may
29
29
make HTTP requests to each other, primarily for operations which need to wait
@@ -66,23 +66,31 @@ https://hub.docker.com/r/matrixdotorg/synapse/.
66
66
67
67
To make effective use of the workers, you will need to configure an HTTP
68
68
reverse-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
70
70
[ reverse_proxy.md] ( reverse_proxy.md ) for information on setting up a reverse
71
71
proxy.
72
72
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.
79
76
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.
80
81
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:
82
93
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:
86
94
87
95
``` yaml
88
96
# 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
105
113
public internet; it has no authentication and is unencrypted.
106
114
107
115
108
- ### Worker Configuration
116
+ ### Worker configuration
109
117
110
118
In the config file for each worker, you must specify the type of worker
111
119
application (` 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.
145
153
Obviously you should configure your reverse-proxy to route the relevant
146
154
endpoints to the worker (`localhost:8083` in the above example).
147
155
156
+
157
+ # ## Running Synapse with workers
158
+
148
159
Finally, you need to start your worker processes. This can be done with either
149
160
` synctl` or your distribution's preferred service manager such as `systemd`. We
150
161
recommend 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
407
418
which processes handle the various proccessing such as push notifications.
408
419
409
420
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
+
410
438
# # Architectural diagram
411
439
412
440
The following shows an example setup using Redis and a reverse proxy :
0 commit comments