我使用 1 个工作进程 IIS 广播和接收所有消息。将工作进程提高到 2,我只收到其他所有消息(丢失 50%)。是设计、配置还是错误?
1 回答
This is by design. The two worker processes don't share state and clients will be distributed between them on a round-robin basis, which means 50% will connect to process A and 50% to process B. As the underlying SignalR message bus is in-memory by default, process A doesn't see messages from process B.
What you're configuring is called a "web garden" (not to be confused with "web farm") and is commonly used to make faulty applications more responsive (see this SO question). As SignalR is built from the ground up with scalability in mind, this configuration won't give you any benefit.
My recommendation is to keep the worker process limit at 1.
There is however a way to make it working with web gardens: you'd need to use an external message bus like Redis or Windows Azure Service Bus (details can be found in the docs) for sharing messages between the processes, which of course introduces additional network latency.