DB2 HADR Performance Tuning: IBM Software Group
DB2 HADR Performance Tuning: IBM Software Group
DB2 HADR Performance Tuning: IBM Software Group
Mar. 2014
Blue Pearl
Format 1
IBM Software Group | Information Management
HADR Overview
Replication is done by log shipping
Whole database is replicated (easy administration)
primary standby
database database
Read only
read/write clients
clients
logs
TCP/IP
connection
2
IBM Software Group | Information Management
Resources
3
IBM Software Group | Information Management
Agenda
Configuration
Monitoring
Diagnostics
4
IBM Software Group | Information Management
TCP Tuning
Recommended TCP window size:
sendRate * roundTripTime
• Consider: bestSendRate * worstRoundTripTime
System default may not be optimal.
Smaller buffer may not make full use of network bandwidth.
5
IBM Software Group | Information Management
6
IBM Software Group | Information Management
Synchronization Modes
SYNC
NEARSYNC
ASYNC
SUPERASYNC
8
IBM Software Group | Information Management
SYNC mode
Transactions on primary will commit only after logs have
been written to disk on both primary and standby.
Write on P
Maximal data protection, with performance cost.
After writing logs to local disk, primary sends a copy to
Send standby. Primary will then wait for “log written” ack
message from standby.
Write on S Serial write and send on primary
In peer state, any transaction committed on primary is
Ack guaranteed to have committed on standby too.
In peer state, if a failover occurs, you will not lose any
committed transaction.
9
IBM Software Group | Information Management
NEARSYNC mode
Transactions on primary will commit only after logs have
been written to disk on primary and received into memory
Send on standby.
Write on P Protection nearly as good as SYNC mode. Performance is
Ack better than SYNC mode.
Write on S When writing logs to local disk, primary also sends a copy
to standby. Primary will then wait for “log received” ack
message from standby.
Parallel write and send on primary
In peer state, you will lose data in a failover only if
standby fails before it writes received log pages locally
(very small window)
10
IBM Software Group | Information Management
ASYNC mode
Transactions on primary will commit only after logs have
been written to local disk and sent to standby
Send Better performance, less data protection.
Write on P When writing logs to local disk, primary also sends a copy
to standby. Primary will go on as soon as send() call to TCP
Write on S returns.
In peer state, any transaction committed on primary is
guaranteed to have been “sent” to standby.
In peer state, if a failover occurs, logs sent but not yet
received can be lost.
11
IBM Software Group | Information Management
SUPERASYNC mode
HADR pair never enters peer state.
State transition stops at remote catchup
Transaction commit on primary has no dependency on log shipping.
Slow network or standby will not slow down primary
But standby can fall behind
Monitor log gap closely.
Failover can lose data in log gap.
Role switch allowed in remote catchup state
Only allowed in peer state in other sync modes.
Check log gap before issuing takeover command
Role switch will stop transactions on primary, ship all logs and finish
replay. No data loss.
Large gap will result in long takeover time
12
IBM Software Group | Information Management
Details at
https://www.ibm.com/developerworks/community/wikis/home?lang
=en#!/wiki/DB2HADR/page/Perf%20Tuning
13
IBM Software Group | Information Management
14
IBM Software Group | Information Management
Configuration Recap
TCP tuning
HADR synchronization mode
Peer wait limit
Standby receive buffer and spool
16
IBM Software Group | Information Management
17
IBM Software Group | Information Management
18
IBM Software Group | Information Management
19
IBM Software Group | Information Management
20
IBM Software Group | Information Management
Earlier releases:
• Or "Log pages written" field from "db2 get snapshot for database"
command
Detailed analysis: DB2 log scanner
https://www.ibm.com/developerworks/community/wikis/home?lang=en#!/wiki/DB2HADR/page
/db2logscan
21
IBM Software Group | Information Management
22
IBM Software Group | Information Management
if (STANDBY_RECV_BLOCKED)
{
this is a slow standby case.
if (STANDBY_LOG_DEVICE_FULL)
standby log device too small. Enlarge it.
else
standby replay is too slow. Tune replay or upgrade hardware.
}
else
{
Most likely a slow network case.
Measure network speed to confirm.
Tune or upgrade network if confirmed.
Or use a less demanding HADR sync mode.
In rare cases, cause is slow standby log write
Measure standby disk speed and log write size to confirm.
Tune or upgrade disk if confirmed.
}
25
IBM Software Group | Information Management
primary
database
26
IBM Software Group | Information Management
27
IBM Software Group | Information Management
The End
Q and A
28