title: Performance of a REST service proxy vs WCF SOAP proxy
body: <p>I've been getting performance results that I cannot explain, when comparing a client that consumes a REST service and a SOAP service. What I did is create a service proxy as follows:</p>
  
  <p>REST:</p>
  
  <pre><code>WebHttpBinding webBinding = new WebHttpBinding();
  webBinding.AllowCookies = true;
  webBinding.MaxReceivedMessageSize = int.MaxValue;
  
  CustomBinding custom = new CustomBinding(webBinding);
  
  WebMessageEncodingBindingElement webMEBE = custom.Elements.Find&lt;WebMessageEncodingBindingElement&gt;();
  
  webMEBE.ContentTypeMapper = new MyMapper();
  webMEBE.ReaderQuotas.MaxArrayLength = int.MaxValue;
  
  var factory = new WebChannelFactory&lt;ITest&gt;(custom, new Uri("http://localhost/Test"));
  var proxy = factory.CreateChannel();
  </code></pre>
  
  <p>SOAP:</p>
  
  <pre><code>endPointAddr = "net.tcp://" + textBox2.Text +
  ":8909/MyService";
  tcpBinding = new NetTcpBinding();
  tcpBinding.MaxReceivedMessageSize = int.MaxValue;
  tcpBinding.ReaderQuotas.MaxArrayLength = int.MaxValue;
  tcpBinding.TransactionFlow = false;
  tcpBinding.Security.Transport.ProtectionLevel =
      System.Net.Security.ProtectionLevel.EncryptAndSign;
  tcpBinding.Security.Transport.ClientCredentialType =
      TcpClientCredentialType.Windows;
  tcpBinding.Security.Mode = SecurityMode.None;
  
  endpointAddress =
      new EndpointAddress(endPointAddr);
  
  IService1 proxy =
      ChannelFactory&lt;IService1&gt;.CreateChannel(tcpBinding, endpointAddress);
  </code></pre>
  
  <p>Both <code>IService1</code> and <code>ITest</code> have one method that I use, <code>GetRequest()</code>, which returns an ~300Kb object. IService1.GetRequest() is an OperationContract, ITest.GetRequest() is a WebGet.</p>
  
  <p>Once I open the channels in both cases I ran a tight loop of proxy.GetRequest(), to figure out how many Requests / s each can handle. The results were that if the test was on a local machine SOAP outperformed REST at 5:1, and over a network SOAP still outperformed REST by about 50%.</p>
  
  <p>I do not understand why there is such a big difference.</p>