Optimistic Concurrency Control does not perform well under high contention

Last Updated on Mar 08, 2021

Optimistic Concurrency Control is an old idea, and its advantages and disadvantages have been debated for a long time. A significant drawback with OCC is that it doesn't perform well under conditions of high contention.

When many transactions try to access the same objects, the chance of a transaction needing to abort increases. If the transaction is indeed aborted and retried, the effort spent on performing the earlier transaction is entirely wasted.

For example, contentions are very high in a stock trading application where multiple trades simultaneously access the same stock object. The number of transactions that are aborted and retried is high in such conditions. If the system is operating close to maximum capacity, the additional transaction load from retried transactions worsens performance.

For this reason, OCC is best used in systems that have spare capacity and do not have high contention on objects. A recruitment application where recruiters and applicants rarely compete for access is a good candidate for optimistic concurrency.

Applications can also reduce contention with commutative atomic operations. A good example is incrementing a counter: the order of increments does not matter, so concurrent increments can all be applied without conflicting. Architecting the data model to reduce concurrent object access helps as well.

© 2022 Ambitious Systems. All Rights Reserved.