aeron
play

Aeron High-Performance Open Source Message Transport Martin - PowerPoint PPT Presentation

Aeron High-Performance Open Source Message Transport Martin Thompson - @mjpt777 1. Why build another Product ? 2. What Features are really needed? 3. How does one Design for this? 4. What did we Learn on the way? 5. Whats the Roadmap ? 1.


  1. Aeron High-Performance Open Source Message Transport Martin Thompson - @mjpt777

  2. 1. Why build another Product ? 2. What Features are really needed? 3. How does one Design for this? 4. What did we Learn on the way? 5. What’s the Roadmap ?

  3. 1. Why build another product?

  4. Not Invented Here!

  5. There’s a story here...

  6. Clients Gateway Gateway Gateway Gateway Gateway Gateway Matching or Matching or Trading Trading Engine Engine

  7. But many others could benefit

  8. Feature Bloat & Complexity

  9. Not Fast Enough

  10. Low-Latency is key

  11. We are in a new world Multi-core, Multi-socket, Cloud...

  12. We are in a new world Multi-core, Multi-socket, Cloud... UDP, IPC, InfiniBand, RDMA, PCI-e

  13. Aeron is trying a new approach

  14. The Team Todd Montgomery Richard Warburton Martin Thompson

  15. 2. What features are really needed?

  16. Messaging Channel Publishers Subscribers Stream Channel

  17. A library, not a framework, on which other abstractions and applications can be built

  18. Composable Design

  19. OSI layer 4 Transport for message oriented streams

  20. OSI Layer 4 (Transport) Services 1. Connection Oriented Communication 2. Reliability 3. Flow Control 4. Congestion Avoidance/Control 5. Multiplexing

  21. Connection Oriented Communication

  22. Reliability

  23. Flow Control

  24. Congestion Avoidance/Control

  25. Multiplexing

  26. Multi-Everything World!

  27. Multi-Everything World Publishers Subscribers Channel Stream

  28. Endpoints that scale

  29. 3. How does one design for this?

  30. Design Principles 1. Garbage free in steady state running 2. Smart Batching in the message path 3. Wait-free algos in the message path 4. Non-blocking IO in the message path 5. No exceptional cases in message path 6. Apply the Single Writer Principle 7. Prefer unshared state 8. Avoid unnecessary data copies

  31. It’s all about 3 things

  32. It’s all about 3 things 1. System Architecture

  33. It’s all about 3 things 1. System Architecture 2. Data Structures

  34. It’s all about 3 things 1. System Architecture 2. Data Structures 3. Protocols of Interaction

  35. Architecture Publisher Subscriber Subscriber Publisher IPC Log Buffer

  36. Architecture Publisher Subscriber Receiver Sender Media Receiver Sender Subscriber Publisher IPC Log Buffer Media (UDP, InfiniBand, PCI-e 3.0)

  37. Architecture Publisher Subscriber Receiver Sender Media Admin Events Conductor Conductor Events Admin Receiver Sender Subscriber Publisher IPC Log Buffer Media (UDP, InfiniBand, PCI-e 3.0) Function/Method Call Volatile Fields & Queues

  38. Architecture Client Media Driver Media Driver Client Publisher Subscriber Receiver Sender Media Admin Events Conductor Conductor Conductor Conductor Events Admin Receiver Sender Subscriber Publisher IPC Log Buffer Media (UDP, InfiniBand, PCI-e 3.0) Function/Method Call Volatile Fields & Queues IPC Ring/Broadcast Buffer

  39. Data Structures • Maps • IPC Ring Buffers • IPC Broadcast Buffers • ITC Queues • Dynamic Arrays • Log Buffers

  40. What does Aeron do? Creates a replicated persistent log of messages

  41. How would you design a log?

  42. File Tail

  43. File Header Message 1 Tail

  44. File Header Message 1 Header Message 2 Tail

  45. File Header Message 1 Header Message 2 Tail

  46. File Header Message 1 Header Message 2 Message 3 Tail

  47. File Header Message 1 Header Message 2 Header Message 3 Tail

  48. Persistent data structures can be safe to read without locks

  49. One big file that goes on forever?

  50. No!!! Page faults, page cache churn, VM pressure, ...

  51. Clean Dirty Active Header Header Message Message Header Header Message Message Header Header Message Message Tail Header Message Header Message

  52. How do we stay “wait - free”?

  53. File Header Message 1 Header Message 2 Header Message 3 Tail Message X Message Y

  54. File Header Message 1 Header Message 2 Header Message 3 Message X Tail Message Y

  55. File Header Message 1 Header Message 2 Header Message 3 Message X Message Y Tail

  56. File Header Message 1 Header Message 2 Header Message 3 Header Message X Message Y Tail

  57. File Header Message 1 Header Message 2 Header Message 3 Header Message X Message Y Padding Tail

  58. File File Tail Header Message 1 Header Message 2 Header Message 3 Header Message X Message Y Padding

  59. File File Header Header Message 1 Message X Header Tail Message 2 Header Message 3 Header Message Y Padding

  60. What’s in a header?

  61. Data Message Header 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 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Version |B|E| Flags | Type | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-------------------------------+ |R| Frame Length | +-+-------------------------------------------------------------+ |R| Term Offset | +-+-------------------------------------------------------------+ | Session ID | +---------------------------------------------------------------+ | Stream ID | +---------------------------------------------------------------+ | Term ID | +---------------------------------------------------------------+ | Encoded Message ... ... | +---------------------------------------------------------------+

  62. Unique identification of a byte within each stream across time ( streamId, sessionId, termId, termOffset )

  63. How do we replicate a log?

  64. We need a protocol of messages

  65. Sender Receiver

  66. Setup Sender Receiver

  67. Sender Receiver Status

  68. Data Data Sender Receiver Status

  69. Heartbeat Data Data Sender Receiver

  70. Heartbeat Data Data Sender Receiver NAK

  71. How are message streams reassembled?

  72. File Completed High Water Mark

  73. File Header Message 1 Completed High Water Mark

  74. File Header Message 1 Completed Header Message 3 High Water Mark

  75. File Header Message 1 Header Message 2 Header Message 3 Completed High Water Mark

  76. What if a gap is never filled?

  77. How do we know what is consumed?

  78. Publishers, Senders, Receivers, and Subscribers all keep position counters

  79. Counters are the key to flow control and monitoring

  80. Protocols can be more subtle than you think…

  81. What about “Self similar behaviour”?

  82. 4. What did we learn on the way?

  83. Humans suck at estimation!!!

  84. Building distributed systems is Hard !

  85. We have more defensive code than feature code

  86. This does not mean the code is riddled with exception handlers – Yuk!!!

  87. Building distributed systems is Rewarding !

  88. Monitoring and Debugging

  89. Loss, throughput, and buffer size are all strongly related!!!

  90. Know your OS network Pro Tip: parameters and how to tune them

  91. We can track application consumption – No need for the Disruptor

  92. Some parts of Java really suck!

  93. Some parts of Java really suck! Unsigned Types?

  94. Some parts of Java really suck! Unsigned Types? NIO (most of) - Locks

  95. Some parts of Java really suck! Unsigned Types? NIO (most of) - Locks Off-heap, PAUSE, Signals, etc.

  96. Some parts of Java really suck! Unsigned Types? NIO (most of) - Locks Off-heap, PAUSE, Signals, etc. String Encoding

  97. Some parts of Java really suck! Unsigned Types? NIO (most of) - Locks Off-heap, PAUSE, Signals, etc. String Encoding Managing External Resources

  98. Some parts of Java really suck! Unsigned Types? NIO (most of) - Locks Off-heap, PAUSE, Signals, etc. String Encoding Managing External Resources Selectors - GC

  99. Bytes!!! public void main(final String[] args) { byte a = 0b0000_0001; byte b = 0b0000_0010; byte flags = a | b; System.out.printf( "flags=%s\n", Integer.toBinaryString(flags)); }

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend