Support for semaphore
See original GitHub issueThis may be a bit out there for a “lightweight” library but have you thought of implementing a distributed counting semaphore?
In my scenario, I have a sql azure database with many customers. Customers can have a lot of data. The .net code is hosted in several azure web instances.
I regularly want to process every customer data. However, I don’t want to process all customers at the same time because it would overload the database. I also don’t want to process each customer serially (1 by 1) because it would take too long. Ideally I would use a distributed semaphore with a count of N to process N customers at a time…
It could be built on top of SqlDistributedLock
and I wonder if you’ve come across this scenario before?
Do you see that fitting within the vision of your library?
Issue Analytics
- State:
- Created 7 years ago
- Comments:10 (5 by maintainers)
Top GitHub Comments
@alastairtree the algorithm I ended up with is essentially this (implemented in SQL):
To clean up, you just drop the marker temp table along with the ticket lock you took. The full code is in https://github.com/madelson/DistributedLock/blob/master/DistributedLock/Sql/SqlSemaphore.cs#L347
There are some additional complexities there dealing with cancellation and lock reentrance.
Give it a try and let me know how it goes.
This is available as of version 1.4