WCF Performance Using Datasets – Part 1

3 בJuly 2011



It’s all started when I encountered a strange behavior in one of the systems I work on.

The system is a legacy system that uses a simple client server architecture implementing using web service – this was pre-WCF time so the options were only .NET remoting and web services. Now as part of major refactoring process of the system we decided to replace the communication layer from WS to WCF.

The motivation is obvious:

  • Alignment with Microsoft latest infrastructure.
  • performance improvement – http to TCP/ Binary encoding.
  • Easy maintenance.
  • Easy monitoring and configuration.
  • Extendible – interception points (behaviors).

After the modification was completed I found that the system became slightly slower  – how can it be.

WCF performance vs. Web Service – What do we know

This bring me to article from 2007 written by Microsoft: http://msdn.microsoft.com/en-us/library/bb310550.aspx

To summarize the results, WCF is 25%—50% faster than ASP.NET Web Services, and approximately 25% faster than .NET Remoting. Comparison with .NET Enterprise Service is load dependant, as in one case WCF is nearly 100% faster but in another scenario it is nearly 25% slower. For WSE 2.0/3.0 implementations, migrating them to WCF will obviously provide the most significant performance gains of almost 4x.”

My Benchmark

Still articles are articles and facts are facts – “the costumer is always right” Smile

In addition in the article there was no mention of datasets specifically.

In the legacy system we mostly use DataSet (I know pretty ugly but this is what we did in a legacy code what can I do…).

So I decided doing my own simple benchmark.

I tested two scenarios:

  1. Pass 10000 objects – the object include two fields: integer and string.
  2. Pass “large” dataset – includes one table the has two string columns contains 10000 rows.

The services types:

  1. Simple ASMX web service.
  2. Self hosted WCF service.

the client makes sequential call to the services: 1 then 2 and I measure the duration in milliseconds.

I repeat the same test 1000 time and use the average duration of the last 100 test runs.

here are the results (duration in milliseconds):




Conducting a Benchmark Notes

Not doing the following can get you faulty results.

  • Remember to run the tests not using Visual Studio (not using the .vshost.exe process).
  • Run the sources complied in “Release”.


My conclusion is for dataset transfer Web Service is faster than WCF (around ~40% faster).

So when choosing to upgrade legacy code to use WCF – will not always increase your system performance – if you use mostly datasets your system may become slower.

What’s next

This is only the start because:

  • First we need to understand what is the cause for the performance decrease – why is WCF slower only for DataSets.
  • Second we need to find a solution to use WCF but still keep our performance or better improve – going back to Web Service is not an option.

So stay tune for part 2, I promise it’s we’ll be worthwhile.




Add comment
facebook linkedin twitter email

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>



  1. Vardi4 בJuly 2011 ב 14:05

    אתה צריך לכוון את ההפרמטרים של ה
    ואז את תקבל שיפור ביצועים כמו למשל לשנות ל
    או לעבוד עם
    WCF is Faster…

  2. Offir Shvartz5 בJuly 2011 ב 12:19

    Eyal Vardi
    I tried with costum binding TCP with MTOM encoding and XMLSerializer and the WCF preformance got worst
    can you give more details about MTOM – I know WCF should be faster (and it is for objects) – tell me if you think somthing in my tests are wrong.