dotnet / AspNetCore.Docs

Documentation for ASP.NET Core
https://docs.microsoft.com/aspnet/core
Creative Commons Attribution 4.0 International
12.64k stars 25.29k forks source link

Scalability: using a pool of servers to receive, process and send message #12679

Open gopala000 opened 5 years ago

gopala000 commented 5 years ago

I have a scenario where background service need to receive message, process the request and send back message to the requested client. I'd like to use a pool of servers for scalability. What is the architectural guidance to make sure that a message is processed only by one server in the pool?


Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

bradygaster commented 5 years ago

@gopala000 are you also thinking of using the Azure SignalR Service? @chenkennt wrote a great blog post describing some new features like stickyness. see the post here: https://devblogs.microsoft.com/aspnet/whats-new-in-azure-signalr-1-1-0-preview-1/

If that's not what you're after let me know and i'll get more info for you on non-ASRS stickness.

gopala000 commented 5 years ago

@bradygaster Thanks for your response. I'm not planning to use Azure SignalR Service. My scenario is

  1. Request originate from browser client
  2. Proxy translates it to a new signalR request to background service
  3. Background service process the request and sends the response to client

The example in the content under heading "React to signalR events with background service" has a "break" statement in while loop. That caused background service to end on single iteration. This seems wrong. My questions are

a. What should be the delay in the continuous while() loop? b. In step #2 of my scenario, I used group as receiver of message with server name and processId in string to avoid more than one server process the request in a server farm. This works fine. Just wanted a validation if there is a better approach.

udlose commented 4 years ago

I'd also like to know the guidance. This has been open for 10 months now. Can we have some guidance please? Would using Redis as a backplane solve this problem?

bradygaster commented 4 years ago

adding @davidfowl here as he and I are discussing a series of updates on SignalR architecture. I think this would be near the top of the list of things we'd want to touch on.

davidfowl commented 4 years ago

I don't understand the request so let me try to get some clarity (sorry for seeing this so late). Is this the architecture we're talking about (each box represents another machine):

[Client] <------> [ Server(s) ] <------> [ Workers with background service(s) ]

OR

[Client] <------> [ Server(s) with background service(s) ]

In short, do you want process messages in process or out of process?

I'll just state some relevant things:

What is the architectural guidance to make sure that a message is processed only by one server in the pool?

I'm not sure I understand the question here. Which message, are you trying to send messages to clients or servers? What are you building?