livekit / livekit-cli

Command line interface to LiveKit
https://docs.livekit.io
Other
215 stars 65 forks source link

refine rate limiter to be more accurate #306

Closed lherman-cs closed 6 months ago

lherman-cs commented 6 months ago

The current implementation is not quite representing "NumPerSecond" as it allows the following sequence:

Burst -> sleep 1s -> Burst -> ...

During the "Burst" time, the load rate can exceed "NumPerSecond" as long as the join can be completed under the "NumPerSecond" interval.

rate.NewLimiter can be configured to allow burst as needed. We would need to restructure the code and allow a new parameter to define the burst.