7 Commits

Author SHA1 Message Date
116e9fad86 Minor cleanups 2024-01-17 10:53:20 +02:00
396ab9f200 Fix incorrect indication in homeserver.yaml.j2 2024-01-17 10:53:12 +02:00
055cbf3208 Add to_json to various Synapse tuning related configs 2024-01-17 10:34:20 +02:00
2481c9cebc Fix YML Error
The playbook is not happy with the previous state of this patch so this commit hopefully fixes it
2024-01-17 10:32:25 +02:00
e5add0fd48 Updated Auto Tune figures
Autotuned figures have been bumped in consultation with other community members as to a reasonable level. Please note these defaults are more on the one of each workers side than they are on the monolith Side.
2024-01-17 10:32:25 +02:00
ecb3bdccde Add vars to Synapse main.yml to control cache related config
This commit adds various cache related vars to main.yml for Synapse.

Some are auto tune and some are just adding explicit ways to control upstream vars.
2024-01-17 10:32:24 +02:00
ec838dc4c3 Modify Synapse Cache Factor to use Auto Tune
Synapse has the ability to as it calls in its config auto tune caches.

This ability lets us set very high cache factors and then instead limit our resource use.

Defaults for this commit are 1/10th of what Element apparently runs for EMS stuff and matrix.org on Cache Factor and upstream documentation defaults for auto tune.
2024-01-17 10:31:12 +02:00
3 changed files with 52 additions and 36 deletions

View File

@ -74,7 +74,7 @@ Synapse's presence feature which tracks which users are online and which are off
If you have enough compute resources (CPU & RAM), you can make Synapse better use of them by [enabling load-balancing with workers](configuring-playbook-synapse.md#load-balancing-with-workers). If you have enough compute resources (CPU & RAM), you can make Synapse better use of them by [enabling load-balancing with workers](configuring-playbook-synapse.md#load-balancing-with-workers).
Tuning Synapse's cache factor can help reduce RAM usage. [See the upstream documentation](https://github.com/element-hq/synapse#help-synapse-is-slow-and-eats-all-my-ram-cpu) for more information on what value to set the cache factor to. Use the variable `matrix_synapse_caches_global_factor` to set the cache factor. Tuning Synapse's cache factor can help reduce RAM usage. Use the variable `matrix_synapse_caches_global_factor` to set the cache factor.
[Tuning your PostgreSQL database](maintenance-postgres.md#tuning-postgresql) could also improve Synapse performance. The playbook tunes the integrated Postgres database automatically, but based on your needs you may wish to adjust tuning variables manually. If you're using an [external Postgres database](configuring-playbook-external-postgres.md), you will aslo need to tune Postgres manually. [Tuning your PostgreSQL database](maintenance-postgres.md#tuning-postgresql) could also improve Synapse performance. The playbook tunes the integrated Postgres database automatically, but based on your needs you may wish to adjust tuning variables manually. If you're using an [external Postgres database](configuring-playbook-external-postgres.md), you will aslo need to tune Postgres manually.

View File

@ -546,8 +546,16 @@ matrix_synapse_event_cache_size: "100K"
# Controls cache sizes for Synapse. # Controls cache sizes for Synapse.
# Raise this to increase cache sizes or lower it to potentially lower memory use. # Raise this to increase cache sizes or lower it to potentially lower memory use.
# To learn more, see: https://github.com/matrix-org/synapse/issues/3939 # To learn more, see:
matrix_synapse_caches_global_factor: 0.5 # - https://matrix-org.github.io/synapse/latest/usage/configuration/config_documentation.html#caching
# - https://github.com/matrix-org/synapse/issues/3939
matrix_synapse_caches_global_factor: 10
matrix_synapse_caches_expire_caches: true
matrix_synapse_caches_cache_entry_ttl: "30m"
matrix_synapse_caches_sync_response_cache_duration: "2m"
matrix_synapse_caches_autotuning_max_cache_memory_usage: "2048M"
matrix_synapse_caches_autotuning_target_cache_memory_usage: "1024M"
matrix_synapse_caches_autotuning_min_cache_ttl: "5m"
# Controls whether Synapse will federate at all. # Controls whether Synapse will federate at all.
# Disable this to completely isolate your server from the rest of the Matrix network. # Disable this to completely isolate your server from the rest of the Matrix network.

View File

@ -760,49 +760,48 @@ federation_domain_whitelist: {{ matrix_synapse_federation_domain_whitelist|to_js
# The number of events to cache in memory. Not affected by # The number of events to cache in memory. Not affected by
# caches.global_factor. # caches.global_factor.
# #
event_cache_size: "{{ matrix_synapse_event_cache_size }}" event_cache_size: {{ matrix_synapse_event_cache_size | to_json }}
caches: caches:
# Controls the global cache factor, which is the default cache factor # Controls the global cache factor, which is the default cache factor
# for all caches if a specific factor for that cache is not otherwise # for all caches if a specific factor for that cache is not otherwise
# set. # set.
# #
# This can also be set by the "SYNAPSE_CACHE_FACTOR" environment # This can also be set by the "SYNAPSE_CACHE_FACTOR" environment
# variable. Setting by environment variable takes priority over # variable. Setting by environment variable takes priority over
# setting through the config file. # setting through the config file.
# #
# Defaults to 0.5, which will half the size of all caches. # Defaults to 0.5, which will half the size of all caches.
# #
global_factor: {{ matrix_synapse_caches_global_factor }} global_factor: {{ matrix_synapse_caches_global_factor | to_json }}
# A dictionary of cache name to cache factor for that individual
# A dictionary of cache name to cache factor for that individual # cache. Overrides the global cache factor for a given cache.
# cache. Overrides the global cache factor for a given cache. #
# # These can also be set through environment variables comprised
# These can also be set through environment variables comprised # of "SYNAPSE_CACHE_FACTOR_" + the name of the cache in capital
# of "SYNAPSE_CACHE_FACTOR_" + the name of the cache in capital # letters and underscores. Setting by environment variable
# letters and underscores. Setting by environment variable # takes priority over setting through the config file.
# takes priority over setting through the config file. # Ex. SYNAPSE_CACHE_FACTOR_GET_USERS_WHO_SHARE_ROOM_WITH_USER=2.0
# Ex. SYNAPSE_CACHE_FACTOR_GET_USERS_WHO_SHARE_ROOM_WITH_USER=2.0 #
# # Some caches have '*' and other characters that are not
# Some caches have '*' and other characters that are not # alphanumeric or underscores. These caches can be named with or
# alphanumeric or underscores. These caches can be named with or # without the special characters stripped. For example, to specify
# without the special characters stripped. For example, to specify # the cache factor for `*stateGroupCache*` via an environment
# the cache factor for `*stateGroupCache*` via an environment # variable would be `SYNAPSE_CACHE_FACTOR_STATEGROUPCACHE=2.0`.
# variable would be `SYNAPSE_CACHE_FACTOR_STATEGROUPCACHE=2.0`. #
# per_cache_factors:
per_cache_factors: #get_users_who_share_room_with_user: 2.0
#get_users_who_share_room_with_user: 2.0
# Controls whether cache entries are evicted after a specified time # Controls whether cache entries are evicted after a specified time
# period. Defaults to true. Uncomment to disable this feature. # period. Defaults to true. Uncomment to disable this feature.
# #
#expire_caches: false expire_caches: {{ matrix_synapse_caches_expire_caches | to_json }}
# If expire_caches is enabled, this flag controls how long an entry can # If expire_caches is enabled, this flag controls how long an entry can
# be in a cache without having been accessed before being evicted. # be in a cache without having been accessed before being evicted.
# Defaults to 30m. Uncomment to set a different time to live for cache entries. # Defaults to 30m. Uncomment to set a different time to live for cache entries.
# #
#cache_entry_ttl: 30m cache_entry_ttl: {{ matrix_synapse_caches_cache_entry_ttl | to_json }}
# Controls how long the results of a /sync request are cached for after # Controls how long the results of a /sync request are cached for after
# a successful response is returned. A higher duration can help clients with # a successful response is returned. A higher duration can help clients with
@ -811,7 +810,16 @@ caches:
# By default, this is zero, which means that sync responses are not cached # By default, this is zero, which means that sync responses are not cached
# at all. # at all.
# #
#sync_response_cache_duration: 2m sync_response_cache_duration: {{ matrix_synapse_caches_sync_response_cache_duration | to_json }}
#FIX ME add documentation notes about these settings or remove this note.
# Check upstream https://matrix-org.github.io/synapse/latest/usage/configuration/config_documentation.html#caching
# for information for now
#
cache_autotuning:
max_cache_memory_usage: {{ matrix_synapse_caches_autotuning_max_cache_memory_usage | to_json }}
target_cache_memory_usage: {{ matrix_synapse_caches_autotuning_target_cache_memory_usage | to_json }}
min_cache_ttl: {{ matrix_synapse_caches_autotuning_min_cache_ttl | to_json }}
## Database ## ## Database ##