Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Add example on how to load balance /sync requests (#14297)
Browse files Browse the repository at this point in the history
Signed-off-by: lukas <lukas.walter@aceart.de>

Signed-off-by: lukas <lukas.walter@aceart.de>
  • Loading branch information
aceArt-GmbH authored Nov 7, 2022
1 parent e980982 commit 42f9d41
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
1 change: 1 addition & 0 deletions changelog.d/14297.doc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add example on how to load balance /sync requests. Contributed by [aceArt](https://aceart.de).
8 changes: 5 additions & 3 deletions docs/workers.md
Original file line number Diff line number Diff line change
Expand Up @@ -305,9 +305,11 @@ may wish to run multiple groups of workers handling different endpoints so that
load balancing can be done in different ways.

For `/sync` and `/initialSync` requests it will be more efficient if all
requests from a particular user are routed to a single instance. Extracting a
user ID from the access token or `Authorization` header is currently left as an
exercise for the reader. Admins may additionally wish to separate out `/sync`
requests from a particular user are routed to a single instance. This can
be done e.g. in nginx via IP `hash $http_x_forwarded_for;` or via
`hash $http_authorization consistent;` which contains the users access token.

Admins may additionally wish to separate out `/sync`
requests that have a `since` query parameter from those that don't (and
`/initialSync`), as requests that don't are known as "initial sync" that happens
when a user logs in on a new device and can be *very* resource intensive, so
Expand Down

2 comments on commit 42f9d41

@olmari
Copy link
Contributor

@olmari olmari commented on 42f9d41 Nov 9, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI, this is still "only" per session or per IP, not per user... While not half-bad, not the same. That being said, We at Hacklab Finland did very recently figured an surprisingly simple Nginx mapper that "extracts" username from synapse access token and uses that as hash key, but our actual problem is where should we put the example... It feels very out of place in this documentation where everything tries to be as program agnostic as possible, but then again doesn't make sense to paste half page worth of Nginx specific stuff into generic worker documentation...

@olmari
Copy link
Contributor

@olmari olmari commented on 42f9d41 Nov 9, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is the current brainstorming we were pondering, not yet very well generalized and probably way too verbose, but beef is also there, aka the "mapper".. tswfi@b3704b9

Please sign in to comment.