WCF gives a very rich set of standard bindings that you can use for your endpoints. However we might need to tweak properties that might not be exposed on the standard bindings. You can handcraft the whole binding or you can start with standard binding as a template. Here are some ways.
- Create the BindingElementCollection from the StandardBinding and update properties on it and use the BindingElementCollection to create the CustomBinding. This creates a full clone of binding elements and you can reset values on the elements using Find<BindingElement> on the collection.
- Create the CustomBinding directly from the StandardBinding by passing the binding into the CustomBinding constructor. The first approach has an issue where properties like SendTimeout/ReceiveTimeout etc don’t get copied onto the CustomBinding since they are held by the Binding and not its child elements & for this simple reason would recommend the second approach.
BasicHttpBinding httpBinding = new BasicHttpBinding();
httpBinding.SendTimeout = TimeSpan.FromSeconds(123);
Console.WriteLine(httpBinding.ToString());
BindingElementCollection bec = httpBinding.CreateBindingElements();
bec.Find<HttpTransportBindingElement>().KeepAliveEnabled = false;
CustomBinding copy1 = new CustomBinding(bec);
Console.WriteLine("SendTimeout = {0} KeepAliveEnabled = {1}",
copy1.SendTimeout,
copy1.Elements.Find<HttpTransportBindingElement>.KeepAliveEnabled);
CustomBinding copy2 = new CustomBinding(httpBinding);
copy2.Elements.Find<HttpTransportBindingElement>.KeepAliveEnabled = false;
Console.WriteLine("SendTimeout = {0} KeepAliveEnabled = {1}",
copy2.SendTimeout,
copy2.Elements.Find<HttpTransportBindingElement>().KeepAliveEnabled);
An easy way for getting performance and diagnostic information. You can quickly collect etw/minidumps vmmaps etc.
http://visualstudiogallery.msdn.microsoft.com/en-us/e8649e35-26b1-4e73-b427-c2886a0705f4
This is the command you can use to do an automated 5 second network capture using netmon for default net.tcp traffic on any stack such as wcf or Sapphire. The default net.tcp port is 808 so thats what we use here.
nmcap /network * /capture tcp.port == 808 /startwhen /timeafter 0 sec /stopwhen /timeafter 5 sec /file output.cap
- You can download network monitor from here
- Check out this post incase you are not aware of nmcap.
Here are some quick walkthroughs on how you can write native services and consume web services natively.
For the samples you can get the Microsoft Windows SDK for Windows 7 and .NET Framework 3.5 SP1
Here was an interesting set of questions comparing WCF & WWS
1) With .NET 4.0, are we going to see any improvement to close the gap?
2) There seems very little information about this except on Channel 9 or various blogs. Are we going to see more information?
3) Is there a way to get the best of both WWS and .NET in a typical application? For example, use WWS for the web service API for
Here is the reply from Bob (our Product Unit Manager)
WCF and Windows Web Services (WWS) are complementary technologies. WCF is the premier Web Services stack to use when writing managed applications; if you are writing native code and want a SOAP stack then definitely use the WWSAPI. Introducing a native SOAP stack underscores our commitment to interop and WS-*. WWSAPI supports a subset of WS-* and is not as full featured or extensible as WCF. It definitely has a smaller footprint than WCF and it also has higher throughput for the scenarios it supports. This is due to a reduced feature set and implementation in native code. It also interops on the wire with WCF.
To answer the specific questions below:
- The current performance of WCF is industry leading. Please see the link for comparison with WebSphere where WCF easily outperforms the competition: http://download.microsoft.com/download/4/8/6/486B4B4F-5A87-4B5C-BEEC-455290F83274/IBMPower570_WebSphere_7_%20NET_Benchmark_WinSrv2008.pdf
- For most WCF scenarios .NET 4 performance is similar, or slightly better than, WCF perf in .NET 3.5 SP1
- The article references does not show WWSAPI to be 10X faster than WCF (as the customer claims); it does show the working set of WWS (native) to be 0.5-1MB compared to 4.5MB for WCF (managed/.NET). Server throughput is also better for WWS than WCF, but as noted above, WCF is already industry leading. The fact that a highly tuned, native, less-feature-rich SOAP stack has higher server throughput on ping-like service is not concerning. The cost of any realistic service will dwarf the infrastructure cost of either WCF or WWS. Put another way, either stack should meet the performance needs of a service and the deciding factor should be whether you require a native or managed solution.
- The article does not state that most teams in MS are moving to WWSAPI as the customer notes. What is happening is that those teams which require a native SOAP stack can move to WWSAPI; the majority however are using WCF as they are managed.
- Finally, trying to wrap or PInvoke between the two is not recommended. If you are writing managed code use WCF; if you are writing native code use WWSAPI.
This was again something we should have done long time back. I guess it was my laziness combined with utter ignorance of a place like this so close to our home in Bangalore. Dad was even more reluctant for some apparent reason. Anyway Mom and Aditi made us silly men realize what an amazing place Bannerghatta National Park actually is.
This one actually came and stood on a kind of pedestal close to the bus we were all in. Really amazing and beautiful creature.
On the way we go through a bear/lion/tiger reserve and finally come back to the zoo. We got to see a baby hippo at the zoo, which was quite interesting. This shot was when the care taker dumped a whole bunch of leaves right onto the little one.
We were thinking of hitting some conventional restaurant,like TGIF for dinner. But we soon realized that Mom would find it quite hard to get something she could enjoy at a place like that and so wanted to try something a bit more Indian. So during the day we were at Forum Mall and spotted a pretty exclusive looking entrance to a restaurant and were curious. Aditi told me that this was a part of BJN group so we decided to try it out. We were a bit worried but anything thought of giving it a try. Fortunately we weren’t disappointed at all.
The place had an amazing ambience and the food was just excellent. We tried the lamb Raan which I think is a must try for any non-vegetarian. The place is done pretty much like an old train station with all the sign boards and even the rail sleepers. Check here for more reviews.
This was the best barbecue I’ve had with whiskey marinated Lamb and a freshly caught fish from the river. We didn’t manage to catch anything ourselves besides stones so we got some professionals to help with the fishing. Utsu managed to take over as the butcher this time.
I also tried Tongba (http://en.wikipedia.org/wiki/Tongba), millet based alcoholic beverage, for the first time. It’s drunk warm and refilled with warm water to make a heterogeneous millet mixture. It’s one hell of a nice drink and a sweet high. We didn’t manage to get the actual bamboo container in which it is actually supposed to be had, so managed with something that we managed to find around Kaka’s farm house. The straw has a special valve, kind of perforated, which filters the millet out. We got one from the nice villagers around there.

Next day we went over to Salami and this was the view of the farm house we stayed last night. I thought the fan was running the whole night and turns out it was actually the sound from the river.

We generally need to have a quick set of performance counters to identify a performance issue with a service. Shown below are three new counters that you will find with WCF 4.0. I also want to emphasize on the Calls outstanding counter here since this is one very u
| PercentOfMaxCalls | Reports # of active requests as % of max calls | Reports the numbers of messages being processed + in the wait queue as a percentage of MaxConcurrentCalls throttle |
| PercentOfMaxSessions | Reports # of active requests as % of max sessions | Reports the numbers of active instances + calls in the wait queue waiting for an instance as a percentage of MaxConcurrentInstances throttle |
| PercentOfMaxInstances | Reports # of active requests as % of max instances | Reports the numbers of messages in the wait queue due to MaxConcurrentSessions throttle |
| CallsOutstanding ( from 3.0) | Reports the # of calls waiting to be completed | Reports the number of in-progress calls to this service. |
Here you see that the %Instance throttle has maxed out. What do you think we should do? You can guess what throttle we are hitting here.
Some common questions when trouble shooting performance problems:
Why are my clients timing out, the service is showing 100% for % of MaxConcurrentCalls?
% of MaxConcurrentCalls gives you an indication of how much closer you are to hitting your max throttle value. This means that if you have a max concurrent call of 10 and you have 10 outstanding calls then you have utilized 100% of your throttle and there is no more work that your service can do. So if you see that your % maxConcurrentCalls is very high it probably indicates you have a very low throttle value. Remember the default is 16 till v3.5 and 16* proc count for v4.0. Before 4.0 you needed to work this out by checking the calls outstanding throttle and your web.config to figure out this value. These new % performance counters would help you identify if you are hitting the max values from now.
What if % MaxConcurrentSessions is showing 100% ?
We have bumped up the default number of sessions for service throttling behavior to 100 per CPU. But then again if you are seeing that %MaxConcurrentSessions is very high this means that you have exhausted all your session. This is probably because your clients are not closing either proxies and terminating sessions when you have less clients or possibly due to a very small MaxConcurrentSessions configuration.