Geeks With Blogs
Marcin Celej blog

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:

wcfvsr_binary_noschema wcfvsr_xml_withschema

What I measure in my tests is client latency so the lower value the better.

Results:

  • 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.

What next:

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.

Posted on Wednesday, September 26, 2007 8:47 AM | Back to top


Comments on this post: WCF vs Remoting - adjustments to my results

# re: WCF vs Remoting - adjustments to my results
Requesting Gravatar...
Hi Marcin, there is a reason why WCF is slower than .NET Remoting when you use DataSet binary serialization: the fast DataSet binary serialization mechanism (implemented as ISerializable) is only used by .NET Remoting. When WCF is used, it uses the slow XML serialization path (with IXmlSerializable). See http://blogs.msdn.com/sowmy/archive/2006/02/22/536747.aspx. The reason is that WCF needs the nice XSD projection from IXmlSerializable. I will write a blog entry on this topic sometime later.
Left by Wenlong Dong on Oct 26, 2007 3:43 AM

# re: WCF vs Remoting - adjustments to my results
Requesting Gravatar...
Thanks for the comment. I know the reasons of the slower DataSet serialization with xml vs. binary as the DataSet serializiation was improved in .NET 2.0 for the exact reason (It was slow even with binary serialization in .NET 1.x as the DataSet was always serialized to some xml structures). I fully agree with the point. I' like to investigate weather the binary serialization could be plugged in the WCF serialization. Maybe it will improve performance.

Anyway the differences in the serialization are so small that I encourage everyone to use WCF anyway. It has so many features that you do not have in Remoting and the most important: with the WCF it's not so easy to violate the SOA principles of programming and with remoting it is very easy (I mean remote objects in Remoting).

Once again thanks for the comment and I look forward for the blog entry (I am subscribed to your blog and I like it).
Left by Marcin Celej on Oct 26, 2007 6:09 AM

# re: WCF vs Remoting - adjustments to my results
Requesting Gravatar...
Hi Marcin,

I have found some similar results in WCF performance tests, one of them that XP was slightly faster (latency) than Vista. I'm interested in your explanation "that Vista does more" :). Can you provide some more information on that? Some references would be highly appreciated!

Thanks!

Bram.
Left by Bram on Jan 22, 2008 8:42 AM

# re: WCF vs Remoting - adjustments to my results
Requesting Gravatar...
Hi Marcin,

I have done some similar testing, see http://geekswithblogs.net/BVeldhoen/archive/2008/01/26/wcf-latency-test-harness.aspx for similar results.

Bram.
Left by Bram on Jan 29, 2008 10:54 PM

# re: WCF vs Remoting - adjustments to my results
Requesting Gravatar...
Hi Marcin, would you mind posting the changed code so I can compare? As a VB developer, I have to see the final code in order to understand the differences.

Thanks very much!
Bob
Left by Bob on Mar 24, 2009 6:55 AM

# re: WCF vs Remoting - adjustments to my results
Requesting Gravatar...
You can download the sample project from codeplex: http://wcfvsremoting.codeplex.com/
Left by Marcin Celej on Mar 24, 2009 8:18 AM

# re: WCF vs Remoting - adjustments to my results
Requesting Gravatar...
Hello:

I have to say the timing for WCF and Remoting are close only for the small datasets. For big untyped Datasets Remoting if much faster. That is because ds.RemotingFormat = SerializationFormat.Binary is not working for WCF. Without this setting serialized DataSet has 3 to 4 times bigger size. In my case it was 7.5MB vs 34 MB. The timing for the data transfer is proportional to the data size. Hence, I expect Remoting to be 4 times faster in this case, when working over WAN.

Regards
-jeff
Left by Jeff Gorvits on Jun 13, 2009 2:50 AM

# slow beyond belief
Requesting Gravatar...
I am a bit surprised by the conclusion.

The first chart shows that WCF is twice as slow, yet "The WCF and .NET Remoting are really comparable in performance.". No, they are not. WCF is more than twice as slow according to your own numbers.

And this is before you have deployed the thing to a WAN? I have recently converted a remoting application to WCF (some 40+ interfaces) and it works fine on the LAN. To get it working in a WAN setting is so far an exercise in futility. Silly configuration options, mixed with an inexplicable drop in performance (down from 'acceptible' to 'seriously slow/dead')
Left by Rune on Sep 28, 2009 10:31 PM

# re: WCF vs Remoting - adjustments to my results
Requesting Gravatar...
Hello. Does the WFC gives support for serialize linq objects? .Net remoting doesn't. :(

Left by using WCF with linq objects on Dec 13, 2009 3:06 PM

# re: WCF vs Remoting - adjustments to my results
Requesting Gravatar...
I just downloaded your solution and noticed the following:

if (includeSchema)
ds.SchemaSerializationMode = SchemaSerializationMode.IncludeSchema;
else
ds.SchemaSerializationMode = SchemaSerializationMode.IncludeSchema;

located in the server project. you might want to fix that.
Left by Grey on Mar 19, 2010 3:03 AM

# re: WCF vs Remoting - adjustments to my results
Requesting Gravatar...
Thank you for your such effort and analysis.
Left by JigneshGN on Dec 15, 2010 5:40 PM

# re: WCF vs Remoting - adjustments to my results
Requesting Gravatar...
It would also be interesting to see the difference in size of the total transmission. Looking at speed alone suggests XML serialization is always better because of flexibility, easier diagnostics, etc... Also considering different types of messages and with MTOM enabled or not. And with .NET 3.5 and 4 because they are supposed to have improved things.
Left by Tony Wall on Jul 12, 2011 9:55 PM

Your comment:
 (will show your gravatar)
 


Copyright © Marcin Celej | Powered by: GeeksWithBlogs.net | Join free