Collection Contents Index Running the Message Agent Encoding and compressing messages pdf/chap10.pdf

Data Replication with SQL Remote
   PART 3. SQL Remote Administration
     CHAPTER 10. SQL Remote Administration       

Tuning Message Agent performance


Who needs to read this section?     If performance is not a problem at your site, you do not need to read this section.

There are several options you can use to tune the performance of the Message Agent. This section describes those options.

Sending messages and receiving messages are two separate processes. The major performance issues for these two processes are different.

Top of page  Tuning throughput by controlling Message Agent threading

It is assumed in this section that you are tuning the performance of a Message Agent that is running in continuous mode at a consolidated site.

Worker threads can be used by the Message Agent to apply incoming messages from remote users. This can improve throughput by allowing messages to be applied in parallel rather than serially.

Setting the number of worker threads 

The number of worker threads is set on the Message Agent command line, using the -w switch. The following command line starts the Message Agent for Adaptive Server Enterprise with twenty worker threads applying messages:

ssremote -c "eng=..." -w 20

The default is to use no worker threads, so that all messages are applied serially. The maximum number of worker threads is 50.

Performance benefits from worker threads 

For the Message Agent for Adaptive Server Anywhere, the performance advantage will be most significant when the server is on a system with a striped drive array.

For Adaptive Server Enterprise, the Message Agent will benefit even more if the Server is used with multiple engines configured.

What messages are applied in parallel 

When worker threads are being used, messages from different remote users are applied in parallel. Messages from a single remote user are applied serially. For example, ten messages from a single remote user will be applied by a single worker thread in the correct order.

Deadlock is handled by re-applying the rolled back transaction at a later time.

Reading messages from the message system is single-threaded. Messages are read and the header information is examined (to determine the remote user and the correct order of application) before passing them off to worker threads to be applied.

Building messages and sending messages is single-threaded.

Open Client version 

To use multiple worker threads with the Adaptive Server Enterprise Message Agent, you need to be using Open Client version 11.1 or above.

The Message Agent prints a message and then does not use worker threads when pre-11.1 versions are being used. The Open Client version is displayed in the first few lines of the Message Agent output.

Top of page  Tuning throughput by caching messages

The Message Agent caches incoming messages in a configurable area of memory as it reads them.

Specifying the message cache size 

The size of the message cache is specified on the Message Agent command line, using the -m command-line switch.

The -m option specifies the maximum amount of memory to be used by the Message Agent for building messages. The allowed size can be specified as n (in bytes), nK, or nM. The default is 2048K (2M).

Example 

The following command line starts an Adaptive Server Anywhere Message Agent using twelve Megabytes of memory as a message cache:

dbremote -c "eng=..." -m 12M

How messages are cached 

When transactions are large, or messages arrive out of order, they are stored in memory by the Message Agent until the message is to be applied. This caching of messages prevents rereading of out-of-order messages from the message system , which may lower performance on large installations. It is especially important when messages are being read over a WAN (such as Remote Access Services or POP3 through a modem). It also avoids contention between worker threads reading messages (a single threaded task) because the message contents are cached.

When the memory usage specified using the -m switch is exceeded, messages are flushed in a least-recently-used fashion.

This switch is provided primarily for customers considering a single consolidated database for thousands of remote databases.

Top of page  Tuning incoming message polling

When running a Message Agent in continuous mode, typically at a consolidated database site, you can control how often it polls for incoming messages, and how "patient" it is in waiting for messages that arrive out of order before requesting that the message be resent. Tuning these aspects of the behavior can have a significant effect on performance in some circumstances.

Issues to consider 

The issues to consider when tuning the message-receiving process are similar to those when tuning the message-sending process.

For Info     For more information on the message sending process, see Tuning the message sending process.

Top of page  Polling interval

By default, a Message Agent running in continuous mode polls one minute after finishing the previous poll, to see whether new messages have arrived. You can configure the polling interval using the -rd command-line option.

The default polling interval from the end of one poll to the start of another is one minute. You can poll more frequently using a value in seconds, as in the following command line:

dbremote -rd 30s

Alternatively, you can poll less frequently, as in the following command line, which polls every five minutes:

dbremote -rd 5

