diff --git a/CHANGELOG.md b/CHANGELOG.md index eb406b802..9e3bd14e5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,13 @@ +# 2018-09-27 + +## Synapse Cache Factor made configurable + +The playbook now makes the Synapse cache factor configurable, through the playbook's `matrix_synapse_cache_factor` variable (having a default value of `0.5`). + +Changing that value allows you to potentially decrease RAM usage or to increase performance by caching more stuff. +Some information on it is available here: https://github.com/matrix-org/synapse#help-synapse-eats-all-my-ram + + # 2018-09-26 ## Disabling Docker container logging diff --git a/roles/matrix-server/defaults/main.yml b/roles/matrix-server/defaults/main.yml index 9b24ae400..ab19be38e 100644 --- a/roles/matrix-server/defaults/main.yml +++ b/roles/matrix-server/defaults/main.yml @@ -74,6 +74,13 @@ matrix_synapse_password_config_pepper: "" # Controls the number of events that Matrix Synapse caches in memory. matrix_synapse_event_cache_size: "100K" +# Controls cache sizes for Matrix Synapse via the SYNAPSE_CACHE_FACTOR environment variable. +# Raise this to increase cache sizes or lower it to potentially lower memory use. +# To learn more, see: +# - https://github.com/matrix-org/synapse#help-synapse-eats-all-my-ram +# - https://github.com/matrix-org/synapse/issues/3939 +matrix_synapse_cache_factor: 0.5 + # A list of additional "volumes" to mount in the container. # This list gets populated dynamically based on Synapse extensions that have been enabled. # Contains definition objects like this: `{"src": "/outside", "dst": "/inside", "options": "rw|ro|slave|.."} diff --git a/roles/matrix-server/tasks/setup_synapse_main.yml b/roles/matrix-server/tasks/setup_synapse_main.yml index 9a5169d2c..ecc93b700 100644 --- a/roles/matrix-server/tasks/setup_synapse_main.yml +++ b/roles/matrix-server/tasks/setup_synapse_main.yml @@ -61,6 +61,13 @@ dest: "{{ matrix_synapse_config_dir_path }}/{{ hostname_matrix }}.log.config" mode: 0644 +- name: Ensure Synapse environment variables file created + template: + src: "{{ role_path }}/templates/env/env-synapse.j2" + dest: "{{ matrix_environment_variables_data_path }}/synapse" + owner: root + mode: 0600 + - name: Ensure matrix-synapse.service installed template: src: "{{ role_path }}/templates/systemd/matrix-synapse.service.j2" diff --git a/roles/matrix-server/templates/env/env-synapse.j2 b/roles/matrix-server/templates/env/env-synapse.j2 new file mode 100644 index 000000000..69f267009 --- /dev/null +++ b/roles/matrix-server/templates/env/env-synapse.j2 @@ -0,0 +1,2 @@ +SYNAPSE_CONFIG_PATH=/data/homeserver.yaml +SYNAPSE_CACHE_FACTOR={{ matrix_synapse_cache_factor }} diff --git a/roles/matrix-server/templates/systemd/matrix-synapse.service.j2 b/roles/matrix-server/templates/systemd/matrix-synapse.service.j2 index 8b014a6db..829f73727 100644 --- a/roles/matrix-server/templates/systemd/matrix-synapse.service.j2 +++ b/roles/matrix-server/templates/systemd/matrix-synapse.service.j2 @@ -27,6 +27,7 @@ ExecStartPre=/bin/sleep 5 {% endif %} ExecStart=/usr/bin/docker run --rm --name matrix-synapse \ --log-driver=none \ + --env-file={{ matrix_environment_variables_data_path }}/synapse \ --network={{ matrix_docker_network }} \ -p 8448:8448 \ {% if not matrix_nginx_proxy_enabled %} @@ -38,7 +39,6 @@ ExecStart=/usr/bin/docker run --rm --name matrix-synapse \ {% for volume in matrix_synapse_container_additional_volumes %} -v {{ volume.src }}:{{ volume.dst }}:{{ volume.options }} \ {% endfor %} - -e SYNAPSE_CONFIG_PATH=/data/homeserver.yaml \ {{ matrix_docker_image_synapse }} ExecStop=-/usr/bin/docker kill matrix-synapse ExecStop=-/usr/bin/docker rm matrix-synapse