The Channel Pump

Note: Cross posted from Sajay.
Permalink

Deep dive - Nicholas Allen's talk on WCF performance and Scale - PowerPoint Deck - Webcast

From the above talk you get an idea of the pull and the push model and a combination of these for certain channels. This defines how the message will be received on the transport and how they will be dispatched. Consider a pump as a loop doing some work. A pump works off a queue which it would push work on for the next layer or pulls work off when there is some work to be done.

Considering a very common scenario like basic http where a message would arrive on the transport. The flow would consist of 2 loops.

channel pump

Dispatcher/Message Pump

1. Dispatcher gets a message. It has available resources and will dispatch the operation(Application) 2. Dispatcher then tells the pump that it can accept the next message.

Channel Pump

1. Pump registers that it can take pull a message. 2. Message arrives and Transport pushes the message to the dispatcher.

All channels affect how messages arrive and how they would be dispatched. We make a fundamental assumption in WCF that channels would always be fast. This is because of the fact that the channel is your infrastructure and it makes sense to put any heavy work to the application layer and not the channel layer.

So general rule of thumb - Do not do blocking or heavy work in your channels. Pass on the work to the upper application layer.

You should think of your channel as gate to your dispatcher and you don't want to block the gate from letting the next person in. Hence bottom line is that a slow channel is a suboptimal channel.