matrix-org / synapse

Synapse: Matrix homeserver written in Python/Twisted.
https://matrix-org.github.io/synapse
Apache License 2.0
11.81k stars 2.13k forks source link

rc_joins rate limits dont function #16002

Open wuast94 opened 1 year ago

wuast94 commented 1 year ago

Description

For test purposes i added this to my homeserver yaml:


rc_joins:
  local:
    per_second: 1000
    burst_count: 2000
  remote:
    per_second: 1000
    burst_count: 2000

but i still can just join 10 rooms and then get the rate limit error

Steps to reproduce

change config and try to join a bunch of rooms at once

Homeserver

my own

Synapse Version

1.88.0

Installation Method

Docker (matrixdotorg/synapse)

Database

Postgres 15

Workers

Single process

Platform

Docker

Configuration

see discription

Relevant log output

MatrixError: [429] Too Many Requests

Anything else that would be useful to know?

No response

clokep commented 1 year ago

I believe those values are cached -- did you restart the server after changing them?

Edit: Nevermind, I see you updated the configuration not the per-user database rows.

wuast94 commented 1 year ago

amd yes restarted anyways 😊

ajohnstonTE commented 1 year ago

I am also seeing this issue. In our app when you join a space you also auto-join all the publicly known child rooms of that space, and we hit rate limit errors after 10 or so joins despite having the following configs:

rc_joins:
  local:
    per_second: 250
    burst_count: 250
  remote:
    per_second: 250
    burst_count: 250
ajohnstonTE commented 1 year ago

It turns out that this is also seemingly dependent on the message rate limiter. If you follow the handler from here:

https://github.com/matrix-org/synapse/blob/develop/synapse/handlers/room_member.py#L482-L487

And then follow the chain of where ratelimit is passed, you eventually end up here (skipping a few links in the chain):

https://github.com/matrix-org/synapse/blob/develop/synapse/replication/http/send_events.py#L154-L156

and then finally here:

https://github.com/matrix-org/synapse/blob/develop/synapse/handlers/message.py#L1729-L1731

Where it relies on the request_ratelimiter, which is populated by rc_message. Additionally setting the following configs:

rc_message:
  per_second: 250
  burst_count: 250

...seems to have resolved our join rate-limit issues. I know this also increases the rate limit for other actions, however. Feel free to double check though, I've only been following the call chains, I'm not otherwise familiar with the project or even Python besides the basics.