468,733 Members | 2,181 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,733 developers. It's quick & easy.

WCF Router Sample CPU Usage Problem

I am looking at using the rotuer sample that comes with the samples in the
Vista sdk (Microsoft
SDKs\Windows\v6.0\Samples\WCFSamples\TechnologySam ples\Scenario\Router\CS\router)

I am using .Net 3.0, C# 2.0, on win2K3 servers.

I have stripped down almost all of the non-essential code from the message
processor , leaving me with this code:

//ProcessMessage implemenation
Message IRequestReplyDatagramRouter.ProcessMessage(Message message)
string newEndPoint = ///destination server endpoint.
EndpointAddress to = new EndpointAddress(newEndpoint);

// If the router doesn't already have a two-way datagram channel
to the 'to' EPR or if that channel is no longer opened, create one.
IRequestReplyDatagramRouter forwardingChannel;
if (!this.extension.RequestReplyDatagramChannels.TryG etValue(to,
out forwardingChannel) || ((IClientChannel)forwardingChannel).State !=
lock (this.extension.RequestReplyDatagramChannels)
(!this.extension.RequestReplyDatagramChannels.TryG etValue(to, out
forwardingChannel) || ((IClientChannel)forwardingChannel).State !=
= new
ChannelFactory<IRequestReplyDatagramRouter>(this.e xtension.Bindings[to.Uri.Scheme], to);
// Add a channel behavior that will turn off
validation of @mustUnderstand on the reply's headers.
forwardingChannel = factory.CreateChannel();

this.extension.RequestReplyDatagramChannels[to] =

Message response = forwardingChannel.ProcessMessage(message);

return response;


This is almost exactly the same as the sample, except for these changes I made
1) I am hosting the service in IIS (6.0)
2) I replaced the custom binding class in the extension class with "new
basicHTTPBinding()" ( i.e., where it calls
3) For now the destination URL is hardcoded (the "to" endpoint")

Here's the question:
The Router works fine, but I am concerned about CPU usage.
Stress testing on our development servers shows that the CPU hits 90-100%
on the routing server when I hit about 50 requests a second. When I call my
destination server (the actual app logic) directly from the test client, the
application server rarely goes over 20% CPU. The operation is a very light
operation , mainly looking up data in a static dictionary.
I verified by logging that the forwarding channel is *not* being created
every time. It is cached in the extension class.
The only code which is executing every call is

Message response = forwardingChannel.ProcessMessage(message);

Why would this use so much CPU, and where could I look to tune this for more


Jonathan Steinberg
Jefferies & Co.
Jun 27 '08 #1
0 1702

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by John J. Hughes II | last post: by
2 posts views Thread by cyshao | last post: by
3 posts views Thread by steve | last post: by
reply views Thread by mario.lat_ | last post: by
5 posts views Thread by =?Utf-8?B?SmltbWVy?= | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.