Geeks With Blogs

News

View Marcin Celej's profile on LinkedIn


Marcin Celej blog

In the last blog I wrote about Windows Communication Foundation performance comparison. The document available here: A Performance Comparison of Windows Communication Foundation (WCF) with Existing Distributed Communication Technologies. I am mainly interested in the comparison of WCF and .NET Remoting. I decided to perform my own research on that topic. Here is what I tested:

  1. SingleCall service - the simplest .NET Remoting service type
  2. Data Transfer Object is DataSet - I believe it is the common medium of sending data
  3. Client and Server are both placed on a single machine
  4. TCP channel - this one allows to communicate two machines with .NET on both sides

Let me describe the client and server applications:

Server

  • The service in general:
    - contains one method that takes one argument and returns DataSet (the DataSet contains as many rows as method argument says)
    - DataSet contains 4 columns - ID (long), Name (string), Description (string) and CreatedOn (DateTime)
  • The .Net Remoting version of the service:
    - it's a wellknown server activated object with SingleCall activation mode
    - the channel is TCP with binary serialization
  • The WCF version of the service:
    - it uses netTcpBinding

Client

  • Invokes each of the service (WCF and Remoting) 100 times on a single thread (sequential invocation in a loop)
  • Passes to the service number of rows to generate in the DataSet (1, 100 and 200)
  • I measured creation of the service proxy, method invocation and proxy close (with WCF service)

Performance results of the services

I tested four ways of the DataSet serialization settings:

  1. Binary serialization; Schema not included in the DataSet
  2. Xml serialization; Schema not included in the DataSet
  3. Binary serialization; Schema included in the DataSet
  4. Xml serialization; Schema included in the DataSet

Here are sample results displayed on charts:

Explantion: The charts show time (in miliseconds) of method invocation so - the lower the better.

I chose here the fastest and the slowest of my tests: binary + no schema and xml + schema. As you can see in each of the cases the Remoting service is the fastest one (probably because the DataSet native serialization is better to the one provided with WCF).

Conclusion

Sending DataSet with .NET Remoting is faster (in any of cases I tested) than sending it with WCF. Maybe there is some other way to improve the WCF in case of sending DatSet but I haven't found it yet. I'll post the test project somewhere (maybe on codeproject) so it could be examined.

Posted on Thursday, April 12, 2007 7:02 PM | Back to top


Comments on this post: WCF vs. Remoting (with DataSet)- performance comparison

# re: WCF vs. Remoting (with DataSet)- performance comparison
Requesting Gravatar...
This is very interesting!

It contradicts the Microsoft report : "To summarize the results, WCF is [...] approximately 25% faster than .NET Remoting". They compare WCF and .NET Remoting on the same machine (net.pipes binding).
Left by claraoscura on May 24, 2007 8:15 AM

# re: WCF vs. Remoting (with DataSet)- performance comparison
Requesting Gravatar...
Passing dataset trough WCF isn't a really good practise, you should create your own DataContract.
Left by crypto on May 25, 2007 10:21 PM

