• Hi Clifton,

    With Service Broker, there are areas that can have a negative performance impact and can be tuned with few additional considerations.

    WAITFOR clause:

    Without WAITFOR, the RECEIVE and GET CONVERSATION GROUP statements return immediately when there are no messages available on the queue. Depending on the implementation, the procedure may loop back through the statements or procedure may exit only to be reactivated. Both of this would consume more resources than simply continuing to run.

    If an application runs continuously as a background service, do not specify a time-out in the WAITFOR statement. This handles unpredictable intervals beetween messages. If an application is activated by Service Broker, or runs as a scheduled job, specify a short time-out, for example, 500 milliseconds. Thus, an activated application that exits after a short time-out does not consume resources when there are no messages to process.

    Conversation group:

    Process multiple messages for a conversation group in the same transaction. However, only process messages for a single conversation group in a given transaction. This helps ensure that more than one instance of the application can process messages, even when the number of conversation groups is relatively small.

    Message retention:

    Avoid using message retention. Maintaining a separate log table that saves the most important information from a message improves performance.

    End conversations:

    End conversations when the task completes. Service Broker maintains state for each conversation. Although the amount of state for a particular conversation is small, an application that does not end conversations may suffer reduced performance over time.

    Transaction duration:

    Keep transactions short. For example, if the conversation pattern for the service involves a large number of messages on the same conversation group, limiting the number of messages processed in each transaction may improve overall throughput.

    The overall performance of the Service Broker is determined by two factors that can be monitored

    i) The number of messages arriving within a specified period of time

    ii) The speed with which the application processes each message.

    HTH.


    Regards,
    Sachin Dedhia