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\TechnologySamples\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.TryGetValue(to,
out forwardingChannel) || ((IClientChannel)forwardingChannel).State !=
CommunicationState.Opened)
{
lock (this.extension.RequestReplyDatagramChannels)
{
if
(!this.extension.RequestReplyDatagramChannels.TryGetValue(to, out
forwardingChannel) || ((IClientChannel)forwardingChannel).State !=
CommunicationState.Opened)
{
ChannelFactory<IRequestReplyDatagramRouter> factory
= new
ChannelFactory<IRequestReplyDatagramRouter>(this.extension.Bindings[to.Uri.Scheme], to);
// Add a channel behavior that will turn off
validation of @mustUnderstand on the reply's headers.
factory.Endpoint.Behaviors.Add(new
MustUnderstandBehavior(false));
forwardingChannel = factory.CreateChannel();

this.extension.RequestReplyDatagramChannels[to] =
forwardingChannel;
}
}
}

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
"this.extension.Bindings[to.Uri.Scheme]")
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
efficiency?

Thanks.
JS

--
Jonathan Steinberg
Jefferies & Co.
.



Relevant Pages

  • [PATCH] 2.6.22 - Documentation Cleanup
    ... To allow flexibilty for each cpu type and board, ... dma code can be given an dma ordering structure which ... allows the order of channel search to be specified, ... like above are usually useful in midlayer driver (e.g. libata core ...
    (Linux-Kernel)
  • Steelseries Ikari laser mouse.
    ... hptrr: adapter at PCI 4:4:0, ... 2 ports with 2 removable, ... CPU supports Enhanced Speedstep, ... hptrr: start channel ...
    (freebsd-stable)
  • [Full-disclosure] Multiple vulnerabilities in ircu
    ... Ircu is the open source IRC server used on Undernet and other IRC networks. ... they allow clients to get more privileges on the IRC ... Gaining ops on channels that get empty on one side of a netsplit ... Making clients think someone is on a channel, ...
    (Full-Disclosure)
  • [NT] RogerWilco Security Vulnerabilities
    ... The following security advisory is sent to the securiteam mailing list, and can be found at the SecuriTeam web site: http://www.securiteam.com ... The UDP port is used for the audio channel. ... (forwarded by the server) ... The last piece of the packet is the audio data block. ...
    (Securiteam)
  • Multiple vulnerabilities in ircu
    ... Ircu is the open source IRC server used on Undernet and other IRC networks. ... they allow clients to get more privileges on the IRC ... Gaining ops on channels that get empty on one side of a netsplit ... Making clients think someone is on a channel, ...
    (Bugtraq)