For greater flexibility our router can be something like a pass through router. If we are just calling a backend service then we can use a generic contract to receive and forward messages to the back end service as shown below.


Here we create a copy of the message to consume locally on the broker incase we want to validate some parts of the message or log etc. Ideally the fastest would be to just directly forward it over but application sometimes require all incoming messages to be logged or validated at the entry point of the DMZ.


  1. Loosely Coupling
  2. Potentially can avoid a lot of serialization and deserialization cost. (Encoders need to match for this)
  3. Changes in the backend usually do not require changes in the Broker provided the broker uses generic client contracts.


  1. Synchronous pattern has its overhead and not scalable.
  2. The router has to be of very high capacity to support high loads even though backend machines may block on IO.

Best Practices

  1. Match your encoders – Encoder mismatches can cause a heavy serialization and deserialization on the router. This is because any change between the backend and the frontend encoders on the binding would require re-encoding of the message and hence a full read and write at the encoder layer.
  2. Avoid having to create message copy. If the backend can create the copy/validate you save the routers CPU for more messages per second.
  3. Make sure you use fast message copy  - Buffered messages have a very optimized message copy path that WCF would take provided you haven’t changed parts in the message. I will talk about how to hit this fast path next.


Next – How to Optimize Message Copying using CreateBufferedCopy?