Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
To Be Message-Driven 
Todd L. Montgomery 
@toddlmontgomery
Life is Message Driven
CPUs are Message Driven
Browsers are “Message” Driven
Why is this?
The most scalable, resilient, & 
fast systems seem to follow 
some common principles…
Facilitating other traits
Why Message Driven?
It’s not what Message 
Passing provides…
It’s what Message Passing makes 
harder or even impossible
Boundaries
Boundaries are Good!
Asynchronous 
Boundary 
Forced Decoupling 
Binary 
Boundary 
& Separation of Concerns 
Ordering 
Errors as 
Messages
Asynchronous, Binary 
Boundaries
Asynchronous
Request 
Response 
@toddlmontgomery 
Processing 
Could do stuff 
while waiting!
Waiting at the mailbox…
Even traditional blocking 
operations can be decoupled
@toddlmontgomery 
Async 
Requests 
& 
Responses 
Request 
Request 
Request 
Response 
Response 
Response
Request 0 
Request 1 
Request 2 
Response 0 
Response 1 
Response 2 
@toddlmontgomery 
Async 
Requests 
& 
Responses 
Corr...
Request 0 
Request 1 
Request 2 
Response 0 
Response 1 
Response 2 
Ordering 
Correlation! 
@toddlmontgomery
Request 0 
Response 0 
Request 1 
Response 1 
Request 2 
Response 2 
Correlation! 
@toddlmontgomery 
(Valid) 
Re-Ordering
Request 0 
Response 1 
Invalid, Drop We only know of 0. 
Handling the Unexpected 
@toddlmontgomery 
1 is unknown!
Binary
.addPayment(5) 
Without a binary boundary, 
too easy to couple & conflate
struct PaymentMessage 
{ 
std::int32_t accountId; 
std::int32_t amount; 
}; 
When all you have is binary, 
harder to coupl...
Ordering
Packets, nay Messages!, 
Can Be… 
Duplicated 
Re-Ordered 
Lost
TCP connections can… 
be closed 
unexpectedly 
end in an 
unknown state 
be intercepted 
by idiots, er Proxies
Which means 
Data over TCP* might be… 
Duplicated 
Re-Ordered 
Lost 
* - When connections are re-established
Ordering is an Illusion!!
Compiler can re-order 
Runtime can re-order 
CPU can re-order
Which is why 
Lock-Free Programming 
shares some behaviors 
with Protocols…
Java 
x86 
C++11 
http://en.wikipedia.org/wiki/Memory_ordering
Source Ordering 
Message A and B from same 
source are ordered
Illusion of Ordering… bordering on “Delusion” 
Total Ordering 
Message A and B from any 2+ sources 
are ordered the same a...
Causal Ordering 
Message A and B from any source are 
ordered if B causally relates to A
Ordering can just fall out
Application Layer Framing 
0 X bytes 
0 1 2 3 4 5 6 7 8 
0 1 3 4 5 6 7 
2 8 
S: 
R: 
File to Transfer 
Recover 
Dead Recko...
Most of the time, Ordering 
simply isn’t enough
Messages Can Be… 
Duplicated 
Re-Ordered 
Lost
Transition Table? 
JavaScript prototypes? 
Java enums? 
Table with Lambdas!?
public void onAck(final Event ev) 
{ 
switch (currentState) 
{ 
… 
case State.FIN_WAIT_1: // an ACK while in FIN_WAIT_1 
c...
State Machines… 
worth your time
RST 
Simultaneous 
Open 
Closing & 
Dupes, etc.
State Machine Testing 
1. Does my “code” implement it correctly? 
2. Is my design safe, correct, etc.? 
VLSI Testing Techn...
Model Checking
2002 ACM System Software Award 
SPIN 
http://en.wikipedia.org/wiki/SPIN_model_checker
TLA+ 
http://research.microsoft.com/en-us/um/people/lamport/tla/tla.html
Idempotent Unit of Work 
ADU 
1. Little to no ordering requirement 
2. Little to no state requirement 
e.g. REST 
That sta...
Responsive 
No/Less waiting & No/Less contention…
Resilient 
No/Less waiting & No/Less state…
Elastic 
No contention, no shared state…
Because Amdahl 
will hunt you down
@toddlmontgomery 
Questions? 
• Reactive Manifesto http://www.reactivemanifesto.com 
• Kaazing http://www.kaazing.com 
• S...
Reactsf 2014-message-driven
Reactsf 2014-message-driven
Reactsf 2014-message-driven
Reactsf 2014-message-driven
Reactsf 2014-message-driven
Reactsf 2014-message-driven
Reactsf 2014-message-driven
Reactsf 2014-message-driven
Reactsf 2014-message-driven
Reactsf 2014-message-driven
Reactsf 2014-message-driven
Reactsf 2014-message-driven
Upcoming SlideShare
Loading in …5
×

Reactsf 2014-message-driven

1,276 views

Published on

To Be Message Driven from React SF 2014

Published in: Technology

Reactsf 2014-message-driven

  1. 1. To Be Message-Driven Todd L. Montgomery @toddlmontgomery
  2. 2. Life is Message Driven
  3. 3. CPUs are Message Driven
  4. 4. Browsers are “Message” Driven
  5. 5. Why is this?
  6. 6. The most scalable, resilient, & fast systems seem to follow some common principles…
  7. 7. Facilitating other traits
  8. 8. Why Message Driven?
  9. 9. It’s not what Message Passing provides…
  10. 10. It’s what Message Passing makes harder or even impossible
  11. 11. Boundaries
  12. 12. Boundaries are Good!
  13. 13. Asynchronous Boundary Forced Decoupling Binary Boundary & Separation of Concerns Ordering Errors as Messages
  14. 14. Asynchronous, Binary Boundaries
  15. 15. Asynchronous
  16. 16. Request Response @toddlmontgomery Processing Could do stuff while waiting!
  17. 17. Waiting at the mailbox…
  18. 18. Even traditional blocking operations can be decoupled
  19. 19. @toddlmontgomery Async Requests & Responses Request Request Request Response Response Response
  20. 20. Request 0 Request 1 Request 2 Response 0 Response 1 Response 2 @toddlmontgomery Async Requests & Responses Correlation!
  21. 21. Request 0 Request 1 Request 2 Response 0 Response 1 Response 2 Ordering Correlation! @toddlmontgomery
  22. 22. Request 0 Response 0 Request 1 Response 1 Request 2 Response 2 Correlation! @toddlmontgomery (Valid) Re-Ordering
  23. 23. Request 0 Response 1 Invalid, Drop We only know of 0. Handling the Unexpected @toddlmontgomery 1 is unknown!
  24. 24. Binary
  25. 25. .addPayment(5) Without a binary boundary, too easy to couple & conflate
  26. 26. struct PaymentMessage { std::int32_t accountId; std::int32_t amount; }; When all you have is binary, harder to couple and/or conflate
  27. 27. Ordering
  28. 28. Packets, nay Messages!, Can Be… Duplicated Re-Ordered Lost
  29. 29. TCP connections can… be closed unexpectedly end in an unknown state be intercepted by idiots, er Proxies
  30. 30. Which means Data over TCP* might be… Duplicated Re-Ordered Lost * - When connections are re-established
  31. 31. Ordering is an Illusion!!
  32. 32. Compiler can re-order Runtime can re-order CPU can re-order
  33. 33. Which is why Lock-Free Programming shares some behaviors with Protocols…
  34. 34. Java x86 C++11 http://en.wikipedia.org/wiki/Memory_ordering
  35. 35. Source Ordering Message A and B from same source are ordered
  36. 36. Illusion of Ordering… bordering on “Delusion” Total Ordering Message A and B from any 2+ sources are ordered the same at all destinations
  37. 37. Causal Ordering Message A and B from any source are ordered if B causally relates to A
  38. 38. Ordering can just fall out
  39. 39. Application Layer Framing 0 X bytes 0 1 2 3 4 5 6 7 8 0 1 3 4 5 6 7 2 8 S: R: File to Transfer Recover Dead Reckoning about Ordering! Clark and Tennenhouse, ACM SIGCOMM CCR, Volume 20, Issue 4, Sept. 1990
  40. 40. Most of the time, Ordering simply isn’t enough
  41. 41. Messages Can Be… Duplicated Re-Ordered Lost
  42. 42. Transition Table? JavaScript prototypes? Java enums? Table with Lambdas!?
  43. 43. public void onAck(final Event ev) { switch (currentState) { … case State.FIN_WAIT_1: // an ACK while in FIN_WAIT_1 currentState = State.FIN_WAIT_2; break; … } } Event Current State Next State State & Events be explicit, do not hide behind abstraction(s) Make them Observable!
  44. 44. State Machines… worth your time
  45. 45. RST Simultaneous Open Closing & Dupes, etc.
  46. 46. State Machine Testing 1. Does my “code” implement it correctly? 2. Is my design safe, correct, etc.? VLSI Testing Techniques e.g. ARC/Branch Testing
  47. 47. Model Checking
  48. 48. 2002 ACM System Software Award SPIN http://en.wikipedia.org/wiki/SPIN_model_checker
  49. 49. TLA+ http://research.microsoft.com/en-us/um/people/lamport/tla/tla.html
  50. 50. Idempotent Unit of Work ADU 1. Little to no ordering requirement 2. Little to no state requirement e.g. REST That stateless bit…
  51. 51. Responsive No/Less waiting & No/Less contention…
  52. 52. Resilient No/Less waiting & No/Less state…
  53. 53. Elastic No contention, no shared state…
  54. 54. Because Amdahl will hunt you down
  55. 55. @toddlmontgomery Questions? • Reactive Manifesto http://www.reactivemanifesto.com • Kaazing http://www.kaazing.com • SlideShare http://www.slideshare.com/toddleemontgomery • Twitter @toddlmontgomery Thank You!

×