Question

I have a question with regards to WCF client channel lifetime while using Message security, but first, a few notes on my company's setup and guidelines:

  • Our client-server applications are solely for intranet use
  • Our clients are WPF applications
  • Our company's guidelines for WCF usage are:
    • Use wsHttpBinding
    • Use Message Security
    • Service InstanceMode: PerCall
    • Service ConcurrencyMode: Multiple

It is the first time I have to use message security on an intranet setup. Here's how I typically use my client channels to limit the amount of resources kept on the client and server and literally just to keep things simple:

  1. Instantiate + open channel (with ChannelFactory)
  2. Make the WCF call
  3. Close / dispose the channel asap

While monitoring this strategy with Fiddler 2, I noticed that because of Message Security, a single WCF call ended up causing 5 round-trips to my service:

  • 3 initial round-trips for handshaking
  • 1 round-trip for the actual WCF call
  • 1 call to close the session (since I am using PerCall, I am assuming this is more a security session at the IIS level)

If I were to turn off Message Security, as one would expect, one WCF ended up being... A single round-trip.

As of now, I must use Message Security because that's our guideline. With this in mind and knowing that we make hundreds of WCF calls from each client WPF app a session, would you therefore advise to open the client channel and keep it open for re-use instead of disposing of it every time?

Was it helpful?

Solution

I would advise not to preemptively turn off features until you know they are a known problem. Preoptimization is needless work. Until you notice your clients having lagging problems, I would not worry about the message security. At that point, try a few things: one of your approaches of keeping a client open longer; two, try grouping requests together without turning off message security; three, consider caching, if you can; four, if the message security is the final culprit, then try a different method. I wouldn't just turn something off because I see a bit more network traffic until I knew it was the absolute last thing that I could do to improve performance.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top