Chapter 12: Implementing a WCF Service for Good Performance


image from book Download CD Content

Overview

After completing this chapter, you will be able to:

  • Manage service scalability by using throttling to control use of resources.

  • Use the Message Transmission Optimization Mechanism (MTOM) to transmit messages containing binary data in a standardized, efficient manner.

  • Explain how to enable streaming for a binding and design operations that support streaming.

Good performance is a key factor in most applications and services. You can help to ensure that a WCF service maintains throughput, remains responsive, and is scalable by thoughtful design, by selecting the appropriate features that meet this design. Examples that you have met so far include careful use of transactions, session state, reliable messaging, and asynchronous operations.

There are other aspects that can impact performance, such as security. You have seen, in earlier chapters, that implementing message level security and secure conversations results in a complex exchange of messages negotiating the protocol to use and the exchange of identity information. Messages themselves are bigger as a result of the additional security information included in the message headers, which means they take longer to traverse the network and require more memory to process. Encryption and decryption are also very resource intensive tasks. However, these are all necessary parts of a secure system, and most people are willing to sacrifice some performance in return for ensuring that their data and identity information remain private. (If decryption were quick and easy to perform, it would also be fairly useless; the more resources it takes to decrypt a message, results in a better protected message.)

An important aspect of maintaining performance is to ensure that a service does not exhaust the resources available on the host computer, as this will cause the system to slow down and possibly stop altogether. WCF provides service throttling to help control resource utilization. Using this feature can greatly aid the scalability of your service. You can also use WCF in conjunction with load-balanced servers. Chapter 13, “Routing Messages,” describes a simple implementation of this technique using WCF. You can also build a load-balancing infrastructure based on Microsoft Windows Network Load Balancing, although the details of this technology are outside the scope of this book.

More Info 

For further information about Microsoft Windows Network Load Balancing, see the Load Balancing page on the Microsoft Windows Server TechCenter Web site at http://technet2.microsoft.com/windowsserver/en/technologies/nlb.mspx.

Using the appropriate encoding mechanism when transmitting data can also have a significant effect on performance. You have seen how WCF supports text and binary encoding of messages. Binary encoding is often more compact and incurs less network overhead, but the format is proprietary and cannot easily be used with applications and services running on non-Microsoft platforms. However, WCF also supports MTOM, which provides a standardized, interoperable format for transmitting large blocks of binary data.

MTOM is useful if you know how much data the service is going to transmit. Some services emit long data blocks of indeterminate size. This type of data is best transmitted as a stream, and WCF provides support for outputting streams from a service.

In this chapter, you will examine how to use service throttling to assist in maintaining scalability, how to encode data by using MTOM to reduce the overhead of transmitting large binary data objects, and how to enable streaming to make best use of network bandwidth.




Microsoft Windows Communication Foundation Step by Step
Microsoft Windows Communication Foundation Step by Step (Step By Step Developer Series)
ISBN: 0735623368
EAN: 2147483647
Year: 2007
Pages: 105
Authors: John Sharp

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net