I received comments to my blog (WCF vs. Remoting (with DataSet)- performance comparison) with some adjustments I could make to improve performance of the WCF. I did some of them:
- Cache ChannelFactory. It is quite expensive to create it each time you need a proxy. My recommendation is: Hide it in your own Factory class or method so you can cache it. I am not sure yet why the ChannelFactory is not cached somehow by WCF but I believe there are some serious reasons.
- Disable security for NetTcpBinding. By default it is turned on and you can easily switch it off in app.config file.
I didn’t do all of the changes that was suggested as I do not agree with some of them. I do not want to create a benchmark that will show that WCF is faster to .NET Remoting as it probably is (mostly). I try to emulate the environment that is in my opinion the most common for the communication mechanisms: client – server .NET application using the fastest way to communicate over the wire (tcp) with DataSet as a Data Transfer Object (DTO).
Here are reults that I gained after the two changes:
What I measure in my tests is client latency so the lower value the better.
- Sending binary DataSet with no schema is still faster in .NET Remoting than WCF. The results are even more visible when sending 200 rows inside the DatSet.
- Sending DataSet with schema with xml serialization is comparable in WCF and .NET Remoting – it is a bit faster in WCF – it is probably because of fact that WCF actually sends all data in xml format.
Now my comment:
The WCF and .NET Remoting are really comparable in performance. The differences are so small (measuring client latency) that it does not matter which one is a bit faster. WCF though has much better server throughput than .NET Remoting. If I would start completely new project I would chose the WCF. Anyway the WCF does much more than Remoting and for all those features I love it. I’ve heard some time ago on Hanselminutes that users complain that Vista is slower to XP but it does much more than XP. Here we have similar situation and I know that most of benchmarks are better on WCF than Remoting.
I will extend my sample project with comparison of sending plain objects (DataContract) as it is the recommended way of doing such things in WCF. So forget DataSets folks – I will never forget you my lovely DataSet… blurp.