# re: WCF vs. Remoting (with DataSet)- performance comparison
Requesting Gravatar...
Hi,
I have already gone through the msdn article(A Performance Comparison of Windows Communication Foundation (WCF) with Existing Distributed Communication Technologies) mentioned by you.
If you have noticed(Page 2 of the article under heading Asp.net web services inside the C# code ), it has taken one object size as 256 bytes while it has put
variables of more than 1kb in these object like shipping address1, itemid, quantity etc.
Can you please let me know whether it is an typo error made in the article or am i mistaking something.
It is very important as i have to calculate my application performance based on object size.
Cheers
Left by rajiv on Jun 26, 2007 10:20 PM

# re: WCF vs. Remoting (with DataSet)- performance comparison
Requesting Gravatar...
Hi, would you consider to publish the sample projects inclusive of the source code for other to test it out in their environment?

Thanks.
Left by LAU on Jul 07, 2007 8:43 PM

# re: WCF vs. Remoting (with DataSet)- performance comparison
Requesting Gravatar...
I finally found some time to publish the proeject as you requested. It is available at CodePlex: http://www.codeplex.com/WCFvsRemoting

I hope it is published properly as I am new to the Codeplex.

Please, let me know if there are any issues.
Left by Marcin Celej on Aug 23, 2007 7:45 AM

# re: WCF vs. Remoting (with DataSet)- performance comparison
Requesting Gravatar...
Kindly send code sample to me
Left by Suyog dabhole on Aug 28, 2007 4:56 PM

# re: WCF vs. Remoting (with DataSet)- performance comparison
Requesting Gravatar...
You can download the code here:

http://www.codeplex.com/WCFvsRemoting/Release/ProjectReleases.aspx?ReleaseId=6774
Left by Marcin Celej on Aug 29, 2007 8:54 AM

# re: WCF vs. Remoting (with DataSet)- performance comparison
Requesting Gravatar...
Marcin, thanks a lot for beining interested in the performance of WCF and did the measurement!

The reason why you get worse data for WCF in your sample is because of the following problems:
1) You are creating the WCF proxy on every message. WCF ChannelFactory/proxy creation is very expensive. It is recommended to cache them, especially the ChannelFactory.
2) You are measuring the client latency instead of server throughput. In Microsoft's data, we measure it server throughput, that is, we have many clients to connect to the server and let the server to be fully loaded.
3) As "crypto" pointed out above, WCF performs the best when you use DataContract. In Microsoft's data, we used binary arrays to perform the fair comparison:
public interface IRemoteObject
{
[OperationContract]
byte [] GetRBytes(int NumBytes);
}
The size of the message payload returned is determined by the "NumBytes" which for the data below is 128 bytes, 4k and 256k. The NetNamedPipeBinding is employed without any security for this scenario.

Hope that this help!
Wenlong
Left by Wenlong Dong on Sep 26, 2007 5:04 AM

# re: WCF vs. Remoting (with DataSet)- performance comparison
Requesting Gravatar...
BTW, after caching the proxy (simply define it as a static variable and create it beforehand), it shows that the data for WCF is slightly better than that of Remoting. Also two more comments:
1) You are using NetTcpBinding in your test. You need to turn off the security for fair comparison by setting the SecurityMode to None.
2) If you use NetNamedPipeBinding vs IpcChannel for Remoting, you would get different data.
Left by Wenlong Dong on Sep 26, 2007 5:10 AM

# re: WCF vs. Remoting (with DataSet)- performance comparison
Requesting Gravatar...
Thanks a lot for your comments. It's funny as I just started evolving my test project to check the WCF versus remoting in all aother cases.
I am aware of the problems you mentioned here an I will put it in my application and maybe the comparison will be better for the WCF.
Anyway I think WCF is great and the performance results do not prevent me from using it. Vista is also slower to XP but it is because it does a lot more things.

I will turn off the security.
I will stil use NetTcpBinding as I believe it is the most common for client server apps.
I will still test DataSet as the DTO as I believe it is what is most common case.
I will not cache ChannelFactory as I believe it shouldn't be done in a real life application.
I will add other test methods to test performanvce of the plain objects (DataContract).
I will still measure client latency as I am intersted mainly in that factor.

Just wait for the next post with the results.
Left by Marcin Celej on Sep 26, 2007 7:17 AM

# re: WCF vs. Remoting (with DataSet)- performance comparison
Requesting Gravatar...
Hmmm, I revised my opinion:

I will cache ChannelFactory as it can be reused and I believe it should be hidden in factory class or method in a real life application so the factory can do it for you.

Thanks once again
Left by Marcin Celej on Sep 26, 2007 7:21 AM

# re: WCF vs. Remoting (with DataSet)- performance comparison
Requesting Gravatar...
Here you can fine revised results with the suggestion from Wenlong Dong:

http://geekswithblogs.net/marcel/archive/2007/09/26/115651.aspx
Left by Marcin Celej on Sep 28, 2007 7:37 PM

