Message Sending Latency
The overall latency of the Send(IMessage) method includes all latencies of all operations inside this method.
The following sequence of operations are performed when the Send(IMessage) method is called:
Invocation of the OutboundSessionMessage or OutboundApplicationMessage event (for Message objects only).
Serialization of the outbound message to the raw buffer.
Writing necessary data (message content, timestamp, sequence numbers, etc.) to the session storage. For the File-Based Session Storage, it is a costly operation, and it can take tens of microseconds. For the Asynchronous File-Based Session Storage, it is cheaper, because the actual writing is performed in a separate thread. And lastly, for the Memory-based Session Storage, it is a very cheap operation, because data is stored only in the memory.
Invocation of the MessageSending event.
Invocation of the system
send(..)
function. In practice, the latency of the system send function can be about 5-10 microseconds (depends on the size of send data, network workload, network software/hardware, etc.)If the system
send(..)
function fails, then the serialized raw buffer is stored in the sending queue to be processed later.
The latency of the Send(IMessage) method (as any other function) depends on the usage frequency. When you call this method infrequently, the method code and associated data structures will be absent in the processor cache, and this can significantly increase the function latency. If you call the method frequently, then you can avoid cache misses and keep the method path fast.