I had implemented those kind of concurrent rate limiter as a RPC service (just an exerckse for self) around 2020. (the idea was to create a request bottleneck middleware to control the number of simultaneous uploads to a server)
I'm far from being experienced in this so the naive way I did to deal with contention and starvation was to implement a kind of 2 staged lottery ticket system.
First get a ticket with an expiry that allows you to try and transform it into a winning ticket before it timeouts.
Once someone gets a winning ticket, they can upload.
Once they are done, they should return the winning ticket to free their spot.
I had implemented those kind of concurrent rate limiter as a RPC service (just an exerckse for self) around 2020. (the idea was to create a request bottleneck middleware to control the number of simultaneous uploads to a server)
I'm far from being experienced in this so the naive way I did to deal with contention and starvation was to implement a kind of 2 staged lottery ticket system.
First get a ticket with an expiry that allows you to try and transform it into a winning ticket before it timeouts. Once someone gets a winning ticket, they can upload. Once they are done, they should return the winning ticket to free their spot.
That's essentially a kind of distributed mutex.