6Copyright © 2007, Oracle. All rights reserved.
RAC Performance Tuning
Copyright © 2007, Oracle. All rights reserved.6 - 2
Objectives
After completing this lesson, you should be able to:• Determine RAC-specific tuning components• Tune instance recovery in RAC• Determine RAC-specific wait events, global enqueues,
and system statistics• Implement the most common RAC tuning tips• Use the Cluster Database Performance pages• Use the Automatic Workload Repository (AWR) in RAC• Use Automatic Database Diagnostic Monitor (ADDM) in
RAC
Copyright © 2007, Oracle. All rights reserved.6 - 3
CPU and Wait Time Tuning Dimensions
Scalableapplication
Scalableapplication
Possiblyneeds SQL
tuning
Needsinstance/RAC
tuning
CPUtime
Waittime
No gain achievedby adding
CPUs/nodes
Copyright © 2007, Oracle. All rights reserved.6 - 4
RAC-Specific Tuning
• Tune for a single instance first.• Tune for RAC:
– Instance recovery– Interconnect traffic– Point of serialization can be exacerbated
• RAC-reactive tuning tools:– Specific wait events– System and enqueue statistics– Enterprise Manager performance pages– Statspack and AWR reports
• RAC-proactive tuning tools:– AWR snapshots– ADDM reports
Certain combinationsare characteristic of
well-known tuning cases.
Copyright © 2007, Oracle. All rights reserved.6 - 5
RAC and Instance or Crash Recovery
Recovery time
SMONrecovers
thedatabase
Remasterenqueue
resources Remastercache
resources
Build recovery set
LMSrecovers
GRD
Merge failedredo threads
1
2
3
5
Resourceclaim
4 Roll forwardrecovery set
Use informationfor other caches
Copyright © 2007, Oracle. All rights reserved.6 - 7
Instance Recovery and Database Availability
Elapsed time
Dat
abas
e av
aila
bilit
y
None
Partial
Full A
B
C D E
G H
F
1 2 3
4
5
2
Copyright © 2007, Oracle. All rights reserved.6 - 8
Instance Recovery and RAC
Instancecrashes
Instancestarts
Instanceopens
Instance startup+
crash recoveryFAST_START_MTTR_TARGET
Instancecrashes
Instancerecovery
starts
Rollingforward
endsInstancerecovery
…first pass + lock claim
FAST_START_MTTR_TARGET
V$INSTANCE_RECOVERY.ESTD_CLUSTER_AVAILABLE_TIME
Copyright © 2007, Oracle. All rights reserved.6 - 9
Instance Recovery and RAC
• Use parallel instance recovery.• Increase PARALLEL_EXECUTION_MESSAGE_SIZE.• Set PARALLEL_MIN_SERVERS.• Use Async I/O.• Increase the size of the default buffer cache.
Copyright © 2007, Oracle. All rights reserved.6 - 10
Analyzing Cache Fusion Impact in RAC
• The cost of block access and cache coherency is represented by:– Global Cache Services statistics– Global Cache Services wait events
• The response time for Cache Fusion transfers is determined by:– Overhead of the physical interconnect components– IPC protocol– GCS protocol
• The response time is not generally affected by disk I/O factors.
Copyright © 2007, Oracle. All rights reserved.6 - 11
Typical Latencies for RAC Operations
AWR Report Latency Name Lower Bound
Typical Upper Bound
Average time to process cr block request 0.1 1 10Avg global cache cr block receive time (ms) 0.3 4 12
Average time to process current block request 0.1 3 23Avg global cache current block receive time(ms) 0.3 8 30
Copyright © 2007, Oracle. All rights reserved.6 - 12
Wait Events for RAC
• Wait events help to analyze what sessions are waiting for.
• Wait times are attributed to events that reflect the outcome of a request:– Placeholders while waiting– Precise events after waiting
• Global cache waits are summarized in a broader category called Cluster Wait Class.
• These wait events are used in ADDM to enable Cache Fusion diagnostics.
Copyright © 2007, Oracle. All rights reserved.6 - 13
Wait Event Views
V$ACTIVE_SESSION_HISTORY
V$SESSION_EVENT
V$SYSTEM_EVENT
V$SESSION_WAIT_HISTORY
Waits for an event by a session
Last 10 wait eventsfor each active session
Activity of recent active sessions
Total waits for an event
V$SESSION_WAITEvents for which
active sessions are waiting
V$SESSION_WAIT_CLASSWaits for a wait event classby a session
V$SQLSTATSIdentify SQL statements impactedby interconnect latencies
Copyright © 2007, Oracle. All rights reserved.6 - 14
Global Cache Wait Events: Overview
gc [current/cr] [multiblock] request
gc [current/cr] [2/3]-way gc [current/cr] block busy
Just requested(placeholder)
Received after two or three network hops, immediately after request
Received but not sent immediately
gc [current/cr] grant 2-wayNot received and not mastered
locally. Grant received immediately.
gc current grant busyNot received and not mastered
locally. Grant received with delay.
gc [current/cr] [block/grant] congested
Block or grant received with delay because of CPU or memory lack
gc [current/cr] [failure/retry]
Not received because of failure
gc buffer busy
Block arrival time less than buffer pin time
Copyright © 2007, Oracle. All rights reserved.6 - 16
2-way Block Request: Example
SGA1
SGA2
LGWRLGWR:
Log sync
Wait complete:gc current block 2-way
Wait:gc current block request
Direct send
Block transfer
1
2
3
FGP
LMS
Copyright © 2007, Oracle. All rights reserved.6 - 17
3-way Block Request: Example
SGA1
SGA2
LGWR
LMS
FGP
Wait complete:gc current block 3-way
Wait:gc current block request
Directmessage
Block transfer
LMSResource
Master
1 2
3
4
Copyright © 2007, Oracle. All rights reserved.6 - 18
2-way Grant: Example
SGA1
SGA2
FGP
Wait complete:gc current grant 2-way
Wait:gc current block request
Directmessage
Grant message
LMSResource
Master
1
2
3
Copyright © 2007, Oracle. All rights reserved.6 - 19
Global Enqueue Waits: Overview
• Enqueues are synchronous.• Enqueues are global resources in RAC.• The most frequent waits are for:
• The waits may constitute serious serialization points.
TX TM
HW
SQ
US
TA
Copyright © 2007, Oracle. All rights reserved.6 - 20
Session and System Statistics
• Use V$SYSSTAT to characterize the workload.• Use V$SESSTAT to monitor important sessions.• V$SEGMENT_STATISTICS includes RAC statistics.• RAC-relevant statistic groups are:
– Global Cache Service statistics– Global Enqueue Service statistics– Statistics for messages sent
• V$ENQUEUE_STATISTICS determines the enqueue with the highest impact.
• V$INSTANCE_CACHE_TRANSFER breaks down GCS statistics into block classes.
Copyright © 2007, Oracle. All rights reserved.6 - 21
Most Common RAC Tuning Tips
• Application tuning is often the most beneficial.• Resizing and tuning the buffer cache• Reducing long full-table scans in OLTP systems• Using Automatic Segment Space Management• Increasing sequence caches• Using partitioning to reduce interinstance traffic• Avoiding unnecessary parsing• Minimizing locking usage • Removing unselective indexes• Configuring interconnect properly
Copyright © 2007, Oracle. All rights reserved.6 - 23
Index Block Contention: Considerations
RAC01 RAC02
Indexblock
Split inprogress
Wait eventsenq: TX - index contention gc buffer busy
gc current block busy gc current split
System statisticsLeaf node splitsBranch node splits Exchange deadlocks gcs refuse xid gcs ast xid Service ITL waits
Copyright © 2007, Oracle. All rights reserved.6 - 24
Oracle Sequences and Index Contention
Can contain 500 rows
1…50000 50001…100000
CACHE 50000 NOORDER
…
RAC01 RAC02
Copyright © 2007, Oracle. All rights reserved.6 - 25
Undo Block Considerations
SGA2SGA1
…
ChangesReads
Index
Additionalinterconnect traffic
Undo Undo
Copyright © 2007, Oracle. All rights reserved.6 - 26
High-Water Mark Considerations
HWM
Heavyinserts
Heavyinserts
New extent
Wait eventsenq: HW - contentiongc current grant
RAC01 RAC02
Copyright © 2007, Oracle. All rights reserved.6 - 27
Concurrent Cross-Instance Calls: Considerations
SGA1 SGA2
CKPT
Table1
Table2
Table1
Table2
Dirtyblock
CKPT
Truncate Table1 Truncate Table2Cross-instance call
1
23 4
Copyright © 2007, Oracle. All rights reserved.6 - 28
Monitoring RAC Database and Cluster Performance
Directly from Database Control and Grid Control:• Status of each node in the cluster• Aggregated alert messages across all the instances• Review issues that are affecting the entire cluster or
each instance• Monitor cluster cache coherency statistics• Determine if any of the services for the cluster
database are having availability problems• Review any outstanding Clusterware interconnect
alerts
Database
Instances
Copyright © 2007, Oracle. All rights reserved.6 - 29
Cluster Database Performance Page
Copyright © 2007, Oracle. All rights reserved.6 - 30
Determining Cluster Host Load Average
Copyright © 2007, Oracle. All rights reserved.6 - 31
Determining Global Cache Block Access Latency
Copyright © 2007, Oracle. All rights reserved.6 - 32
Determining Average Active Sessions
Copyright © 2007, Oracle. All rights reserved.6 - 33
Determining Database Throughput
Copyright © 2007, Oracle. All rights reserved.6 - 34
Determining Database Throughput
Copyright © 2007, Oracle. All rights reserved.6 - 35
Accessing the Cluster Cache Coherency Page
BlockClass
Segmentname
Segmentname
Copyright © 2007, Oracle. All rights reserved.6 - 36
Accessing the Cluster Cache Coherency Page
Copyright © 2007, Oracle. All rights reserved.6 - 37
Viewing Cluster Interconnects Page
Copyright © 2007, Oracle. All rights reserved.6 - 38
Copyright © 2007, Oracle. All rights reserved.6 - 39
Viewing the Database Locks Page
Copyright © 2007, Oracle. All rights reserved.6 - 40
AWR Snapshots in RAC
SYSAUX
SGA (Instn)
In-memorystatistics
6:00 a.m.
7:00 a.m.
8:00 a.m.9:00 a.m.
9:00 a.m.
SGA (Inst1)
In-memorystatistics
…
MMON Coordinator
MMON
AWR tables
Copyright © 2007, Oracle. All rights reserved.6 - 41
AWR Reports and RAC: Overview
Copyright © 2007, Oracle. All rights reserved.6 - 43
Automatic Database Diagnostic Monitor for RAC
Database ADDM
AWR
Instance ADDM
Self-diagnostic engine
Inst1 Instn
…
Copyright © 2007, Oracle. All rights reserved.6 - 44
• Identifies the most critical performance problems for the entire RAC cluster database
• Runs automatically when taking AWR snapshots• Performs database-wide analysis of:
– Global resources (for example I/O and global locks)– High-load SQL and hot blocks– Global cache interconnect traffic– Network latency issues– Skew in instance response times
• Is used by DBAs to analyze cluster performance• Eliminates need to investigate n reports to spot
common problems
Automatic Database Diagnostic Monitor for RAC
Copyright © 2007, Oracle. All rights reserved.6 - 45
What Does ADDM Diagnose for RAC?
• Latency problems in interconnect• Congestion (identifying top instances affecting the
entire cluster)• Contention (buffer busy, top objects etc.)• Top consumers of multiblock requests• Lost blocks• Information about interconnect devices (warns about
using PUBLIC interfaces)• Throughput of devices: How much of it is used by
Oracle and for what purpose (GC, locks, PQ)
Copyright © 2007, Oracle. All rights reserved.6 - 46
EM Support for ADDM for RAC
Copyright © 2007, Oracle. All rights reserved.6 - 47
Summary
In this lesson, you should have learned how to:• Determine RAC-specific tuning components• Tune instance recovery in RAC• Determine RAC-specific wait events, global enqueues,
and system statistics• Implement the most common RAC tuning tips• Use the Cluster Database Performance pages• Use the Automatic Workload Repository in RAC• Use Automatic Database Diagnostic Monitor in RAC
Copyright © 2007, Oracle. All rights reserved.6 - 48
Practice 6: Overview
This practice covers studying a scalability case by using the ADDM.