"Stuffing" Packets with net.tcp and net.pipe

One performance tuning knob you can use over Indigo’s TCP and Named Pipe transports is our level of batching messages. Sockets programmers may be familiar with this concept as Nagle’s algorithm.

In brief, you can make the tradeoff between latency and maximizing packet usage by setting 3 knobs:

  1. IContextChannel.AllowOutputBatching (or message.Properties.AllowOutputBatching at the Channel layer)
  2. bindingElement.MaxOutputDelay
  3. bindingElement.ConnectionBufferSize

When you set AllowOutputBatching=true, you are saying “hold on to this message in a local buffer to send out with other serialized messages if possible”. ConnectionBufferSize determines the size of the this local buffer (as well as the buffer sizes used by the underlying network objects). MaxOutputDelay specifies the maximum amount of time that we will wait for more data to package with a batched message. The default value of MaxOutputDelay is 200 milliseconds.

One last note: when using the typed programming model, these values only affect OneWay methods. For request-reply, ServiceModel will always optimize for latency and will set AllowOutputBatching = false.

Leave a Reply

Your email address will not be published. Required fields are marked *