Taming the Concurrency Crocodile
Duncan Jones
What is the problem?
Get state
Act on state
t
>> projection
>> command
Solution 1: Transactions
Get state
Act on state
t
‘Solved’ technology
Doesn’t scale well
Solution 2: Locks on crocs
Get state
Act on state
t
Needs safety net to force-unlock in the event of an error
Relatively simple technology
Solution 3: Undo, redo, undo….
Get state
Act on state
t
?
UNDO
Very efficient if contention rates are low
Much more complicated code
How do I know if there has been any change?
As at…
Solution 3 (b): Re-run
Get state
Act on state
t
?
RETRY
Very efficient if contention rates are low
Risk of getting “stuck”
How do I know if there has been any change?
As at…
?
Solution 4: Look behind you…
Get state
Act on prior state
t
Very easily achieved in event sourced
systems
Requires understanding of the impact to
The business and not always applicable
Wrapping it up
IT DEPENDS….
LATENCY
GEOGRAPHIC�DISTRIBUTION
COST OF “INCORRECT” STATE
AVAILABLE�TECHNOLOGY
BUSINESS RULES ON�HISTORICAL STATE
Other possibilities
Do nothing
Actor model
Merge state
Slides source
github.com/MerrionComputing/Presentations
Duncan Jones
💬@Merrion