官方的原話:
About Runtime Connection Load Balancing
Runtime Connection Load Balancing is a feature of Oracle connection pools that can distribute client work requests across the instances in an Oracle RAC database based on the Load Balancing Advisory information. The connection allocation is based on the current performance level provided by the database instances as indicated by the Load Balancing Advisory FAN events. This provides load balancing at the transaction level, instead of load balancing at the time of the initial database connection.
With Runtime Connection Load Balancing, applications use Load Balancing Advisory information to provide better performance to users. OCI Session pools and ODP.NET connection pools support Runtime Connection Load Balancing. For Java applications, Oracle recommends the Universal Connection Pool (UCP). The Universal Connection Pool is integrated to take advantage of Load Balancing Advisory information. UCP, introduced in Oracle Database 11g Patchset 1 (11.1.0.7), can be used against Oracle Database 10g or Oracle Database 11g.
You must enable the client data source for Runtime Connection Load Balancing with a service that has the following configuration:
■ The Load Balancing Advisory is enabled and the service-level goal is set to either Service Time or Throughput.
■ The service connection load balancing goal is set to Short.
Figure 7–1, "Runtime Connection Load Balancing" illustrates Runtime Connection Load Balancing. In this illustration, the Oracle RAC database has three instances. Suppose that the Load Balancing Advisory indicates that Instance1 and Instance3 have the best performance, while Instance2 currently has less than optimal performance.
When Runtime Connection Load Balancing is enabled on the implicit connection cache, the following process occurs:
1. A client requests a connection from the connection pool.
2. Runtime Connection Load Balancing selects the connection that belongs to the most efficient (best) instance from the connection pool. In Figure 7–1, there are three possible nodes to which the connection can be routed. Instance1, which has the least amount of CPU workload, is currently being assigned about 60 percent of the incoming connections. Instance2, which is currently overloaded, is only being assigned around 10 percent of the incoming connections. Instance3, which has a high workload, is being assigned around 30 percent of the incoming connections. The best instance to handle the connection request in this case would be Instance1.
3. The client receives the connection that would process the work request with the best response time.
Figure 7–1 Runtime Connection Load Balancing
650) this.width=650;" src="http://www.bkjia.com/uploads/allimg/131229/21245062I-0.png" title="11.png" alt="195426305.png" />
Oracle Database 11g introduces an additional flag in the load balancing advisory event called affinity hint. The affinity hint is automatic when load balancing advisory is turned on through setting the goal on the service. This flag is for temporary affinity that lasts for the duration of a web session. Web conversations often connect and disconnect a number of times during the entire session. During each of these connects, it may access the same or similar data, for example, a shopping cart, Siebel, and so on. Affinity can improve buffer cache efficiency, which lowers cpu usage and transaction latency. The Affinity Hint is a flag that indicates if Affinity is active or inactive for a particular instance and service combination. Different instances offering the same service can have different settings for the Affinity Hint.
Applications using Oracle Database 11g and UCP, can take advantage of this new affinity feature. If the affinity flag is turned on in the Load Balancing Advisory event, then UCP will create an Affinity Context for the Web session such that when that session does a get connection from the pool, the pool will always try to give it a connection to the instance it connected to the first time it acquired a session. The choice of instance for the first connection is based on the current load balancing advisory information.
總結:
其實Runtime Connection Load Balancing是建立在Connection Load Balancing基礎上的,是指從串連池中取得已有串連時的 Connection Load Balancing。
srvctl建立service的時候,需要制定一個參數-BGoal for the Load Balancing Advisory)。
該參數是:運行時負載平衡,Load Balancing Advisory的子參數,支援事務層級(transaction level)的負載平衡,其三個選項:NONE為關閉,其餘兩個參數是SERVICE_TIME(適於長時間交易的事務)和THROUGHPUT(適於短時間交易的事務),其含義在官方文檔中的解釋為:
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 by connections using the service, as well as available bandwidth to the service. This goal is best suited for workloads that require varying lengths of time to complete, for example, an internet shopping system.
THROUGHPUT - The Load Balancing Advisory measures the percentage of the total response time that the CPU consumes for the service. This measures the efficiency of an instance, rather than the response time. This goal is best suited for workloads where each work request completes in a similar amount of time, for example, a trading system.
要啟用運行時負載平衡,另外一個參數 -j <clb_goal> 負載平衡的串連目標要設定為SHORT。
本文出自 “無雙城” 部落格,請務必保留此出處http://929044991.blog.51cto.com/1758347/1298400