This repository has been archived by the owner on Oct 27, 2023. It is now read-only.
Perfectioning the Rate Limiter in Multi-Process environment #2
Labels
performance
Problem related to performance
Issue presented by maintainer
Currently the rate limiter of cassiopeia and django-cassiopeia has small problems dealing with rate limiting in multiprocess environments. The issues caused is mainly caused by:
x:x, 99:100
.x:x, 100:100
.x:x, 99:100
.x:x, 99:100
.x:x, 100:100
.x:x, 99:100
.Temporary fix (or rather state)
Currently when a 429 is returned, the next calls will stop automatically because the root level cass defined by django-cassiopeia puts a lock (this is still unclear, but visually this is happening). Enough to prevent a black list.
Definitive Fix is scheduled together with the next Django big release 3.1
Initial thoughts: I have in mind to actually replace this rate limiter entirely, since the actual version uses a python object that is not thread accessible. It can be replaced ... by another cache (sorry if cache is already overwhelming your head), a cache that can do atomic ++ and --, and set an error pass lower to your limit (e.g. rate limits stops at 98/100) due to latency (as small as 10ms). This might still fail if you have multiple servers that distances each other with high latency, and the only solution is to keep lower the error pass.
The text was updated successfully, but these errors were encountered: