locked
WCF performance RRS feed

  • Question

  • Hello,

    I tried to compare WCF and TIBCO.Randezvouz performance using simple Order Entry Service. I used netTcpBinding and all defaults. I beleive netTcpBinding should be fastest binding in WCF.

    Unfortunately, WCF was able to process 2,000,000 orders per second. But TIBCO.Randezvouz received 14,000,000 orders per second.

    Can somebody help me to improve WCF performance? Can I disable security or may be I have to switch to UDP binding? We really like to switch to WCF but it should be pretty fast middleware.

    Thank you.

    Here is source code:

    // WCF
    [
    DataContract]
    public class
    Order
    {
      [
    DataMemberpublic string
    Symbol;
      [DataMemberpublic int
    Size;
      [DataMemberpublic double Price;
    }

    [ServiceContractclass OrderService
    {
      [OperationContractpublic void Send(Order
    order)  {
          MessageCounter
    .MessageArrived(order); // calculate service speed
      }
    }

    static void Main(string[] args) {
       ServiceHost host = new ServiceHost
    (
             
    typeof(OrderService
    ),
              new Uri("net.tcp://localhost:9090/OrderService/"
    ));
        host.Open();
    }

    //
    // TIBCO.Rendezvous
    // ....
    public void
    Open() {
        Dispatcher dispatcher = new Dispatcher(Queue
    .Default);
        NetTransport transport = new NetTransport("", "", "tcp:localhost:7500"
    );
        Listener listener = new Listener(Queue.Default, transport, "TESTING.Performance",null
    );
        listener.MessageReceived += new MessageReceivedEventHandler
    (listener_MessageReceived);
    }

    void listener_MessageReceived(object listener, MessageReceivedEventArgs args)  {
       Order order = new Order
    ();
       order.Symbol = ((
    string)args.Message.GetField("Symbol").Value).TrimEnd('\0'
    );
       order.Size = ((int)args.Message.GetField("Size"
    ).Value);
       order.Price = ((
    double)args.Message.GetField("Price"
    ).Value);
       // ...
       MessageCounter.MessageArrived(order);
    }

    //
    // service config file.

    <service type="MyService.OrderService">
      <
    endpoint address="OrderService" binding="netTcpBinding" contract="MyService.IOrderService"
    />
    </
    service
    >

    Tuesday, May 16, 2006 7:23 PM

Answers

  • There are few things that you can do to boost the performance of WCF:

    1) The NetTcpBinding is secure by default, so you are paying the cost of transport security. Turning off transport security buys you performance but costs vulnerability.

    2) Your current implementation uses a request/response message exchange pattern even though the underlying method returns void. You should tag your service operation with [OperationContract( OneWay = true )] if you want fire-and-forget messaging.

    3) On the service side, consider using InstanceContextMode.Single and ConcurrencyMode.Multiple. Our default behavior uses per-call instancing, which means we pay a small cost to allocate an initiailize a new instance of the service implementation type on each call. ConcurrencyMode.Multiple will allow multiple calls into your service instance at once, which is a behavior similar to the Rendezvous implementation.

    There are also several throttles you can look at tweaking, both at the transport layer and the dispatcher layer. These are exposed on the NetTcpBinding and the ServiceBehavior attribute, respectively. We ship fairly conservative settings for these throttles out of the box; individaul applications will likely benefit from some measurement and adustment of these settings.

    HTH
    -steve

     

    Wednesday, May 17, 2006 7:22 PM

All replies

  • There are few things that you can do to boost the performance of WCF:

    1) The NetTcpBinding is secure by default, so you are paying the cost of transport security. Turning off transport security buys you performance but costs vulnerability.

    2) Your current implementation uses a request/response message exchange pattern even though the underlying method returns void. You should tag your service operation with [OperationContract( OneWay = true )] if you want fire-and-forget messaging.

    3) On the service side, consider using InstanceContextMode.Single and ConcurrencyMode.Multiple. Our default behavior uses per-call instancing, which means we pay a small cost to allocate an initiailize a new instance of the service implementation type on each call. ConcurrencyMode.Multiple will allow multiple calls into your service instance at once, which is a behavior similar to the Rendezvous implementation.

    There are also several throttles you can look at tweaking, both at the transport layer and the dispatcher layer. These are exposed on the NetTcpBinding and the ServiceBehavior attribute, respectively. We ship fairly conservative settings for these throttles out of the box; individaul applications will likely benefit from some measurement and adustment of these settings.

    HTH
    -steve

     

    Wednesday, May 17, 2006 7:22 PM
  • Hi dimetc,

     

    I was wondering if you ever made the switch to WCF and how your performance evaluation vs. different middleware applications went?

     

    Thanks,

     

    Tom

    Wednesday, April 18, 2007 9:43 PM
  • I am very interested in this performance study above. I downloaded somebody's sample simple app off the web that does performance testing similar to this post. Very simple netTcpBinding and just calling a simple method over and over for 10 sec. The object is just a person class with one member name. I am only getting 6000 calls every 10 seconds. How in the world is the starter of this thread getting 2,000,000 a second. I wish I could do that with WCF. Any suggestions?

    Thanks,
    Friday, July 25, 2008 7:05 PM
  •  


    Most likely, there is an error in the original poster's measurements.  With WCF NetTcp one is lucky to get hundreds of messages per second with the right optimizations.  If you batch the messages into one large piece then it can do higher throughput, but so can any other file transfer.  For fast performance in thousands or millions of messages per second (without batching) there is still good use for realtime middleware like OMG DDS or TIBCO.

    Thursday, August 28, 2008 1:08 PM
  • Hi Friend ,

         You have to try with following seetings

     

    <behaviors>
          <endpointBehaviors>
            <behavior name="ItemBehaviour">
              <dataContractSerializer maxItemsInObjectGraph="2147483647"/>
            </behavior>
          </endpointBehaviors>
        </behaviors>

    Tuesday, October 19, 2010 4:56 AM
  • I would be interested in what you finally got it up to, here is an article about WCF Performance, it provides some metrics of performance for production systems, but they are more business type systems that are concerned about relaibalility and security, but it is an interesting read none the less.

     

    WCF Service Performance

     

     

    Tuesday, December 7, 2010 10:22 AM
  • Hello,

    I am working on .NET with TIBCO as middle ware. Can sum one let me know if this combination is adapted by companies worldwide?  Is this better than BizTalk? Would it be fine enough if I dont know WCF?

    I tried to get answers for these questions on many sites but couldn't.

     

    Tuesday, December 28, 2010 6:55 AM
  • Hi Geeks, I have some questions related to Performance,

    i am using WCF4 as Service, via Router->NetTcp, awsome :)

    So in future i split down my services (NetTcp), but off course all communication for Http still will be via Router(WCF4) feature.
    Client  is (WPF), and now i am going to call it via Services, because in future it will totally become Internet based, So what are my intentions,

    Although i am trying to get one module and make one service, mean per module wise.

    When i split any Service(s)(NetTcp).

    How much service can take its OperationContracts.

    How much OperationContracts service should have for Best Performance.

    Or any other advice by you. :)

    I have main intention over here, Performance, Performance, Performance and Best Practices (Although i am doing :))

    But need your advice.

    Regads, -N

    Monday, March 21, 2011 5:59 AM