Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Exploring concurrent rate limiters, mutexes, semaphores (shalvah.me)
37 points by nalgeon on Sept 14, 2023 | hide | past | favorite | 1 comment


Nice post.

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.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: