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.”
Still articles are articles and facts are facts – “the costumer is always right”
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:
- Pass 10000 objects – the object include two fields: integer and string.
- Pass “large” dataset – includes one table the has two string columns contains 10000 rows.
The services types:
- Simple ASMX web service.
- 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.
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.