我對Load Balancing Advisory的理解

xulongxc發表於2015-07-03

相當長的一段時間對Load Balancing Advisory都理解不好,尤其對下面一段話理解不好,其實要了解這部分內容,需要對services的概念深入理解:

  • Service Time—The Load Balancing Advisory attempts to direct work requests to instances according to their response time. Load Balancing Advisory data is based on the elapsed time for work done in the service as well as available bandwidth to the service.

  • Throughput—The Load Balancing Advisory measures the percentage of the total response time that the CPU consumes for the service. This goal measures the efficiency of an instance, rather than the response time.

其實在listener路由connection的時侯oracle始終會參考檢視gv$servicemetric的內容

上面提到的Service Time對應的就是gv$servicemetric裡面的ELAPSEDPERCALL或者DBTIMEPERCALL,他們2個表示的意思一樣,只不過從10g開始,使用DBTIMEPERCALL,DBTIMEPERCALL也就是我們在10g awr中提到的db time;Throughput表示的就是gv$servicemetric裡面的CPUPERCALL/DBTIMEPERCALL的,listener在路由connection的時侯會比較每個例項上的services的對應的DBTIMEPERCALL或者CPUPERCALL/DBTIMEPERCALL,到底比較什麼,取決於我們給這個services指定的GOAL值是什麼,可以透過dbms_services來修改services的GOAL值。

不管GOAL的值設定的是什麼,最終Service Time和Throughput是透過gv$servicemetric裡面的欄位GOODNESS體現出來的,doc對GOODNESS的解釋:Indicates how attractive a given instance is with respect to processing the workload that is presented to the service. A lower number is better. This number is internally computed based on the GOAL (LONG or SHORT) that is specified for the particular service.

貌似GOODNESS越小越好,GOODNESS小似乎代表的是這個例項下的這個services的負載輕,listener路由connection的時侯會優先使用這個services對應的例項,當然能否連線上還和欄位FLAGS的值有關,FLAGS的值如下:

  • 0x01 - service is BLOCKED from accepting new connections

  • 0x02 - service is VIOLATING the set threshold on some metric

  • 0x04 - goodness is UNKNOWN

[@more@]

Enabling the Load Balancing Advisory

The Load Balancing Advisory provides information to applications or clients about the current service levels that the Oracle RAC database instances are providing. The Load Balancing Advisory makes recommendations to applications about which instance to direct application requests for a database service to obtain the best performance based on the policy that you have defined for that service.

When the Load Balancing Advisory is enabled, it will account for the following when balancing connection requests across instances:

  • Server power differences

  • Sessions that are blocked or waiting

  • Failures that slow down processing

Using the Load Balancing Advisory prevents sending work to Oracle RAC instances that are overworked, not responding, or not available.

The Load Balancing Advisory informs the application or client about the current performance level that an Oracle RAC database instance is providing for a service. The Load Balancing Advisory also recommends how much of the workload should be sent to that instance.

The best way to take advantage of the Load Balancing Advisory is to use an integrated Oracle client, one that has the Runtime Connection Load Balancing feature. Integrated Oracle clients subscribe to the Load Balancing Advisory FAN events.

You configure your Oracle RAC environment to use the Load Balancing Advisory by defining service-level goals for each service used. This enables the Load Balancing Advisory for that service and enables the publication of FAN load balancing events. There are two types of service-level goals for Runtime Connection Load Balancing:

  • Service Time—The Load Balancing Advisory attempts to direct work requests to instances according to their response time. Load Balancing Advisory data is based on the elapsed time for work done in the service as well as available bandwidth to the service.

  • Throughput—The Load Balancing Advisory measures the percentage of the total response time that the CPU consumes for the service. This goal measures the efficiency of an instance, rather than the response time.

If you do not select the Enable Load Balancing Advisory option, the service-level goal is set to None, which disables load balancing for the service.

About Connection Load Balancing

Oracle Net is a software component that resides on the client and on the Oracle database server. It establishes and maintains the connection between the client application and the server, and exchanges messages between them using industry standard protocols. For the client application and a database to communicate, the client application must specify location details for the database it wants to connect to, and the database must provide some sort of identification or address.On the database server, the Oracle Net Listener, commonly known as the Listener, is a process that listens for client connection requests. The configuration file for the Listener is the listener.ora.The client uses a connect descriptor to specify the database to which to connect. This connect descriptor contains a protocol and a database service name. When a client requests a connection, the Listener on the server receives the request and forwards the connection to the Oracle database. You can define your connect descriptors in the tnsnames.ora file on the client machine, or include them as part of the connection request.When the client connects to the cluster database using a service, you can use the Oracle Net connection load balancing feature to spread user connections across all of the instances that are supporting that service. There are two types of load balancing that you can implement: client-side and server-side load balancing.In an Oracle RAC database, client connections should use both types of connection load balancing. When you create an Oracle RAC database using Oracle Database Configuration Assistant (DBCA), DBCA configures and enables server-side load balancing by default.

See Also:

for more information about Oracle Net configuration

Client-Side Load Balancing

Client-side load balancing balances the connection requests across the Listeners. When the Listener receives the connection request, the Listener connects the user to an instance that the Listener knows provides the requested service.

Client-side load balancing is defined in your client connection definition by setting the parameter LOAD_BALANCE=yes in the tnsnames.ora file. When you set this parameter to yes, the Oracle client randomly selects an address from the address list, and connects to that node's Listener. This balances client connections across the available Listeners in the cluster.

When you create an Oracle RAC database with DBCA, it creates a sample client-side load balancing connection definition in the tnsnames.ora file on the server.

Client-side load balancing includes connection failover. With connection failover, if an error is returned from the chosen address, Oracle Net Services will try the next address in the address list until either a successful connection is made or it has exhausted all the addresses in the list.

Server-Side Load Balancing

With server-side load balancing, the Listener directs a connection request to the best instance currently providing the service by using information from the Load Balancing Advisory.

For each service, you can define the method that you want the Listener to use for load balancing by setting the connection load balancing goal. You can use a goal of either long or short for connection load balancing. These goals have the following characteristics:

  • Short—Connections are distributed across instances based on the elapsed time under the service. Use the Short connection load balancing goal for applications that have connections of small duration.

  • Long—Connections are distributed across instances based on the number of sessions per instance, for each instance that supports the service. Use the Long connection load balancing goal for applications that have connections of long duration. This is typical for connection pools and SQL*Forms sessions. Long is the default connection load balancing goal.

Any services created by using DBCA use the Long connection load balancing goal by default.

Note:

If you did not use DBCA to create your database, or if you are using Listener ports other than the default of 1521, then you must configure the LOCAL_LISTENER and REMOTE_LISTENER database initialization parameters for your cluster database.

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29440247/viewspace-1721345/,如需轉載,請註明出處,否則將追究法律責任。

相關文章