1 of 10

Taming the Concurrency Crocodile

Duncan Jones

2 of 10

What is the problem?

Get state

Act on state

t

>> projection

>> command

3 of 10

Solution 1: Transactions

Get state

Act on state

t

‘Solved’ technology

Doesn’t scale well

4 of 10

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

5 of 10

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…

6 of 10

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…

?

7 of 10

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

8 of 10

Wrapping it up

IT DEPENDS….

LATENCY

GEOGRAPHIC�DISTRIBUTION

COST OF “INCORRECT” STATE

AVAILABLE�TECHNOLOGY

BUSINESS RULES ON�HISTORICAL STATE

9 of 10

Other possibilities

Do nothing

Actor model

Merge state

10 of 10

Slides source

github.com/MerrionComputing/Presentations

Duncan Jones

💬@Merrion