adopting actors: an epic tail of loss and learning

36
Adopting actors An epic tail of loss and learning

Upload: iain-hull

Post on 12-Apr-2017

95 views

Category:

Software


0 download

TRANSCRIPT

Page 1: Adopting Actors: An epic tail of loss and learning

Adopting actorsAn epic tail of loss and learning

Page 2: Adopting Actors: An epic tail of loss and learning

Iain [email protected]

@IainHullhttp://workday.github.io

Page 3: Adopting Actors: An epic tail of loss and learning

Workday

Page 4: Adopting Actors: An epic tail of loss and learning

Growth

2013 2014 2015 2016

Page 5: Adopting Actors: An epic tail of loss and learning

Cloud Master

Launch tasks Assign to agents

Page 6: Adopting Actors: An epic tail of loss and learning

Cloud Master

Launch tasks Assign to agents

Page 7: Adopting Actors: An epic tail of loss and learning
Page 8: Adopting Actors: An epic tail of loss and learning

Service Growthin millions of tasks per month

2015-09 2015-10 2015-11 2015-12 2016-01 2016-02 2016-03 2016-04 2016-050

5

10

15

20

PrintLargeSmallBatch

Page 9: Adopting Actors: An epic tail of loss and learning

Why Akka?

Page 10: Adopting Actors: An epic tail of loss and learning

Initial Observations

Page 11: Adopting Actors: An epic tail of loss and learning

Parent

Config ChildSnapshots

Changes

Page 12: Adopting Actors: An epic tail of loss and learning

Parent

Config ChildSnapshots

Changes

Message flow: Ensure messages follow a consistent path

Page 13: Adopting Actors: An epic tail of loss and learning

Parent

Config ChildSnapshots

Changes

Creation: Assume actor is recovering from failure (state machine)

Page 14: Adopting Actors: An epic tail of loss and learning

Anti-patterns

Page 15: Adopting Actors: An epic tail of loss and learning

GodClass

Page 16: Adopting Actors: An epic tail of loss and learning

Movie Star

Page 17: Adopting Actors: An epic tail of loss and learning

Pool

Agent

State

Agent Agent Agent Agent

Queue

Page 18: Adopting Actors: An epic tail of loss and learning

Movie Star

Too much state• Hard to reason about• Too many messages in flight• Hard to recover• Bad concurrencyBreakup Actor

Page 19: Adopting Actors: An epic tail of loss and learning

Split Brain

Page 20: Adopting Actors: An epic tail of loss and learning

Pool

Agent

State

Agent Agent Agent Agent

Page 21: Adopting Actors: An epic tail of loss and learning

Duplicate state

Single source of truth• Synchronizing state is hard• Failure causes–State out of sync–Causes more failureMerge Actors

Page 22: Adopting Actors: An epic tail of loss and learning

Split Brain

Page 23: Adopting Actors: An epic tail of loss and learning

Pool

Agent

State

Agent Agent Agent Agent

Task

Page 24: Adopting Actors: An epic tail of loss and learning

Passing responsibility

Seems simple at first• Do not always know who is in control• Both actors updating the same row• Creates race conditionsSplit Actors

Page 25: Adopting Actors: An epic tail of loss and learning

Can youlet it crash?

Page 26: Adopting Actors: An epic tail of loss and learning

Pool

Agent

State

Agent Agent Agent Agent

Can you let it crash?

Do not make it

more robust!!!

Page 27: Adopting Actors: An epic tail of loss and learning

Lessons

Page 28: Adopting Actors: An epic tail of loss and learning

Test for resilience

• Chaos Marmoset• Unit test recovery• Destructive system test

Page 29: Adopting Actors: An epic tail of loss and learning

Stateless Enterprise

idioms do not apply

Page 30: Adopting Actors: An epic tail of loss and learning

Sovereignty

One actor • One row • One shard• One table

Otherwise failure hard to handle

Page 31: Adopting Actors: An epic tail of loss and learning

AtomicityActors

Atomic receive methodState not sharedComms async messagesNot nestable

MutexAtomic scopeState is sharedComms via mutable stateNestable (ACID)

Page 32: Adopting Actors: An epic tail of loss and learning

Atomicity

Anything!!! Nothing

Actors Mutex

Page 33: Adopting Actors: An epic tail of loss and learning

Pool

Agent

State

Agent Agent Agent Agent

Atomicity

Page 34: Adopting Actors: An epic tail of loss and learning

Eventual consistency

Page 35: Adopting Actors: An epic tail of loss and learning

Lessons

- Atomicity and Consistency

- Actor modeling ≠ Object modeling

- Test for Resilience not robustness

- Refactor Early

Page 36: Adopting Actors: An epic tail of loss and learning

?