Item Bin Technique
Item Bin Technique
In applications such as inventory management, a useful technique is to design the database to split hotspots representing quantities of objects into ‘bins’, rather than having all similar items in one bin. This technique uses the message VORefPublic>>tryLock.
The action of #tryLock is to try once to set a lock (read-lock or write-lock depending on the transaction’s #exclusiveLocks attribute) and to return <true> if the lock is granted or already set, otherwise <false>. This allows an application be designed to work around some kinds of hotspot by a replication technique.
For example, in an order-processing application, the quantity-on-hand might be recorded in a number of notional bins for each item. An order-processing transaction, on requiring such an item, chooses a bin of that item at random and tries to obtain a lock on it by sending the message #tryLock, if this returns <false> it tries other bins at random until a free one is found, when the transaction may continue.
The less frequent re-stocking transaction requires access to all the bins to distribute incoming stock between them, to keep them approximately equal.
