99
Interaction Protocols Martin Thompson - @mjpt777

Interaction Protocols · protocol noun \ ˈprō-tə-ˌkȯl \ Source:

  • Upload
    others

  • View
    3

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Interaction Protocols · protocol noun \ ˈprō-tə-ˌkȯl \ Source:

Interaction Protocols

Martin Thompson - @mjpt777

Page 2: Interaction Protocols · protocol noun \ ˈprō-tə-ˌkȯl \ Source:

Code

Page 3: Interaction Protocols · protocol noun \ ˈprō-tə-ˌkȯl \ Source:
Page 4: Interaction Protocols · protocol noun \ ˈprō-tə-ˌkȯl \ Source:

Are protocols the most significant human discovery?

Page 5: Interaction Protocols · protocol noun \ ˈprō-tə-ˌkȯl \ Source:

protocolnoun \ ˈprō-tə-ˌkȯl \

Source: http://www.merriam-webster.com/

Page 6: Interaction Protocols · protocol noun \ ˈprō-tə-ˌkȯl \ Source:

protocolnoun \ ˈprō-tə-ˌkȯl \

: a code prescribing strict adherence to correct etiquette and precedence

Source: http://www.merriam-webster.com/

Page 7: Interaction Protocols · protocol noun \ ˈprō-tə-ˌkȯl \ Source:

protocolnoun \ ˈprō-tə-ˌkȯl \

: a code prescribing strict adherence to correct etiquette and precedence

: a set of conventions governing the treatment and formatting of data in an electronic communications system

Source: http://www.merriam-webster.com/

Page 8: Interaction Protocols · protocol noun \ ˈprō-tə-ˌkȯl \ Source:

Evolutionary Biology

Page 9: Interaction Protocols · protocol noun \ ˈprō-tə-ˌkȯl \ Source:

Facial Expressions

Page 10: Interaction Protocols · protocol noun \ ˈprō-tə-ˌkȯl \ Source:

Etiquette & Manners

Page 11: Interaction Protocols · protocol noun \ ˈprō-tə-ˌkȯl \ Source:

Hygiene

Courtesy

Norms

Evolution of Communities

Disease

Society

Trust

<=>

<=>

<=>

Page 12: Interaction Protocols · protocol noun \ ˈprō-tə-ˌkȯl \ Source:

Rules of Engagement

“What is acceptable”“Good conditions to succeed”

“Jus ad bellum, Jus ad bello”

Page 13: Interaction Protocols · protocol noun \ ˈprō-tə-ˌkȯl \ Source:

Concurrent & Distributed

Systems

Page 14: Interaction Protocols · protocol noun \ ˈprō-tə-ˌkȯl \ Source:

How to Interact

Page 15: Interaction Protocols · protocol noun \ ˈprō-tə-ˌkȯl \ Source:

IETF(Internet Engineering Task Force)

Page 16: Interaction Protocols · protocol noun \ ˈprō-tə-ˌkȯl \ Source:
Page 17: Interaction Protocols · protocol noun \ ˈprō-tə-ˌkȯl \ Source:

418“I'm a teapot”

Page 18: Interaction Protocols · protocol noun \ ˈprō-tə-ˌkȯl \ Source:
Page 19: Interaction Protocols · protocol noun \ ˈprō-tə-ˌkȯl \ Source:
Page 20: Interaction Protocols · protocol noun \ ˈprō-tə-ˌkȯl \ Source:
Page 21: Interaction Protocols · protocol noun \ ˈprō-tə-ˌkȯl \ Source:
Page 22: Interaction Protocols · protocol noun \ ˈprō-tə-ˌkȯl \ Source:

How should we document our protocols?

Page 23: Interaction Protocols · protocol noun \ ˈprō-tə-ˌkȯl \ Source:

API vs Protocol

Page 24: Interaction Protocols · protocol noun \ ˈprō-tə-ˌkȯl \ Source:

Open, *[Read | Write], Close

Page 25: Interaction Protocols · protocol noun \ ˈprō-tə-ˌkȯl \ Source:

Open, *[Read | Write], Close

1. Open: ...2. Read: ...

3. Write: ...

4. Close: ...

Page 26: Interaction Protocols · protocol noun \ ˈprō-tə-ˌkȯl \ Source:

Think events and then consider:pre, post, and invariant

conditions

Page 27: Interaction Protocols · protocol noun \ ˈprō-tə-ˌkȯl \ Source:

“What can go wrong?”

Page 28: Interaction Protocols · protocol noun \ ˈprō-tə-ˌkȯl \ Source:

Multicast Example

Page 29: Interaction Protocols · protocol noun \ ˈprō-tə-ˌkȯl \ Source:

ACK / NAK Implosion

Page 30: Interaction Protocols · protocol noun \ ˈprō-tə-ˌkȯl \ Source:
Page 31: Interaction Protocols · protocol noun \ ˈprō-tə-ˌkȯl \ Source:
Page 32: Interaction Protocols · protocol noun \ ˈprō-tə-ˌkȯl \ Source:

Where should we focus?

