Comparing Binding Performance and Scalability
Developers need to know about the performance and scalability characteristics of bindings. Performance and scalability are important when you are working with real-world applications where service-level agreements and user experience matters. Users will complain about an application that performs poorly. Applications that do not scale usually mean that business objectives are not being met.
We have provided a simple performance comparison of four bindings available in WCF. The operation under test is a simple operation that returns a 256-character string. Listing 4.23 shows the service being used to compare performance between each binding.
Listing 4.23 Performance Test Service public class PerformanceTestService : IPerformanceTestService
private static string String256;
static PerformanceTestService()
public string Get256Bytes()
return String256;
The service was exposed over four different bindings: netNamedPipe Binding, netTcpBinding, wsHttpBinding, and basicHttpBinding.A test client called the Get256Bytes operation 50,000 times sequentially to compare the differences between the bindings. We then measured the average elapsed time, operations per second, and CPU time. All tests were performed on a single workstation running both server and client. This was done so that we could compare the performance of all the bindings. Figure 4.3 shows the average response time for each binding. You can use the response-time measurement to help examine user experience.
- Average Response Time (ms) (Smaller Bars Are Better)
ws2007HttpBinding wsHttpBinding basicHttpBinding netTcpBinding netNamedPipeBinding
Figure 4.3 Average response time ws2007HttpBinding wsHttpBinding basicHttpBinding netTcpBinding netNamedPipeBinding
Figure 4.3 Average response time
Figure 4.4 shows the average number of operations per second for each binding. This measurement has an impact on the throughput. Only a single instance of the test client was used for these tests. Additional throughput could be achieved if multiple clients were used. Operations per second is one measurement we use to determine scalability.
Operations Per Second (Bigger Bars Are Better)
8000 7000 6000 5000 4000 3000
Figure 4.4 shows the average number of operations per second for each binding. This measurement has an impact on the throughput. Only a single instance of the test client was used for these tests. Additional throughput could be achieved if multiple clients were used. Operations per second is one measurement we use to determine scalability.
Operations Per Second (Bigger Bars Are Better)
2000
1000
ws2007HttpBinding wsHttpBinding basicHttpBinding netTcpBinding netNamedPipeBinding
Figure 4.4 Operations per second ws2007HttpBinding wsHttpBinding basicHttpBinding netTcpBinding netNamedPipeBinding
Figure 4.4 Operations per second
2000
1000
Scalability should also take into account hardware resources consumed for each operation. Figure 4.5 attempts to measure scalability by showing the cost of an operation in MCycles. MCycles is a measurement based on CPU processing power an operation uses. For the purposes of this test, we used a Dell 4700 with a 3.4GHz Pentium 4 processor, which equates to 3400 MCycles. Notice that the measurements for the ws2007HttpBinding, wsHttpBinding, and the basicHttpBinding bindings have significantly higher cost than the netTcpBinding or the netNamedPipeBinding bindings. This is because of the overhead needed for interoperability.
- Cost Per Operation (Mcycles) (Smaller Bars Are Better)
ws2007HttpBinding wsHttpBinding basicHttpBinding netTcpBinding netNamedPipeBinding
Figure 4.5 Cost per operation ws2007HttpBinding wsHttpBinding basicHttpBinding netTcpBinding netNamedPipeBinding
Figure 4.5 Cost per operation
The WCF team has released a whitepaper on the performance of WCF (available at http://msdn2.microsoft.com/en-us/library/bb310550.aspx). The paper goes into much more detail and considers security settings such as transport, message, and mixed mode, and compares previous technologies such as NET Remoting, Web Service Enhancements, ASP.NET Web Services, and Enterprise Services.
Post a comment