By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,939 Members | 1,540 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,939 IT Pros & Developers. It's quick & easy.

WCF Router Sample CPU Usage Problem

P: n/a
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
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.