Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Commit 0a00347

Browse files
committed
Merge commit '079bc3c8e' into anoa/dinsic_release_1_21_x
* commit '079bc3c8e': Fixup worker doc (again) (#8000)
2 parents d174faa + 079bc3c commit 0a00347

File tree

3 files changed

+43
-14
lines changed

3 files changed

+43
-14
lines changed

changelog.d/8000.doc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Improve workers docs.

docs/systemd-with-workers/workers/federation_reader.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
worker_app: synapse.app.federation_reader
2+
worker_name: federation_reader1
23

34
worker_replication_host: 127.0.0.1
4-
worker_replication_port: 9092
55
worker_replication_http_port: 9093
66

77
worker_listeners:

docs/workers.md

Lines changed: 41 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ The processes communicate with each other via a Synapse-specific protocol called
2323
feeds streams of newly written data between processes so they can be kept in
2424
sync 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
2828
stream between all configured Synapse processes. Additionally, processes may
2929
make HTTP requests to each other, primarily for operations which need to wait
@@ -66,23 +66,31 @@ https://hub.docker.com/r/matrixdotorg/synapse/.
6666

6767
To make effective use of the workers, you will need to configure an HTTP
6868
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
7070
[reverse_proxy.md](reverse_proxy.md) for information on setting up a reverse
7171
proxy.
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
105113
public internet; it has no authentication and is unencrypted.
106114
107115
108-
### Worker Configuration
116+
### Worker configuration
109117
110118
In the config file for each worker, you must specify the type of worker
111119
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.
145153
Obviously you should configure your reverse-proxy to route the relevant
146154
endpoints to the worker (`localhost:8083` in the above example).
147155

156+
157+
### Running Synapse with workers
158+
148159
Finally, 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
150161
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
407418
which 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

412440
The following shows an example setup using Redis and a reverse proxy:

0 commit comments

Comments
 (0)