I've finally found some time to test WCF performance vs .NET Remoting in sending 'plain' objects. Here you can find my previous results of sending DataSet through the wires.
The test project described in this article can be downloaded here.
What I tested:
- Plain [Serializable] object
- Marked with or without [DataContract] attribute
- I tested client latency (not server throughput)
What are my results:
I hoped it will be different but it occurs that the .NET Remoting is better in sending plain objects than WCF. It isn't much better but it still is a bit.
What I tested is an operation that returns a Human object (with Name, FirstName and few other members) and I executed the method 100 times for each service type. Each time I created a new service proxy (WCF or Remoting), invoked the method and closed the proxy (in WCF only). My results (in seconds) are:
- WCF: 1.2 s
- Remoting: 0.71 s - this one is better
I tested the Human class with both [Serializable] attribute and without [DataMemeber] and with the [DataMember] set. Both of my results are equal - so it doesn't matter (from client latency point of view) whether you place the DataMember or Serializable attribute as WCF respects both.
Why those results favour the .NET Remoting:
- I believe it is caused by the fact that WCF 'requires' closing service proxy and I measure it in my tests - so when .NET Remoting sends only one request to the server WCF sends two (first with the invocation and second with the information to close the service) - it could be probably improved with Single Call service.
- WCF sends data in XML format internally and .NET Remoting uses binary format. Whatever people say I believe it is not possible to outperform binary format with any text based (e.g. xml) format which is redundant in nature - maybe I will be surprised some day.
I do not try to show that the .NET Remoting is better than WCF. I only try to figure out real life situation in which I would probably use WCF. I try to answer whether it is faster or not as I already know IT IS BETTER than Remoting. Really. I use it in my projects and I am thrilled. Why do I write this? To stop receiving emails from people that try to tell me how can I change my tests to show that the WCF is better. I am pretty sure that every test can be prepared in such a way that it shows what it is required to show. I do not want to do that.