Latency and throughput¶
How to get changes to the destination as fast as you need them, and how to apply more of them per second.
Polling and latency¶
How quickly changes reach the destination depends on how the group learns that there are changes. See How incremental groups work.
Use change data notifications for low latency¶
Do: set up change data notifications on the source (a Notification Address the Capture Agent can reach, UDP port 2728 open), and keep the default Poll Interval of 3 minutes as a safety net.
Why: the Capture Agent then tells the Replicator Service as soon as changes are committed, and the group polls right away; polling only catches what a lost notification missed. A very short Poll Interval instead makes every group query the staging database constantly, costing CPU on the Replicator Service's computer and the staging database for little gain.
Not when: the Capture Agent can't reach the Replicator Service's computer (a firewall or NAT that can't be opened). Then shorten the Poll Interval only as much as your latency requirement needs.
Two sources on the same computer need different notification addresses: a listener is bound to the address and port, so the second source's groups silently fall back to polling. See Change data notifications, Change data notifications are not received and Incremental group fails with a 'Bad IP address' error.
Use a fixed schedule to apply at intervals¶
Do: for a group that should apply changes at regular intervals (for example once an hour, or once a day), turn on Use Fixed Schedule and set the Poll Interval to that interval.
Why: without Use Fixed Schedule, every change data notification makes the group poll at once, so a long Poll Interval alone delays nothing. With it, the group ignores notifications and polls only when the interval has passed.
Keep in mind:
- The interval counts from when the group starts polling: when the Replicator Service starts, and when the group is resumed (including after you save its properties); the group polls right away at that moment. To apply at a set time of day, pause the group and resume it at that time with a scheduled script instead (see Pause and resume an incremental group).
- Members waiting for a baseline or an ALTER run make the group check about every 6 minutes (applyMaxAutoSnapshotInterval) until they're done, whatever the Poll Interval.
Remember what the Capture Agent keeps meanwhile¶
Do: size the Capture Agent's staging database for the changes that accumulate between polls, during pauses and while a group is in error, and watch it (see Storage monitor).
Why: after each commit, the Replicator Service acknowledges its position to the Capture Agent, which then prunes the staged changes every subscriber has applied (see Control how staged changes are pruned). Changes no group has applied yet stay, so the staging database grows with:
- a long Poll Interval (a day's changes are kept for a day);
- a paused group, or one that keeps retrying a polling error;
- a group left paused because it's no longer used: delete such groups.
If the staging database fills up, the Storage Monitor can pause the Capture Agent's log readers, and the source's journals or logs grow instead.
Throughput¶
Choose the apply method¶
Use Merge when the destination supports it and throughput matters, keep Batch otherwise, and use Sequence only when destination foreign keys require the original order. See Choosing Batch, Merge or Sequence.
Keep the commit limits at their defaults, then tune¶
Do: start with Row Limit 20000 and Transaction Limit 0. With Merge, consider a larger Row Limit if the destination keeps up and has log space: each merge then handles more rows at once.
Why: the limits decide how much is applied in one destination transaction (see Commit limits). Larger batches are more efficient, especially for Merge, which applies a whole batch per table with one statement, but they take longer to commit and need more log space. A transaction is never split, so a large source transaction is always applied whole.
Not when: each source transaction must be its own destination transaction (set Transaction Limit to 1), or the destination's log space is small (lower Row Limit).
Size Maximum Subscriptions and the connection limits together¶
Do: set the group's Maximum Subscriptions to what the source and destination can take, and keep the source's and destination's Maximum Number of Connections high enough for all the groups and subscriptions that run against them at once (see source and destination options).
Why: Maximum Subscriptions is how many members are baselined at once in a group run and, with Merge, how many tables are merged in parallel, each on its own connections. When a source or destination reaches its Maximum Number of Connections, further requests wait for a free connection (status Waiting on the Connections page) instead of failing, so a limit too low shows up as runs or polls that seem to hang. See also Replications do not run.
Not when: members must finish their baselines in run order: set Maximum Subscriptions to 1.
Index the destination for apply, not for the baseline¶
Do:
- Make sure every destination table has an index on the replication key. The Replicator Service creates one for the tables it creates; create it yourself for a table you create (Use existing table for baseline).
- For large baselines to SQL Server or Oracle destinations that keep their table (not Create every time baseline is Run), tick Allow disable/enable indexes on the group.
Why: every captured update and delete is applied with a WHERE on the key columns. Without an index, each one
scans the table: the most common cause of an incremental group that can't keep up. During a baseline, non-unique
indexes only slow the load: Allow disable/enable indexes disables them before the copy and enables them afterwards.
A table dropped and re-created at every baseline has no indexes to disable. See also
Disabling indexes during a baseline.
Load baselines with the native loader¶
Do: keep Use native-loader function, if available and Truncate table before replication (both defaults) for baselines. For SQL Server destinations, see also Recovery model.
Why: the native loader (such as SQL Server Bulk Copy) is the fastest way to load a table, and TRUNCATE empties a
table without logging each row. See Baseline Replication
Options.
Not when: a baseline fails with an unhelpful native-loader error: switch that subscription to Insert using ODBC for one run to see the database's own error, then switch back.
Commit baselines at intervals¶
Do: keep a non-zero ODBC commit interval and BCP commit interval (defaults 10000 and 20000 rows) in the Group Replication Settings or the service's settings.
Why: 0 commits once, at the end of the table, so a large baseline builds one huge destination transaction, and an interrupted run has no checkpoint to restart from: Allow Checkpoint/Restart records progress only when rows are committed. Committed rows stay at the destination if the run fails.