Added first bit about locations in nginx, and added link to PG-tuning.

This commit is contained in:
Hans van Zijst 2024-12-30 09:56:43 +01:00
parent 63d0b8d6f5
commit 84414e0310
Signed by: hans
GPG key ID: 43DBCC37BFDEFD72
2 changed files with 32 additions and 1 deletions

View file

@ -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;
}

View file

@ -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).