Beruflich Dokumente
Kultur Dokumente
This is the final instalment of a four part series covering my “top 10” performance strategies for
Oracle databases. In part one, we looked at methodology, database and application design, and
indexing . In part two, we covered the essential tuning tools, the SQL optimizer and strategies for
tuning SQL and PL/SQL. In the third instalment we looked at contention, memory management and
IO optimization.
In this final instalment we’ll consider the performance optimization of Oracle Real Application
Clusters (RAC). RAC is central to Oracle’s grid architecture, and is a significant and important
technological advantage for Oracle. I always advise Oracle DBAs to get familiar with RAC and know
how to get the most of it.
RAC performance optimization is a big topic and I can only provide an introduction in this article.
You can find more information on each in my book Oracle Performance Survival Guide.
RAC architecture
RAC is a shared disk clustered databases: every instance in the cluster has equal access to the
database’s data on disk. This is in contrast to the shared nothing architecture employed by other
RDBMS clusters. In a shared nothing architecture, each instance is responsible for a certain subset
of data. Whenever a session needs that data, then the appropriate instance must be involved in
serving up the data.
The main challenge in the shared disk architecture is to establish a global memory cache across all
the instances in the cluster: otherwise the clustered database becomes IO bound. Oracle
establishes this shared cache via a high-speed private network referred to as the cluster
interconnect.
All the instances in a RAC cluster share access to datafiles on shared disk, though each have private
redo logs and undo segments. Each instance has its own SGA and background processes and each
session that connects to the cluster database connects to a specific instance in the cluster.
RAC will perform well, and scale well, if the following are true:
• The time taken to request a block across the interconnect (Global Cache requests) is much
lower – say ten times less – than the time to retrieve a block from the disk. Global Cache
requests are intended to avoid the necessity of a disk read, and sometimes the disk read
must occur even after the Global Cache request.
• The cluster is well balanced, or at least there are no overloaded instances in the cluster.
Since so many RAC operations involve two or three instances, an overloaded instance might
cause problems for its neighbours as well as itself.
• The overhead incurred through cluster activities is a small proportion of the total database
time. We want our RAC database to be a database first, and a cluster second.
As a rule of thumb, we might expect that cluster-related waits comprise less than 10% of total
database time. Waits above 20% certainly warrant investigation.
Some documents or presentations suggest that Global Cache latency is primarily or exclusively
Interconnect latency: the time it takes to send the block across the interconnect network.
Interconnect latency is certainly an important part of overall Global Cache latency: but it’s not the
only part. Oracle processes such as the Global Cache Service (LMS) have to perform a significant
amount of CPU intensive processing each time a block is transferred, and this CPU time is usually as
least as significant as any other factor in overall Global Cache latency. In certain circumstances non-
CPU operations – such flushing redo entries to disk – will also contribute to Global Cache latency.
To measure Global Cache latency, we use the wait interface as exposed by GV$SYSTEM_EVENT. The
following query reports on average times for each of the Global Cache request types as well as
single-block read time (for comparison):
This example output provides reason for concern. The average wait for Global Cache consistent read
requests (as shown by ‘gc cr block 2-way’ and ‘gc cr block 3-way’) is more than 1 millisecond and
more than 1/10th of the time for a db file sequential read. While the Global Cache is still faster than
disk, it’s taking longer than we’d expect if the interconnect and RAC were fully optimized.
The best way to determine the interconnect contribution to overall performance is to use the ping
utility to measure latency independently of the Oracle stack. Ping packet handling is not identical to
RAC packet handling, but if ping latency is high then you can confidently assume that network
responsiveness is an issue.
In Oracle 10g the view X$KSXPIA shows the private and public IP addresses being used by the current
instance. In Oracle 11g this information is available in the view GV$CLUSTER_INTERCONNECTS. The
following query shows us the private interconnect IP address plus other identifying information for
the current instance (this query must be run as SYS):
We can then ping the IP address from another node in the cluster to determine average latency. On
a Linux system, we can use the “–s 8192” flag to set an 8K packet size so as to align with the block
size of this Oracle database. On Windows the appropriate flag is “-l”:
The ping output above indicates very low latency – about .25 ms - across the interconnect.
Asides from high latencies – as exposed by the ping command - interconnect issues can show up as
“lost” or congested blocks.
There’s a few things we can do at the network level to optimize the interconnect:
High Global Cache latencies can also occur if the remote instance is very busy: often balancing the
cluster (as outlined in the next section) is the solution.
In this example it is clear that MELRAC2 is being subjected to a disproportionate level of CPU load: if
this is not addressed, increasing cluster workload will almost certainly lead to performance
degradation as MELRAC2 becomes the bottleneck for the entire cluster.
Quest Software’s Spotlight on RAC – now available in the Toad DBA Suite RAC edition - probably has
the most advanced RAC balance monitoring. Spotlight on RAC displays cluster balance from a
number of perspectives and performs a statistical analysis to determine if the imbalance is
systematic or due to short term random fluctuations.
There’s a number of techniques that you can try to balance your cluster database. In particular
Services allow you to allocate workloads to specific instances within a cluster, and can be either the
cause and/or cure of cluster imbalances.
• By partitioning certain types of workload to certain instances, we can reduce the amount of
Global Cache traffic, since similar workloads are most likely to utilize similar data blocks.
• Services can help you share a RAC cluster across multiple applications, some of which may
have different service level objectives. By allocating more instances in the cluster to a
specific service, we effectively allocate the service a bigger share of cluster resources.
Oracle also provides client side, server side and application level load balancing facilities that you can
tweak to get better balance of workload across the cluster.
Note how in the above example it’s the least busy instances (in terms of logical reads) that have the
highest Global Cache/Logical request ratio: the less busy an instance is, the more likely that the
blocks it needs are in the memory of another, more busy, instance. If every instance in the cluster is
fighting over the same set of “hot blocks” then we will see very high Global Cache traffic
We can attempt to reduce the amount of inter-instance traffic through one of the following
techniques:
Summary
The most significant difference between a RAC and a single instance database is the use of Global
Cache requests to fetch blocks from other instances in the cluster rather than to read them from
disk. RAC will scale and perform well, providing that: