This chapter covers
- Managing concurrent mutations with a lock-free optimistic concurrency control strategy
- Supporting high throughput of reads and writes
- Reconciliation between concurrent mutations
The changes required to let our system manage concurrency are only in the commit phase. They involve a reconciliation algorithm that is universal in the sense that it can be used in any system where system data is represented as an immutable hash map.
The implementation of the reconciliation algorithm is efficient as it leverages the fact that subsequent versions of the system state are created via structural sharing.
In the previous chapter, we illustrated the multi-version approach to state management where a mutation is split into two distinct phases: the calculation phase that deals only with computation and the commit phase that moves the state reference forward.
Usually, in a production system, mutations occur concurrently. Moving the state forward naively like we did in the previous chapter is not appropriate. In the present chapter, we are going to learn how to handle concurrent mutations.
In DOP, the fact that only the code of the commit phase is stateful allows us to leverage an Optimistic Concurrency Control strategy that doesn’t involve any locking mechanism. As a consequence, the throughput of reads and writes is high.