Page 33: Interaction Protocols · protocol noun \ ˈprō-tə-ˌkȯl \ Source:

Many Aspects to Consider

• Layering

• Versioning

• Encoding

• Addressing

• Error Handling

• Flow Control

• Congestion Control

• Feedback

• Sequencing

• Batching

• Sync/Async

• Validation

• Trust

• Privacy

Page 34: Interaction Protocols · protocol noun \ ˈprō-tə-ˌkȯl \ Source:

Encoding

Don’t use text codecs!Please use binary codecs

Page 35: Interaction Protocols · protocol noun \ ˈprō-tə-ˌkȯl \ Source:

0 1 2 3

0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1

+-+-------------------------------------------------------------+

|R| Frame Length |

+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-------------------------------+

| Version |B|E| Flags | Type |

+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-------------------------------+

|R| Term Offset |

+-+-------------------------------------------------------------+

| Session ID |

+---------------------------------------------------------------+

| Stream ID |

+---------------------------------------------------------------+

| Term ID |

+---------------------------------------------------------------+

| Encoded Message ...

... |

+---------------------------------------------------------------+

Page 36: Interaction Protocols · protocol noun \ ˈprō-tə-ˌkȯl \ Source:

Versioning

Page 37: Interaction Protocols · protocol noun \ ˈprō-tə-ˌkȯl \ Source:

Versioning/Identity

• Protocols: What conversation?

Page 38: Interaction Protocols · protocol noun \ ˈprō-tə-ˌkȯl \ Source:

Versioning/Identity

• Protocols: What conversation?

• Messages: What encoding?

Page 39: Interaction Protocols · protocol noun \ ˈprō-tə-ˌkȯl \ Source:

Versioning/Identity

• Protocols: What conversation?

• Messages: What encoding?

• State: What instance?

Page 40: Interaction Protocols · protocol noun \ ˈprō-tə-ˌkȯl \ Source:

MPMC Queuehttp://www.1024cores.net/

Page 41: Interaction Protocols · protocol noun \ ˈprō-tə-ˌkȯl \ Source:
Page 42: Interaction Protocols · protocol noun \ ˈprō-tə-ˌkȯl \ Source:

Sync vs Async

Page 43: Interaction Protocols · protocol noun \ ˈprō-tə-ˌkȯl \ Source:

Synchronous

Page 44: Interaction Protocols · protocol noun \ ˈprō-tə-ˌkȯl \ Source:

Synchronous

Page 45: Interaction Protocols · protocol noun \ ˈprō-tə-ˌkȯl \ Source:

Synchronous

Page 46: Interaction Protocols · protocol noun \ ˈprō-tə-ˌkȯl \ Source:

Synchronous

Page 47: Interaction Protocols · protocol noun \ ˈprō-tə-ˌkȯl \ Source:

Synchronous

Page 48: Interaction Protocols · protocol noun \ ˈprō-tə-ˌkȯl \ Source:

Synchronous

Page 49: Interaction Protocols · protocol noun \ ˈprō-tə-ˌkȯl \ Source:

Synchronous

Page 50: Interaction Protocols · protocol noun \ ˈprō-tə-ˌkȯl \ Source:

Synchronous

Page 51: Interaction Protocols · protocol noun \ ˈprō-tə-ˌkȯl \ Source:

Synchronous

Page 52: Interaction Protocols · protocol noun \ ˈprō-tə-ˌkȯl \ Source:

Synchronous

Page 53: Interaction Protocols · protocol noun \ ˈprō-tə-ˌkȯl \ Source:

Synchronous

Page 54: Interaction Protocols · protocol noun \ ˈprō-tə-ˌkȯl \ Source:

Synchronous

Page 55: Interaction Protocols · protocol noun \ ˈprō-tə-ˌkȯl \ Source:

Synchronous

What’s Happening?

Page 56: Interaction Protocols · protocol noun \ ˈprō-tə-ˌkȯl \ Source:

Asynchronous

Page 57: Interaction Protocols · protocol noun \ ˈprō-tə-ˌkȯl \ Source:

Asynchronous

Page 58: Interaction Protocols · protocol noun \ ˈprō-tə-ˌkȯl \ Source:

Asynchronous

Page 59: Interaction Protocols · protocol noun \ ˈprō-tə-ˌkȯl \ Source:

Asynchronous

Page 60: Interaction Protocols · protocol noun \ ˈprō-tə-ˌkȯl \ Source:

Asynchronous

Page 61: Interaction Protocols · protocol noun \ ˈprō-tə-ˌkȯl \ Source:

Asynchronous

Page 62: Interaction Protocols · protocol noun \ ˈprō-tə-ˌkȯl \ Source:

Asynchronous

Page 63: Interaction Protocols · protocol noun \ ˈprō-tə-ˌkȯl \ Source:

Asynchronous

Page 64: Interaction Protocols · protocol noun \ ˈprō-tə-ˌkȯl \ Source:

Asynchronous

Page 65: Interaction Protocols · protocol noun \ ˈprō-tə-ˌkȯl \ Source:

Asynchronous

Page 66: Interaction Protocols · protocol noun \ ˈprō-tə-ˌkȯl \ Source:

