Add support for multiple federation sender workers

This commit is contained in:
Slavi Pantaleev 2022-09-15 08:13:08 +03:00
parent 226c550ffa
commit ec654ca91e
5 changed files with 27 additions and 7 deletions

View File

@ -4,7 +4,8 @@
People who are interested in running a Synapse worker setup should know that **our Synapse worker implementation is much more powerful now**:
- we've added [Stream writers support](#stream-writers-support)
- we've added support for [Stream writers](#stream-writers-support)
- we've added support for [multiple federation sender workers](#multiple-federation-sender-workers-support)
- see the [Potential Backward Incompatibilities after these Synapse worker changes](#potential-backward-incompatibilities-after-these-synapse-worker-changes)
### Stream writers support
@ -26,6 +27,11 @@ matrix_synapse_workers_stream_writer_receipts_stream_workers_count: 1
matrix_synapse_workers_stream_writer_presence_stream_workers_count: 1
```
### Multiple federation sender workers support
Until now, we only supported a single `federation_sender` worker (`matrix_synapse_workers_federation_sender_workers_count` could either be `0` or `1`).
From now on, you can have as many as you want to help with your federation traffic.
### Potential Backward Incompatibilities after these Synapse worker changes
Below we'll discuss **potential backward incompatibilities**.

View File

@ -510,12 +510,21 @@ matrix_synapse_workers_pusher_workers_metrics_range_start: 19200
matrix_synapse_workers_appservice_workers_count: 0
matrix_synapse_workers_appservice_workers_metrics_range_start: 19300
# matrix_synapse_workers_federation_sender_workers_count can only be 0 or 1 for now.
# More instances are not supported due to a playbook limitation having to do with keeping `federation_sender_instances` in `homeserver.yaml` updated.
# matrix_synapse_workers_federation_sender_workers_count controls the number of federation sender workers to spawn.
# See https://github.com/matrix-org/synapse/blob/master/docs/workers.md#synapseappfederation_sender
matrix_synapse_workers_federation_sender_workers_count: "{{ matrix_synapse_workers_presets[matrix_synapse_workers_preset]['federation_sender_workers_count'] }}"
matrix_synapse_workers_federation_sender_workers_metrics_range_start: 19400
# matrix_synapse_federation_sender_instances populates the `federation_sender_instances` Synapse configuration used when Synapse workers are in use (`matrix_synapse_workers_enabled`).
# What you see below is an initial default value which will be adjusted at runtime based on the value of `matrix_synapse_workers_federation_sender_workers_count` or `matrix_synapse_workers_enabled_list`.
# Adjusting this value manually is generally not necessary.
matrix_synapse_federation_sender_instances: []
# matrix_synapse_send_federation controls if theh main Synapse process should send federation traffic.
# This is allowed if workers are disabled, or if there are no federation sender workers.
# Adjusting this value manually is generally not necessary.
matrix_synapse_send_federation: "{{ not matrix_synapse_workers_enabled or (matrix_synapse_workers_enabled_list | selectattr('type', 'equalto', 'federation_sender') | list | length > 0) }}"
matrix_synapse_workers_media_repository_workers_count: "{{ matrix_synapse_workers_presets[matrix_synapse_workers_preset]['media_repository_workers_count'] }}"
matrix_synapse_workers_media_repository_workers_port_range_start: 18551
matrix_synapse_workers_media_repository_workers_metrics_range_start: 19551

View File

@ -53,6 +53,13 @@
register: "matrix_synapse_workers_list_results_federation_sender_workers"
loop: "{{ range(0, matrix_synapse_workers_federation_sender_workers_count | int) | list }}"
- name: Populate matrix_synapse_federation_sender_instances from enabled federation sender workers list
ansible.builtin.set_fact:
matrix_synapse_federation_sender_instances: "{{ matrix_synapse_federation_sender_instances + [item.ansible_facts.worker.name] }}"
with_items: "{{ matrix_synapse_workers_list_results_federation_sender_workers.results }}"
- debug: var="matrix_synapse_federation_sender_instances"
# This type of worker can only have a count of 1, at most
- name: Build pusher workers
ansible.builtin.set_fact:

View File

@ -31,7 +31,6 @@
when: "vars[item]|int > 1"
with_items:
- "matrix_synapse_workers_pusher_workers_count"
- "matrix_synapse_workers_federation_sender_workers_count"
- "matrix_synapse_workers_stream_writer_typing_stream_workers_count"
- "matrix_synapse_workers_stream_writer_to_device_stream_workers_count"
- "matrix_synapse_workers_stream_writer_account_data_stream_workers_count"

View File

@ -352,9 +352,6 @@ worker_app: synapse.app.homeserver
# thx https://oznetnerd.com/2017/04/18/jinja2-selectattr-filter/
# reduce the main worker's offerings to core homeserver business
{% if matrix_synapse_workers_enabled_list | selectattr('type', 'equalto', 'federation_sender') | list | length > 0 %}
send_federation: false
{% endif %}
{% if matrix_synapse_workers_enabled_list | selectattr('type', 'equalto', 'media_repository') | list | length > 0 %}
enable_media_repo: false
{% endif %}
@ -2851,6 +2848,7 @@ opentracing:
# Uncomment if using a federation sender worker.
#
#send_federation: false
send_federation: {{ matrix_synapse_send_federation | to_json }}
# It is possible to run multiple federation sender workers, in which case the
# work is balanced across them.
@ -2862,6 +2860,7 @@ opentracing:
#
#federation_sender_instances:
# - federation_sender1
federation_sender_instances: {{ matrix_synapse_federation_sender_instances | to_json }}
# When using workers this should be a map from `worker_name` to the
# HTTP replication listener of the worker, if configured.