Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Few questions about Mediator.NET #22

Open
SuheylZ opened this issue Apr 19, 2019 · 1 comment
Open

Few questions about Mediator.NET #22

SuheylZ opened this issue Apr 19, 2019 · 1 comment

Comments

@SuheylZ
Copy link

SuheylZ commented Apr 19, 2019

Hi Again,

I'm using your mediator in two projects which are live and so far it has performed well. both the projects are web based. So kudos to you on a very clean and smooth implementation of CQRS.

I'm planning to use it in a much larger system but have a few questions which are not clear to me.

  1. What is the limit of handlers if any? In the system I'm estimating it to cross well over 800. In the projects that I have used it the number has reached to 270 max and so far no issues.

  2. Can we have a dedicated thread pool for the handlers? off course that requires a custom scheduler. I'm thinking of assigning priorities to the commands, queries and with dedicated threads based on priorities of the handlers?

  3. When delving into the code for SimpleInjector.Mediator I noticed that mediator is registered as scoped. As dotnet core apps are mostly long running apps. I'm not clear if it makes sense to register the mediator instance as scoped, isn't it better to have it as singleton?

thanks in advance

@SuheylZ SuheylZ changed the title Mediator is registered as Scoped Few questions about Mediator.NET Apr 19, 2019
@mayuanyang
Copy link
Owner

Hi!

Thanks for keeping in touch!

I am glad to hear that Mediator runs well so far for you.

Here are my feedback for your questions

  1. What is the limit of handlers if any? In the system I'm estimating it to cross well over 800. In the projects that I have used it the number has reached to 270 max and so far no issues.
    _There is no limit of handlers, and it uses HashSet hence performance should be fine.

  2. Can we have a dedicated thread pool for the handlers? off course that requires a custom scheduler. I'm thinking of assigning priorities to the commands, queries and with dedicated threads based on priorities of the handlers?
    _Very good question, I have not tried it myself, in theory you should be able to instanciate a mediator instance and do something like Task.Run(async () => await mediator.Send(aCommand/orAQuery)) which might leavage the threadpool to schedule the task.

  3. When delving into the code for SimpleInjector.Mediator I noticed that mediator is registered as scoped. As dotnet core apps are mostly long running apps. I'm not clear if it makes sense to register the mediator instance as scoped, isn't it better to have it as singleton?
    _Mediator itself is not stateless, it has context which might affect other message if it is shared. As instanciating a new instance of IMediator is cheap, having a scoped instace or transient instance is more safe and can reduce side effects.

I hope this helps and looking forward to hear from you soon

Regards
Eddy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants