none
WCF vs. Raw .NET Sockets

    Question

  • Hello,

    I was wondering if anyone could point me towards any performance comparison or study on using WCF versus raw .NET sockets. 

    Specifically, the setup I'm interested in is an asynchronous Publish/Subscribe model, where the publisher passes small amounts of numerical and string data at a frequency of ~20 updates max per second per client, to about 10 clients over a local network.  Also, any thoughts on the best WCF setup for this (HTTP vs MSMQ, binary vs MTOM, etc.) would be great as well.

    Thanks.

    Cheers,
    Cory
    Wednesday, November 26, 2008 7:51 PM

Answers

  • Hello,

    It's not even about performance and speed of development.

    The purpose of WCF is to protect developers from all the transport protocol plumbing... WCF has huge number of features, that's why it is slower, than raw .NET sockets (basically it is buit on these sockets).

    Looking at your requirements I can say that you are on safe side: WCF easily will satisfy your needs.
    Regarding bindings:
    If you do not need reliability, you can use UDP binding + binary serialization (I know, WCF does not support it out-of-the-box, at least in this version, but you can use UDP binding from MS samples),
    otherwise I would recommend TCP + binary serialization.

    HTTP you do not need, bacause your application reside in local network...
    MTOM is not intended for small messages...
    MSMQ does not really fit here...

    Vitaliy Liptchinsky http://dotnetframeworkplanet.blogspot.com/
    Tuesday, December 02, 2008 8:44 PM

All replies

  • Hi, Cory:

    Raw .NET sockets will be much faster. Usually, they are two or more times faster than WCF. See the site http://www.udaparts.com/document/articles/fastsocketpro.htm

    Raw socket approach is more complex in general, and costs your more time to develop your product. You have to balance performance and fast development. However, you may use a third-party library like SocketPro to simplify your project and speed up development.


    HTTP server push is really great and easy! Don't you give it a try?
    • Edited by msdn_msg Monday, May 11, 2009 12:43 AM
    • Proposed as answer by msdn_msg Monday, May 11, 2009 12:44 AM
    Tuesday, December 02, 2008 3:31 PM
  • Hello,

    It's not even about performance and speed of development.

    The purpose of WCF is to protect developers from all the transport protocol plumbing... WCF has huge number of features, that's why it is slower, than raw .NET sockets (basically it is buit on these sockets).

    Looking at your requirements I can say that you are on safe side: WCF easily will satisfy your needs.
    Regarding bindings:
    If you do not need reliability, you can use UDP binding + binary serialization (I know, WCF does not support it out-of-the-box, at least in this version, but you can use UDP binding from MS samples),
    otherwise I would recommend TCP + binary serialization.

    HTTP you do not need, bacause your application reside in local network...
    MTOM is not intended for small messages...
    MSMQ does not really fit here...

    Vitaliy Liptchinsky http://dotnetframeworkplanet.blogspot.com/
    Tuesday, December 02, 2008 8:44 PM