Does anyone know of a fast bus for local messaging between applications on the same machine?

StackOverflow https://stackoverflow.com/questions/8310579

  •  25-10-2019
  •  | 
  •  

Question

I'm looking for a pub/sub mechanism that can be used by .NET applications running on the same machine (a mixture of different app domains and processes). I'd really rather avoid having to run a separate service or anything that requires too much configuration. Obviously I'd like to keep the memory and cpu load to a minimum too.

Specifically I want to broadcast high volumes of small messages to subscribers on the same host. So I want a bus (e.g. MSMQ or NServiceBus) - but I don't want the overhead of full network support (it only needs local named pipes) or the cost and complexity of an enterprise bus.

Was it helpful?

Solution

Named pipes is the fastest way to do local process interaction.

Reference:
NamedPipeServerStream
NamedPipeClientStream
Choosing a transport

Important reading:
Don't get in a deadlock

OTHER TIPS

If you just want to send a signal from one process to other that some portion of work is done, the most lightweight solution could be a mutex.

I would guess that configured properly, MSMQ + NServiceBus would be able to achieve your desired throughput on a single machine. There is an [Express] attribute that will cause your messages to not be written to disk. If performance is adequate, you are much better off using a high-level framework like this than rolling your own.

Mailslots
Memory Mapped files
Named Pipes
LPC

All on Windows

This isn't my definitive solution, but one solution that has come up is 0MQ which offers a reliable pub/sub mode and has relatively low requirements for configuration and infrastructure. The downside is that it is relatively low level (the .NET API is a wrapper around the native C code) - so I will need to implement all the serialisation and so on.

I'll post back when I've had time to experiment and come to a conclusion.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top