Here's the thing:Imagine there is a database containing just ids from 1 to 1000 and a flag is_used for each of those. There is a service which has only two methods: getId() which finds available id in DB and returns it aftersetting is_used to truerelease(int id) for setting is_used to false on id passedHow would you suggest to organize everything to be scalable and performant if there are two rules:Each id should be used only by one client at some point in timeIf all ids are used then clients called for getId should be queued and provided with id as soon as it becomes available.
Scalable and performant way to organize access to a shared resource?
design;performance;scalability