Asynchronous

Page 67: Interaction Protocols · protocol noun \ ˈprō-tə-ˌkȯl \ Source:

Asynchronous

Page 68: Interaction Protocols · protocol noun \ ˈprō-tə-ˌkȯl \ Source:

Asynchronous

Page 69: Interaction Protocols · protocol noun \ ˈprō-tə-ˌkȯl \ Source:

Asynchronous

Page 70: Interaction Protocols · protocol noun \ ˈprō-tə-ˌkȯl \ Source:

Asynchronous

What’s Happening?

Page 71: Interaction Protocols · protocol noun \ ˈprō-tə-ˌkȯl \ Source:

But, but, synchronousis much easier...

Page 72: Interaction Protocols · protocol noun \ ˈprō-tə-ˌkȯl \ Source:

...it’s all about feedbackand managing state

Page 73: Interaction Protocols · protocol noun \ ˈprō-tə-ˌkȯl \ Source:

Events model the real world,i.e. it’s distributed

Page 74: Interaction Protocols · protocol noun \ ˈprō-tə-ˌkȯl \ Source:

When designing an API provide Async with an Sync wrapper

if you must

Page 75: Interaction Protocols · protocol noun \ ˈprō-tə-ˌkȯl \ Source:

RPC / HTTP / TCP

Page 76: Interaction Protocols · protocol noun \ ˈprō-tə-ˌkȯl \ Source:

TCP → TCP Fast Open → QUIC

HTTP/1.1 → SPDY → HTTP/2

TLS 1.2 → TLS 1.3

Page 77: Interaction Protocols · protocol noun \ ˈprō-tə-ˌkȯl \ Source:
Page 78: Interaction Protocols · protocol noun \ ˈprō-tə-ˌkȯl \ Source:

Batching

Page 79: Interaction Protocols · protocol noun \ ˈprō-tə-ˌkȯl \ Source:

Etiquette of a request

Page 80: Interaction Protocols · protocol noun \ ˈprō-tə-ˌkȯl \ Source:

100 GigE ?

Page 81: Interaction Protocols · protocol noun \ ˈprō-tə-ˌkȯl \ Source:

Syscalls

Page 82: Interaction Protocols · protocol noun \ ˈprō-tə-ˌkȯl \ Source:

sndmmsg, rcvmmsg()

Onload, VMADPDK, ef_vi, RDMA Verbs

Future of Syscalls

Page 83: Interaction Protocols · protocol noun \ ˈprō-tə-ˌkȯl \ Source:

Natural Batching &Mechanical Sympathy

Page 84: Interaction Protocols · protocol noun \ ˈprō-tə-ˌkȯl \ Source:

ORMs vs SQL

Page 85: Interaction Protocols · protocol noun \ ˈprō-tə-ˌkȯl \ Source:

Snake Oil Protocols

Page 86: Interaction Protocols · protocol noun \ ˈprō-tə-ˌkȯl \ Source:

2PC / XA

Page 87: Interaction Protocols · protocol noun \ ˈprō-tə-ˌkȯl \ Source:
Page 88: Interaction Protocols · protocol noun \ ˈprō-tə-ˌkȯl \ Source:

“Two-Phase Commit is not fault

tolerant because it uses a single coordinator whose failure can

cause the protocol to block”

Page 89: Interaction Protocols · protocol noun \ ˈprō-tə-ˌkȯl \ Source:

Protocols requiring arbitration

Page 90: Interaction Protocols · protocol noun \ ˈprō-tə-ˌkȯl \ Source:

Guaranteed Delivery™

Page 91: Interaction Protocols · protocol noun \ ˈprō-tə-ˌkȯl \ Source:

Applications should havefeedback & recovery protocols

Page 92: Interaction Protocols · protocol noun \ ˈprō-tə-ˌkȯl \ Source:

Protocol Layering

Depend on behaviour,

not implementation

Page 93: Interaction Protocols · protocol noun \ ˈprō-tə-ˌkȯl \ Source:

Wrapping up…

Page 94: Interaction Protocols · protocol noun \ ˈprō-tə-ˌkȯl \ Source:

Are protocols the most significant human discovery?

Page 95: Interaction Protocols · protocol noun \ ˈprō-tə-ˌkȯl \ Source:

Question, Hypothesis,

Prediction, Experiment,

Analysis

Page 96: Interaction Protocols · protocol noun \ ˈprō-tə-ˌkȯl \ Source:
Page 97: Interaction Protocols · protocol noun \ ˈprō-tə-ˌkȯl \ Source:

Why are protocols notstudied and practiced more?

Page 98: Interaction Protocols · protocol noun \ ˈprō-tə-ˌkȯl \ Source:

Your next project =>

1. Frameworks? ⊕ Protocols?

2. ...

Page 99: Interaction Protocols · protocol noun \ ˈprō-tə-ˌkȯl \ Source:

@mjpt777

https://github.com/real-logic/aeron

“A distributed system is one in which the failure of a computer you didn't even know existedcan render your own computer unusable.”

- Leslie Lamport

Questions?