I have self-hosted WCF service in console with netNamedPipeBinding
binding. The service has just one empty method Send(DataTable bulk)
[ServiceContract]
public interface IWcfQueueService
{
[OperationContract]
void Send(DataTable bulk);
}
public class WcfQueueService : IWcfQueueService
{
public void Send(DataTable bulk)
{
// Here would be something like _bulks.Add(bulk);
// BUT, for now it is empty method and still it's slower than MSMQ
}
}
My client gets 200K inputs from DB and process it with our BoundedThreadPool(only creates, let say, 20 threads). Each input is processed with different thread. Each thread executes MyMethod
and in the end of MyMethod
the result is added to bulkManager
.
public void MyMethod(string input)
{
var res = ProcessInput(input);
bulkManager.Add(res);
}
When bulkManager
accumulates N items (=bulk) it pass the bulk to another thread that all it does is enqueue that bulk with one of two methods:
- If wcf enabled:
wcfQueueService.Send(bulk);
- else if MSMQ enabled:
new MessageQueue(@".\private$\q").Send(new Message {Body = bulk});
All two methods works, but MSMQ works much more faster. With MSMQ client manages to process about 80K bulks in 20seconds while with wcf only 20K-30K bulks. I don't understand why it happens. My WCF runs in different process like MSMQ does. In addition, my WCF doesn't stores anything, it has empty method. So why MSMQ wins WCF?
Updated
As leppie
suggested I tried .NetRemoting. NetRemoting indeed improved the speed. The client processed 60K. But,
- It's still slower than MSMQ
- As I read .Net Remoting is deprecated by WCF and WCF should be faster than .Net Remoting according to this, so why I get that my wcf is slower? Maybe my binding is wrong?
InstanceContextMode
on the service toSingle
andConcurrencyMode
toMultiple
? Then do another test. Also try to adjust the throttling settings (in the service behavior). – Selfknowledge