Comments (4)
In the Disruptor, every IEventHandler
has a dedicated executor thread that synchronously and sequentially processes the events. It performs very well if you can split your application processing pipeline in a few well-defined steps. Of course, you can also group multiple steps into a single IEventHandler
.
The best way to use the Disruptor is to have more cores than event handlers to avoid context switches. In this situation, you will not gain much with async IO, especially if you need to wait for the operation to complete before processing the next event. I would advise to use synchronous IO here, because blocking your thread is not an issue and because async IO often have a small overhead (at least a few allocations, but often more than just allocations).
If you only have an async API, you can simply Wait
for the task to finish. Synchronously waiting on a task (sync over async) is often an anti-pattern, but in this case you are waiting in the event handler dedicated thread, not from a thread-pool thread, so you will not have deadlock issues.
I hope this helps.
from disruptor-net.
The Disruptor can be useful for IO bound use cases, particularly for networking, because you benefit from the good latency and you can use the batching to properly handle queuing. If latency is not an issue, for example for non-critical disk IO, you still benefit from the batching.
If you have a low-throughput, IO bound scenario with a one-step pipeline, then you probably do not need to use the Disruptor 🙂.
from disruptor-net.
I just thought that it would be possible to add a useful async handler support in the Disruptor. An API could be added to register multiple IAsyncEventHandler
together. They would be run in the same dedicated thread and awaiting in an handler would allow the previous handler to process the next entry. But I feel like it would be a very niche use-case.
from disruptor-net.
@ocoanet thanks for you reply, which inspired me a lot, And after think it twice, I found for my case, i.e. IO-bound scenario, the throughput is usually not very high, the bottleneck usually is not queuing system, but the IO itself. So I probably just use simple queues for my use cases.
And for Disruptor, I think your idea is really great. The only thing I am thinking is, just as my cases, is Disruptor needed for IO bound cases? It might depend on the business logic of the application.
from disruptor-net.
Related Issues (20)
- add Task and async support for 'OnEvent' and 'Publish' HOT 10
- First 2 elements of ringBuffer are null HOT 7
- Strong Naming the Disruptor Assembly? HOT 2
- EventPoller for ValueRingBuffer HOT 5
- EventHandlerGroup<T>.And(EventHandlerGroup<T> eventHandlerGroup) usage HOT 4
- Long-running EventHandler causes high CPU consumption HOT 5
- Error: Unknown command 'Build-Assembly'.
- DynamiclyAddHandler can't work HOT 1
- Task-based handlers HOT 4
- Remove cake usage
- Add a wiki page to explain event handler interfaces HOT 1
- Is it safe to use Disruptor with System.IO.Pipelines without extra allocations? HOT 11
- Read method without locals HOT 15
- Is there a way to ensure backpressure on producers and not overwrite? HOT 13
- Is it safe/possible to use ByRefLike value types as events for ValueDisruptor? HOT 2
- .NET 6 support HOT 12
- Buffer getting full HOT 3
- Batch rewind HOT 9
- IAsyncBatchEventHandler with CancellationToken HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from disruptor-net.