Interesting related videos

Loading...

Monday, May 5, 2008

Increasing WCF Client Applications Performance

Some times your WCF client object are created on the Middle-Tier of the application.
This scenario leads for creating many WCF client objects quickly and, as a result, experience increased initialization requirements.

There are two main approaches to increasing the performance of middle-tier applications when calling services:
1. Cache the WCF client object and reuse it for subsequent calls where possible.
2. Create a ChannelFactory object and then use that object to create new WCF client channel objects for each call.

Issues to consider when using these approaches include:

- If the service is maintaining a client-specific state by using a session, then you cannot reuse the middle-tier WCF client with multiple-client tier requests because the service's state is tied to that of the middle-tier client.

- If the service must perform authentication on a per-client basis, you must create a new client for each incoming request on the middle tier instead of reusing the middle-tier WCF client (or WCF client channel object) because the client credentials of the middle tier cannot be modified after the WCF client (or ChannelFactory) has been created.

- While channels and clients created by the channels are thread-safe, they might not support writing more than one message to the wire concurrently. If you are sending large messages, particularly if streaming, the send operation might block waiting for another send to complete. This causes two sorts of problems: a lack of concurrency and the possibility of deadlock if the flow of control returns to the service reusing the channel (that is, the shared client calls a service whose code path results in a callback to the shared client). This is true regardless of the type of WCF client you reuse.

- You must handle faulted channels regardless of whether you share the channel. When channels are reused, however, a faulting channel can take down more than one pending request or send.

Link to MS article:
Middle-Tier Client Applications

No comments: