iluwatar / java-design-patterns

Design patterns implemented in Java
https://java-design-patterns.com
Other
88.27k stars 26.19k forks source link

Disruptor Pattern #112

Open npathai opened 8 years ago

npathai commented 8 years ago

Description: The Disruptor is a high-performance inter-thread messaging library. It provides a way to achieve high throughput and low latency in message processing systems. The main elements of the Disruptor pattern include:

  1. Ring Buffer: A pre-allocated circular buffer that holds the data to be processed. The ring buffer is the core of the Disruptor, allowing for efficient memory allocation and access.
  2. Event Processors: Components that consume events from the ring buffer. They can be set up in different configurations such as single, multiple, or parallel consumers.
  3. Sequencers: Components that control the order of events being processed. They ensure that events are processed in the correct sequence and manage dependencies between different event processors.
  4. Producers: Components that publish events to the ring buffer. Producers write data to the ring buffer, which is then consumed by the event processors.
  5. Wait Strategies: Strategies that determine how consumers wait for events to be available in the ring buffer. Different strategies can be used to balance between CPU usage and latency.

References:

  1. Disruptor Pattern Wikipedia
  2. LMAX Disruptor: High Performance Inter-thread Messaging Library
  3. Martin Fowler on LMAX Architecture

Acceptance Criteria:

  1. Implement a ring buffer with configurable size to hold the events.
  2. Develop event processors that consume events from the ring buffer, supporting different processing configurations.
  3. Ensure proper sequencing of events using a sequencer component.
  4. Implement producers that can publish events to the ring buffer efficiently.
  5. Include at least one wait strategy for managing how consumers wait for events.

Please refer to the project contribution guidelines before submitting your pull request.

iluwatar commented 8 years ago

Great find @npathai :+1:

npathai commented 8 years ago

@iluwatar Yup its an amazing pattern. I will keep adding newer ones. I like learning patterns and will contribute lot here. :)

iluwatar commented 7 years ago

Disruptor was recently mentioned in Spring blog here: https://spring.io/blog/2016/07/20/notes-on-reactive-programming-part-iii-a-simple-http-server-application

iluwatar commented 6 years ago

http://lmax-exchange.github.io/disruptor/

jomariabejo commented 7 months ago

Hello everyone! I'm new to Java Design Patterns and excited to contribute. I'd love some guidance on how I can be of assistance here. Specifically, are there plans to incorporate a new module focusing on the 'Disruptor' pattern? I'm eager to learn and contribute to its implementation if that's in line with the project's objectives.

iluwatar commented 7 months ago

Sure, check here first https://github.com/iluwatar/java-design-patterns/wiki/01.-How-to-contribute

Study the existing design patterns. The new one is expected to follow the same technical structure.

jomariabejo commented 7 months ago

Thank you for talking me to the requirements for contributions. Before proposing the Disruptor pattern implementation, I'll thoroughly research the existing design patterns to ensure they correspond with the technical structure.

stale[bot] commented 5 months ago

This issue has been automatically marked as stale because it has not had recent activity. The issue will be unassigned if no further activity occurs. Thank you for your contributions.

iluwatar commented 1 month ago

Updated task description