Oracle9i Performance Tuning Chapter 11 Advanced Tuning Topics

Embed Size (px)

DESCRIPTION

Chapter 11: Advanced Tuning Topics3 Dedicated Server Mode Dedicated server mode is the default mode and it is most commonly used It is an Oracle server process dedicated to serving requests for one specific user connection and session

Citation preview

Oracle9i Performance Tuning Chapter 11 Advanced Tuning Topics Chapter 11: Advanced Tuning Topics2 Chapter Objectives Learn how to configure and monitor shared servers Understand distributed transactions Set up replications and use materialized views Understand the concept of Oracle Real Application Clusters Chapter 11: Advanced Tuning Topics3 Dedicated Server Mode Dedicated server mode is the default mode and it is most commonly used It is an Oracle server process dedicated to serving requests for one specific user connection and session Chapter 11: Advanced Tuning Topics4 Dedicated Server Mode (continued) Chapter 11: Advanced Tuning Topics5 Dedicated Server Process 1.Client initiates a request to connect to the database; listener process picks up the request 2.Listener process creates a dedicated server for the client 3.Listener process tells the client the memory address of the dedicated server assigned to it 4.Client connects to the dedicated server and submits requests to the database through the dedicated server; the dedicated server responds to the users requests 5.Dedicated server works on the request 6.Dedicated server sends back results to client Chapter 11: Advanced Tuning Topics6 Dedicated Server Process (continued) Chapter 11: Advanced Tuning Topics7 Dedicated Server Analogy Chapter 11: Advanced Tuning Topics8 Shared Server Mode A shared server process is shared among all user connections connecting in this mode A shared server process receives and responds to all requests submitted by the users Chapter 11: Advanced Tuning Topics9 Shared Server Mode (continued) Chapter 11: Advanced Tuning Topics10 Shared Server Architecture Dispatcher layer: This layer comprises one or many dispatcher processes acting as an interface between the user and Oracle Each dispatcher process also controls server processes and assigns to them requests submitted by users Server layer: This layer comprises many server processes Each server process handles the user requests assigned by the dispatcher Queue layer: This layer is a data structure that keeps a queue of requests and responses Chapter 11: Advanced Tuning Topics11 Shared Server Architecture (continued) Chapter 11: Advanced Tuning Topics12 Shared Server Process 1. Client initiates a request to connect to the database; listener process picks up the request 2. Listener process tells the client the memory address of the shared server 3. Client connects to the dispatcher 4. Client submits requests to the database via the dispatcher process 5. Dispatcher process places the request in a queue for the server process to handle it 6. Server process picks up the request from the queue to process it 7. Server process works on the request until it is completed 8. Server process places the results of the request in a response queue 9. Dispatcher picks up the result of the request from the response queue 10. Dispatcher sends the results of the request to client Chapter 11: Advanced Tuning Topics13 Shared Server Process (continued) Chapter 11: Advanced Tuning Topics14 Shared Server Analogy Chapter 11: Advanced Tuning Topics15 Shared Server Client Configuration Chapter 11: Advanced Tuning Topics16 Shared Server Server Side Setup The following is a list of all required parameters for shared server mode configuration: DISPATCHERS: sets the number of dispatcher processes to be initiated for the database (formerly known as MTS_DISPATCHERS) MAX_DISPATCHERS: tells Oracle the maximum number of dispatcher processes that can be run concurrently (formerly known as MTS_MAX_DISPATCHERS) SHARED_SERVERS: sets the number of server processes to be initiated (formerly known as MTS_SERVERS) Chapter 11: Advanced Tuning Topics17 Shared Server Server Side Setup (continued) MAX_SHARED_SERVERS: tells Oracle the maximum number of servers that can be run concurrently (formerly known as MTS_MAX_SERVERS) CIRCUITS: indicates the total number of virtual circuits for inbound and outbound network connections (formerly known as MTS_CIRCUITS); each connection is a circuit SHARED_SERVER_SESSIONS: indicates the total number of sessions allowed using shared servers (formerly known as MTS_SERVERS) Chapter 11: Advanced Tuning Topics18 Shared Server Server Side Setup (continued) Chapter 11: Advanced Tuning Topics19 Shared Server Server Side Setup (continued) Chapter 11: Advanced Tuning Topics20 Shared Server Performance Views Chapter 11: Advanced Tuning Topics21V$CIRCUIT Chapter 11: Advanced Tuning Topics22V$DISPATCHER Chapter 11: Advanced Tuning Topics23 Using V$DISPATCHER_RATE The 66 columns of this view are classified into the four categories listed here: CUR_ : Current statistics column MAX_ : Maximum statistics value that is ever reached for this column AVG_ : Historical average value for this column TTL_ : Time To Live; this is a statistic value for the most recent time interval SCALE_ : Scale values for the TTL_ columns Chapter 11: Advanced Tuning Topics24 Using V$QUEUE Chapter 11: Advanced Tuning Topics25 Using V$SHARED_SERVER Chapter 11: Advanced Tuning Topics26 Using V$SHARED_SERVER_MONITOR Chapter 11: Advanced Tuning Topics27 Advantages of Shared Servers The following are some advantages of shared servers: They work very well with a large pool of connections to the database Resources used by shared servers are well balanced, which means there is no waste of resources if some user connections are inactive; in that case, resources will be used by the active connections They scale down or up depending on the connections load They enable you to use both dedicated server mode and shared server mode They are well suited for Web applications in which there is a high percentage of connections and disconnections; shared servers have less time overhead than dedicated servers Chapter 11: Advanced Tuning Topics28 Advantages of Shared Servers (continued) The following are some advantages of shared servers: Connections are not rejected because resources are lacking; shared servers can be configured to set a limit on the number of allowed connections They work very well with Oracle Connection Manager for connection pooling They allow users to share dispatcher and server processes They use less memory than dedicated servers, especially if user connections are not active Chapter 11: Advanced Tuning Topics29 Disadvantages of Shared Servers The following are some disadvantages of shared servers: Unlike dedicated servers, shared servers require DBA setup and configuration time and effort DBAs are required to monitor the performance of the shared servers Shared servers may not perform for all types of applications and sessions DBAs must connect to shared servers using dedicated server mode Tracing sessions using SQL Trace are not possible They are not suitable if you are already using middleware to handle user connections Chapter 11: Advanced Tuning Topics30 Distributed Transactions Overview A distributed transaction comprises one or more DML statements executed on more than one database as one single transaction Oracle supports a mechanism called two-phase commit This mechanism ensures that data changes by distributed transactions are committed in all databases Chapter 11: Advanced Tuning Topics31 Distributed Transactions Overview (continued) The two-phase commit has the following phases: Preparation phase: In this phase, the main database (local) informs all databases to prepare for a commit This includes recording information about the transaction in the redo log and locking modified data Commit phase: In this phase, the main database tells all involved databases to commit the changes After the databases commit changes, they notify the main database whether the commit failed or succeeded Once all the databases have notified the main database that the commit is completed, changes in the main database are committed Chapter 11: Advanced Tuning Topics32 Distributed Transactions Using Database Links Chapter 11: Advanced Tuning Topics33 DATABASE LINK Options SHARED option: tells Oracle to create a database link that can be shared among multiple users PUBLIC option: tells Oracle to allow all users to use the database link CONNECT TO CURRENT_USER (authentication method #1 known as CURRENT-USER): tells Oracle to use the current user for authentication to the database youre trying to link to CONNECT TO user IDENTIFIED BY password (authentication method #2 known as FIXED-USER): tells Oracle to use the user and password provided in this clause for authentication to the database you are trying to link to AUTHENTICATE BY (authentication method #3 known as CONNECTED-USER): tells Oracle to use the credentials of the connected user who has an existing account in the database you are trying to link to USING connect_string: tells Oracle the TNSNAME (service name) to use to connect to the database you are trying to link to Chapter 11: Advanced Tuning Topics34 DATABASE LINK Performance Issues The following is a list of parameters that influence performance for the DATABASE LINK: dblink_encrypt_login: tells Oracle whether to use encryption when connecting to other databases distributed_lock_timeout: the amount of time in seconds to wait to obtain a lock on a desired resource open_links: total number of open links per session open_links_per_instance: total number of open links per session Chapter 11: Advanced Tuning Topics35 Replication Architecture Replication is the process of copying and maintaining changes to data objects As the changes occur on the primary database, they are applied to the secondary database Chapter 11: Advanced Tuning Topics36 Replication Architecture (continued) Chapter 11: Advanced Tuning Topics37 Supported Objects for Replication Oracle supports the replication of the following objects: Indexes: enable fast access to data stored in tables Indextypes: enable the creation of new indexing schemes Packages and package bodies: enable developers to package procedures, functions, and data variables within one object Procedures and functions: enable users to write code in modules to perform a specific task or function Synonyms: enable database object aliasing Chapter 11: Advanced Tuning Topics38 Supported Objects for Replication (continued) Tables: represent the most common and the main database objects used to store data Triggers: enable users to write code to be invoked when an event occurs User-defined operators: enable developers and administrators to define their own operators to perform a specific operation User-defined types and type bodies: allow developers to create their own user-defined data types and data objects Views and object views: simplify complicated queries and limit the scope of what data users can see Chapter 11: Advanced Tuning Topics39 Benefits of Replication The following are some benefits of replication: Data availability: Replication offers another layer of ensuring data availability and access in case of failure in the master site Data can still be accessible through the replica site Data synchronization: Oracle replication provides a reliable means of ensuring that data is synchronized between replicated databases Development effort: Replication is a function of Oracle that has been proven to be a robust feature Developers or database administrators need not develop any code to replicate data Performance: Oracle has invested resources to ensure that the process of replication is fast and reliable, provided the network connection between databases is reliable and has a high bandwidth and that the replicated databases are geographically adjacent to each other Chapter 11: Advanced Tuning Topics40 Replication Methods Asynchronous replication is also known as store-and- forward replication Data changes on the master site will be stored in the database first and then periodically at a set time, the changes will be forwarded to all replica sites Synchronous replication is also known as real-time- replication Synchronous replication acts like a single transaction: any data changes on the master site will not be stored until changes are stored on all replica sites Chapter 11: Advanced Tuning Topics41 Types of Replication Multimaster Single-Master Chapter 11: Advanced Tuning Topics42 Materialized-view Replication There are two types of materialized-view replication: Read-only materialized-view replication: In this type, data is replicated through the use of a materialized view which is in read-only mode Data cannot be updated through the materialized view, only through the table in the master site Updatable materialized-view replication: With this type of replication, data is replicated from the master site using a materialized view Any changes on the replica site are synchronized and refreshed with the master site Users can update data directly to the master or replica site Chapter 11: Advanced Tuning Topics43 Hybrid Replication Hybrid replication combines multimaster replication and materialized-view replication Chapter 11: Advanced Tuning Topics44 Diagnosing Replication Performance When you diagnose replication problems, make sure that: The underlying database link is working (you should be able to connect to the remote database from the local database) The scheduled interval value provided for the START WITH clause in the CREATE statement is valid The scheduled interval for refreshing is longer than the execution time to refresh the data The network connection between the two databases is stable The maximum number of open links has not been reached for the replica site You have enough storage for both the MATERIALIZED VIEW and MATERIALIZED VIEW LOG Chapter 11: Advanced Tuning Topics45 Real Application Cluster The Oracle Real Application Cluster is an architecture in which multiple Oracle instances access and work on one shared Oracle database Chapter 11: Advanced Tuning Topics46 RAC Characteristics Oracle9i RAC provides the following benefits: High availability: Database downtime is decreased Scalability: Oracle instance(s) and database can scale-up or scale-down depending on business growth Increased performance and throughput: RAC takes advantage of hardware resources to improve performance and efficiency Failover mechanism: RAC supports the Oracle Data Guard feature that facilitates the failover to another instance and database in case of failure Manageability: Once it is configured and implemented, there is little need for tuning Oracle9i RAC disadvantages include the following: Hardware: RAC requires more hardware resources than the normal setup of Oracle instance, specifically CPUs and memory resources Expertise: Configuring and implementing RAC requires expertise Chapter 11: Advanced Tuning Topics47Summary Dedicated servers are more widely used than shared servers and are the default Oracle configuration A client connected to an Oracle instance using dedicated server mode is served by a dedicated process A shared server is a process shared among all users connecting in this mode A shared server is composed of three layers that interact with each other: dispatcher, server, and queue structure Configuring the database in shared server mode requires setting parameters in the INIT.ORA file on the database side and the service name in the TNSNAMES.ORA file on the client side Types of replication include the following: multimaster replication, single-master replication, materialized-view replication, and hybrid replication