deltachat / deltachat-core-rust

Delta Chat Rust Core library, used by Android/iOS/desktop apps, bindings and bots 📧
https://delta.chat/en/contribute
Other
658 stars 84 forks source link

limit amount of updates a webxdc can send per timespan #3311

Closed r10s closed 2 years ago

r10s commented 2 years ago

the max. amount of updates messages an webxdc can send per timespan should be limited to some reasonable number.

if the webxdc updates wants to send quicker, several update messages could be combinded to a single one.

r10s commented 2 years ago

@link2xt you mentioned a crate or a simple algorithm for "only N actions over time T", allowing a burst or so; that could also be useful for other purposes, i know i re-asked you at some point, but i forgot again and do not know where i noted that ...

link2xt commented 2 years ago

The crate is https://lib.rs/crates/governor, but it may be an overkill for our purposes. The crate is designed for high load, and some simple things like checking whether you can send N messages now without modifying the counter are not supported: https://github.com/antifuchs/governor/issues/15

Key words for the algorithm are "token bucket", "leaky bucket", "generic cell rate algorithm". Easier to implement it ourselves as a struct with a few methods in a separate ratelimit.rs module or something like this than looking for a crate.

r10s commented 2 years ago

@link2xt i like to move forward on this issue these days~weeks - can you maybe draft a thing that is helpful for this issue as well as for other places (we talked about sth. like that several times iirc but i still have no good idea how sth. like that should look like :)