Setting a very small interval may have some detrimental impact on overall system throughput, for the following reasons:

In general, you should not use a very small polling interval unless you have a specific reason for requiring a very quick response time for messages.

Setting larger intervals may provide a better overall throughput of messages in your system, at the cost of waiting somewhat longer for each message to be applied. In many SQL Remote installations, optimizing turnaround time is not the primary concern.

Top of page  Requesting resends

If, when the Message Agent polls for incoming messages, one message is missing from a sequence, the Message Agent does not immediately request that the message be resent. Instead, it has a default patience of one poll.

If the next message expected is number 6 and message 7 is found, the Message Agent takes no action until the next poll. Then, if no new message for that user is found, it issues a resend request.

You can change the number of polls for which the Message Agent waits before sending a request using the -rp command-line option. This option is often used in conjunction with the -rd option that sets the polling interval.

For example, if you have a very small polling interval, and a message system that does not preserver the order in which messages arrive, it may be very common for out-of-sync messages to arrive only after two or three polls have been completed. In such a case, you should instruct the Message Agent to be more patient before sending a resend request, by increasing the -rp value. If you do not do this, a large number of unnecessary resend requests may be sent.

Top of page  Example

Suppose there are two remote users, named user1 and user2, and suppose the Message Agent command line is as follows:

dbremote -rd 30s -rp 3

In the following sequence of operations, messages are marked as userX.n so that user1.5 is the fifth message from user1. The Message Agent expects messages to start at number 1 for both users.

At time 0 seconds:

  1. The Message Agent reads user1.1, user2.4

  2. The Message Agent applies user1.1

  3. The Message Agent patience is now user1: N/A, user2: 3, as an out of sequence message has arrived from user 2.

At time 30 seconds:

  1. The Message Agent reads: no new messages

  2. The Message Agent applies: none

  3. The Message Agent patience is now user1: N/A, user2: 2

At time 60 seconds:

  1. The Message Agent reads: user1.3

  2. The Message Agent applies: no new messages

  3. The Message Agent patience: user1: 3, user2: 1

At time 90 seconds:

  1. The Message Agent reads: user1.4

  2. The Message Agent applies: none

  3. The Message Agent patience user1: 3, user2: 0

  4. The Message Agent issues resend to user2.

When a user receives a new message, it resets the Message Agent patience even if that message is not the one expected.

Top of page  Tuning the message sending process

The turnaround time for replication is governed by how often each sites sends messages and how often each site polls for incoming messages. To achieve a small time lag between data entry and data replication, you can set a small value for the -sd Message Agent command-line option, which controls the frequency for polling to see if more data needs to be sent.

Issues to consider 

The issues to consider when tuning the message-sending process are similar to those when tuning the incoming-message polling frequency:

For Info     For more information on tuning polling for the incoming-messages, see Tuning incoming message polling.

Top of page  Polling interval

You control the interval to wait between polls for more data from the transaction log to send using the -sd command-line option, which has a default of one minute. The following example sets the polling interval to 30 seconds:

dbremote -sd 30s ...

Alternatively, you can poll less frequently, as in the following command line, which polls every five minutes:

dbremote -sd 5

Setting a very small interval may have some detrimental impact on overall system throughput, for the following reasons:

Setting larger intervals may provide a better overall throughput of messages in your system, at the cost of waiting somewhat longer for each message to be applied. In many SQL Remote installations, optimizing turnaround time is not the primary concern.

Top of page  Resending messages

When a user requests that a message be resent, the message has to be retrieved from early in the transaction log. Going back in the transaction log to retrieve this message and send it causes the Message Agent to interrupt the regular sending process. If you are tuning your SQL Remote installation for optimum performance, you must balance the urgency of sending requests for resent messages with the priority of processing regular messages.

The -ru command-line option controls the urgency of the resend requests. The value for the parameter is a time in minutes (or in other units if you add s or h to the end of the number), with a default of zero.

To help the Message Agent delay processing resend requests until more have arrived before interrupting the regular message sending activity, set this option to a longer time.

The following command line waits one hour until processing a resend request.

dbremote -ru 1h ...
Top of page  

Collection Contents Index Running the Message Agent Encoding and compressing messages pdf/chap10.pdf