mirror of
https://github.com/spantaleev/matrix-docker-ansible-deploy.git
synced 2024-12-23 04:55:46 +00:00
Merge pull request #979 from aaronraimist/synapse-speed
Add some advice about making Synapse faster
This commit is contained in:
commit
a37a8c76d4
@ -12,6 +12,7 @@ Table of contents:
|
|||||||
|
|
||||||
- [Upgrading PostgreSQL](#upgrading-postgresql), for upgrading to new major versions of PostgreSQL. Such **manual upgrades are sometimes required**.
|
- [Upgrading PostgreSQL](#upgrading-postgresql), for upgrading to new major versions of PostgreSQL. Such **manual upgrades are sometimes required**.
|
||||||
|
|
||||||
|
- [Tuning PostgreSQL](#tuning-postgresql) to make it run faster
|
||||||
|
|
||||||
## Getting a database terminal
|
## Getting a database terminal
|
||||||
|
|
||||||
@ -90,3 +91,43 @@ If you have plenty of space in `/tmp` and would rather avoid gzipping, you can e
|
|||||||
Example: `--extra-vars="postgres_dump_name=matrix-postgres-dump.sql"`
|
Example: `--extra-vars="postgres_dump_name=matrix-postgres-dump.sql"`
|
||||||
|
|
||||||
**All databases, roles, etc. on the Postgres server are migrated**.
|
**All databases, roles, etc. on the Postgres server are migrated**.
|
||||||
|
|
||||||
|
|
||||||
|
## Tuning PostgreSQL
|
||||||
|
|
||||||
|
PostgreSQL can be tuned to make it run faster. This is done by passing extra arguments to Postgres with the `matrix_postgres_process_extra_arguments` variable. You should use a website like https://pgtune.leopard.in.ua/ or information from https://wiki.postgresql.org/wiki/Tuning_Your_PostgreSQL_Server to determine what Postgres settings you should change.
|
||||||
|
|
||||||
|
### Here are some examples:
|
||||||
|
|
||||||
|
These are not recommended values and they may not work well for you. This is just to give you an idea of some of the options that can be set. If you are an experienced PostgreSQL admin feel free to update this documentation with better examples.
|
||||||
|
|
||||||
|
Here is an example config for a small 2 core server with 4GB of RAM and SSD storage:
|
||||||
|
```
|
||||||
|
matrix_postgres_process_extra_arguments: [
|
||||||
|
"-c 'shared_buffers=128MB'",
|
||||||
|
"-c 'effective_cache_size=2304MB'",
|
||||||
|
"-c 'effective_io_concurrency=100'",
|
||||||
|
"-c 'random_page_cost=2.0'",
|
||||||
|
"-c 'min_wal_size=500MB'",
|
||||||
|
]
|
||||||
|
```
|
||||||
|
|
||||||
|
Here is an example config for a large 6 core server with 24GB of RAM:
|
||||||
|
```
|
||||||
|
matrix_postgres_process_extra_arguments: [
|
||||||
|
"-c max_connections=40",
|
||||||
|
"-c shared_buffers=1536MB",
|
||||||
|
"-c checkpoint_completion_target=0.7",
|
||||||
|
"-c wal_buffers=16MB",
|
||||||
|
"-c default_statistics_target=100",
|
||||||
|
"-c random_page_cost=1.1",
|
||||||
|
"-c effective_io_concurrency=100",
|
||||||
|
"-c work_mem=2621kB",
|
||||||
|
"-c min_wal_size=1GB",
|
||||||
|
"-c max_wal_size=4GB",
|
||||||
|
"-c max_worker_processes=6",
|
||||||
|
"-c max_parallel_workers_per_gather=3",
|
||||||
|
"-c max_parallel_workers=6",
|
||||||
|
"-c max_parallel_maintenance_workers=3",
|
||||||
|
]
|
||||||
|
```
|
||||||
|
@ -6,13 +6,11 @@ Table of contents:
|
|||||||
|
|
||||||
- [Purging old data with the Purge History API](#purging-old-data-with-the-purge-history-api), for when you wish to delete in-use (but old) data from the Synapse database
|
- [Purging old data with the Purge History API](#purging-old-data-with-the-purge-history-api), for when you wish to delete in-use (but old) data from the Synapse database
|
||||||
|
|
||||||
- [Synapse maintenance](#synapse-maintenance)
|
- [Compressing state with rust-synapse-compress-state](#compressing-state-with-rust-synapse-compress-state)
|
||||||
- [Purging old data with the Purge History API](#purging-old-data-with-the-purge-history-api)
|
|
||||||
- [Compressing state with rust-synapse-compress-state](#compressing-state-with-rust-synapse-compress-state)
|
|
||||||
- [Browse and manipulate the database](#browse-and-manipulate-the-database)
|
|
||||||
|
|
||||||
- [Browse and manipulate the database](#browse-and-manipulate-the-database), for when you really need to take matters into your own hands
|
- [Browse and manipulate the database](#browse-and-manipulate-the-database), for when you really need to take matters into your own hands
|
||||||
|
|
||||||
|
- [Make Synapse faster](#make-synapse-faster)
|
||||||
|
|
||||||
## Purging old data with the Purge History API
|
## Purging old data with the Purge History API
|
||||||
|
|
||||||
@ -73,3 +71,13 @@ docker run --rm --publish 1799:8080 --link matrix-postgres --net matrix adminer
|
|||||||
You should then be able to browse the adminer database administration GUI at http://localhost:1799/ after entering your DB credentials (found in the `host_vars` or on the server in `{{matrix_synapse_config_dir_path}}/homeserver.yaml` under `database.args`)
|
You should then be able to browse the adminer database administration GUI at http://localhost:1799/ after entering your DB credentials (found in the `host_vars` or on the server in `{{matrix_synapse_config_dir_path}}/homeserver.yaml` under `database.args`)
|
||||||
|
|
||||||
⚠️ Be **very careful** with this, there is **no undo** for impromptu DB operations.
|
⚠️ Be **very careful** with this, there is **no undo** for impromptu DB operations.
|
||||||
|
|
||||||
|
## Make Synapse faster
|
||||||
|
|
||||||
|
Synapse's presence feature which tracks which users are online and which are offline can use a lot of processing power. You can disable presence by adding `matrix_synapse_use_presence: false` to your `vars.yml` file.
|
||||||
|
|
||||||
|
Tuning Synapse's cache factor can help reduce RAM usage. [See the upstream documentation](https://github.com/matrix-org/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 your PostgreSQL database will also make Synapse run significantly faster. See [maintenance-postgres.md##tuning-postgresql](maintenance-postgres.md##tuning-postgresql).
|
||||||
|
|
||||||
|
See also [How do I optimize this setup for a low-power server?](faq.md#how-do-i-optimize-this-setup-for-a-low-power-server).
|
||||||
|
Loading…
Reference in New Issue
Block a user