Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SignalR lost messages if IIS configure with more than 1 worker process

Tags:

signalr

I broadcast and receive all messages with 1 worker process IIS. Bump the worker process to 2, I receive only every other messages (lost 50%). Is it by designed, configuration or bug?

like image 910
Naptime Avatar asked Oct 06 '12 06:10

Naptime


1 Answers

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.

like image 105
Alexander Köplinger Avatar answered Oct 19 '22 18:10

Alexander Köplinger