From 84414e031040120725c5730761366fcceac14df8 Mon Sep 17 00:00:00 2001 From: Hans van Zijst Date: Mon, 30 Dec 2024 09:56:43 +0100 Subject: [PATCH] Added first bit about locations in nginx, and added link to PG-tuning. --- matrix/nginx/workers/README.md | 31 ++++++++++++++++++++++++++++++- matrix/postgresql/README.md | 2 ++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/matrix/nginx/workers/README.md b/matrix/nginx/workers/README.md index 214130b..c1f487e 100644 --- a/matrix/nginx/workers/README.md +++ b/matrix/nginx/workers/README.md @@ -9,7 +9,7 @@ Changing nginx's configuration from a reverse proxy for a normal, monolithic Synapse to one for a Synapse that uses workers, quite a lot has to be changed. As mentioned in [Synapse with workers](../../synapse/workers.md#synapse), we're -changing from network sockets to UNIX sockets. +changing the "backend" from network sockets to UNIX sockets. Because we're going to have to forward a lot of specific requests to all kinds of workers, we'll split the configuration into a few bits: @@ -98,3 +98,32 @@ upstream normal_sync { The `hash` bit is to make sure requests are always forwarded to the same worker. + + +# Locations + +Now that we have defined the workers and/or worker pools, we have to forward +the right traffic to the right workers. The Synapse documentation about +[available worker +types](https://element-hq.github.io/synapse/latest/workers.html#available-worker-applications) +lists which endpoints a specific worker type can handle. + +The docs say that the `generic_worker` can handle these requests for synchronisation +requests: + +``` +# Sync requests +^/_matrix/client/(r0|v3)/sync$ +^/_matrix/client/(api/v1|r0|v3)/events$ +^/_matrix/client/(api/v1|r0|v3)/initialSync$ +^/_matrix/client/(api/v1|r0|v3)/rooms/[^/]+/initialSync$ +``` + +Now, if we had only one worker type for synchronisations, named `sync`, not +splitting those requests up in normal and initial, we would direct all +sync-requests to that worker with this `location`: + +``` +location ~ ^(/_matrix/client/(r0|v3)/sync|/_matrix/client/(api/v1|r0|v3)/events|/_matrix/client/(api/v1|r0|v3)/initialSync|/_matrix/client/(api/v1|r0|v3)/rooms/[^/]+/initialSync)$ { + proxy_pass http://sync; +} diff --git a/matrix/postgresql/README.md b/matrix/postgresql/README.md index ae86a94..d47203c 100644 --- a/matrix/postgresql/README.md +++ b/matrix/postgresql/README.md @@ -80,3 +80,5 @@ superuser, the first line. This is for later, check [Tuning your PostgreSQL Server](https://wiki.postgresql.org/wiki/Tuning_Your_PostgreSQL_Server) on the PostgreSQL wiki. +For tuning in the scenario with [Synapse workers](../synapse/workers), see [this +useful site](https://tcpipuk.github.io/postgres/tuning/index.html).