# re: WCF vs. Remoting (with DataSet)- performance comparison
Requesting Gravatar...
Create your own Data Contracts and return the Generic list.
Left by Jamal Gilani on Jun 30, 2009 12:41 PM

# re: WCF vs. Remoting (with DataSet)- performance comparison
Requesting Gravatar...
Nice article. Thank you.
Left by John Warner on Jul 31, 2009 6:25 AM

# davetiyeci
Requesting Gravatar...
güzel davetiye sözleri ve davetiye modelleri
Left by davetiye on Oct 28, 2009 10:30 PM

# re: WCF vs. Remoting (with DataSet)- performance comparison
Requesting Gravatar...
güzel davetiye sözleri ve Davetiye metinleri
Left by davetiye on Nov 01, 2009 9:06 PM

# davetiyeci
Requesting Gravatar...
güzel davetiye sözleri ve davetiye metinleri
Left by davetiye on Nov 01, 2009 9:11 PM

# re: WCF vs. Remoting (with DataSet)- performance comparison
Requesting Gravatar...
What is the final conclusion , and which is faster
Left by Seshu on Jan 05, 2010 9:04 PM

# re: WCF vs. Remoting (with DataSet)- performance comparison
Requesting Gravatar...
Nice Article learned a lot.
Left by amir on Jan 07, 2010 6:57 PM

# re: WCF vs. Remoting (with DataSet)- performance comparison
Requesting Gravatar...
Ha Sido un Laaaaaaaaaaaargo Camino hasta hoy, Buenisisimo.
Left by Pablo on Jan 08, 2010 6:30 AM

# re: WCF vs. Remoting (with DataSet)- performance comparison
Requesting Gravatar...
i am still confusing, in graph shows wcf is better performance than remoting, but in description it is mentioned remoting is faster.... so finally which one is better one.
Left by vrsanaidu on Jan 19, 2010 11:16 PM

# re: WCF vs. Remoting (with DataSet)- performance comparison
Requesting Gravatar...
Below the chart you can find a description: The charts show time (in miliseconds) of method invocation so - the lower the better.

It means that Remoting is better as it has smaller columns :)
Left by Marcin Celej on Jan 19, 2010 11:29 PM

# re: WCF vs. Remoting (with DataSet)- performance comparison
Requesting Gravatar...
hi,marcin I have a issue on the performance of WCF working on IIS
maybe you can help me,check my thread below
http://social.msdn.microsoft.com/Forums/en/wcf/thread/c7bce8d1-f10e-40c8-8caa-0be2c6568abc
Left by okoha on Dec 26, 2010 7:06 PM

# re: WCF vs. Remoting (with DataSet)- performance comparison
Requesting Gravatar...
Hi Marcin,

I'm faced with exactly the same scenario as you've outlined here. We want to move our existing dataset based .net2 web services across to WCF with nettcp transport running under .net4. Ideally we'd find time to move the return types over to POCO's but it's not an option at the moment so we are looking at this route in the short term. I was just wondering did you ever manage to get the type of speed up you were after or did you go with the remoting solution?

Cheers.
Left by Matt on Nov 16, 2011 7:45 AM

# re: WCF vs. Remoting (with DataSet)- performance comparison
Requesting Gravatar...
which one is better?
Left by moa on Feb 08, 2012 1:07 AM

# re: WCF vs. Remoting (with DataSet)- performance comparison
Requesting Gravatar...
Hi, any chance of a descriptive walkthrough of your code for someone who is new to remoting .Net or otherwise.

Thanks
Left by Luke on Feb 10, 2012 4:26 AM

# re: WCF vs. Remoting (with DataSet)- performance comparison
Requesting Gravatar...
Passing Data Set to WCF Service??
not a good idea at all..
what ever happened to JSON or XML?
Left by Chetan on Jan 21, 2014 6:54 PM

Your comment:
 (will show your gravatar)


Copyright © Marcin Celej | Powered by: GeeksWithBlogs.net