您的位置:首页 > 数据库 > Oracle

Improving Oracle Service Bus Performance by Caching Business Service Results

2010-11-13 21:42 417 查看
If you use business services that return somewhat static results that do not change often, you can configure those business services to cache results. When you enable result caching, the service returns results from cache rather than invoking the external service. This improves performance by reducing network overhead to access the external service. Result caching also helps improve scalability by reducing the load on the back-end servers that host the external service.

In this section, the term "result cache" refers to the cache itself that all business services share to store their respective results, and "cached result" refers to a single result in the result cache.

For business services that use result caching, you can control the time to live for the cached result. After the cached result expires, the next business service call results in invoking the back-end service to get the result. This result is then stored in the cache for future requests to access.

The result caching mechanism that Oracle Service Bus uses is Oracle Coherence. The Oracle Service Bus implementation of result caching includes global enable/disable, cache message variables, configuration fields on each business service, and cache options for service statistics, debugging, alert rules, and smart search.

This section describes the Oracle Service Bus implementation of result caching.

34.7.5.1 How Result Caching Works

Figure 34-1 illustrates a client invoking a business service and receiving a response that contains cached results.

Note:

Result caching works only with request/response operations.

Figure 34-1 Business Service Result Caching



Description of "Figure 34-1 Business Service Result Caching"

Each cached result is uniquely identified by a cache key that is made up of the ServiceRef (the unique identifier for the service which is the fully qualified path name of the service), the operation being invoked, and a cache token String. The cache token helps to uniquely identify a single cache result among other cache results for one business service. You control the value of the cache token. You can set the cache token either by configuring the Cache Token expression in the Result Caching configuration for the business service or by using the cache-token metadata element in the $transportMetaData using the proxy service message flow.

If the business service locates cached results through a cache key, it returns those cached results to the client instead of invoking the external service directly.

In Figure 34-1, the solid arrows represent the message path between the client and a cached result. The dotted arrows show the message path if no cached result exists. If no cached result exists, the business service invokes the external service directly, returns the result to the client, and stores the result in cache. A result cache could be empty for a number of reasons, including a first-time invocation where no cache yet exists, a caching error, or because the cache was flushed.

For cache expiration, cached results have a time-to-live (TTL) attribute. You can configure cache expiration either with the Expiration Time property in the Result Caching configuration on the business service or the cache-ttl element in the $transportMetaData using the proxy service message flow. If Oracle Coherence finds that the TTL has expired, it flushes the cache, and the business service invokes the external service for a result. That result is then stored in the cache (if there is no error in the result), and the result is available in the cache so that it can be returned to the next request.

34.7.5.1.1 Flushing Cached Results
Oracle Service Bus/Coherence can flush an individual cached result, all cached results for a business service, or the entire result cache (all cached results for all Oracle Service Bus business services). The following events illustrate how Oracle Service Bus/Coherence flush cache:

Cache TTL has expired – Each cached result has its own TTL. When a TTL is reached, Oracle Coherence flushes that individual cached result.

Disable result caching on a single business service – When you disable result caching on a business service, Oracle Service Bus triggers flushing of all cached results for that business service in Oracle Coherence.

Update, Rename, or Delete a business service – If you update, rename, or delete a business services, Oracle Service Bus triggers flushing of all cached results for that business service from Oracle Coherence.

Update dependent resource – When you update a dependent resource, such as a WSDL, Oracle Service Bus triggers flushing all cached results for that business service from Oracle Coherence. However, changes to the following dependent resources do not cause cache flushing: Service Provider, UDDI Registry, Alert Destination.

Globally disable result caching – When you globally disable result caching, Oracle Service Bus triggers flushing the entire result cache (all cached results for all business services) from Oracle Coherence.

For more information on working with and configuring result caching, see:

Section 26.2.11, "Enabling Result Caching Globally"

Section 18.1, "Creating and Configuring Business Services"

"Business Service Message Handling Configuration Page" in the Oracle Fusion Middleware Developer's Guide for Oracle Service Bus

34.7.5.2 Result Caching Best Practices

This section describes best practices for using result caching.

34.7.5.2.1 Security Best Practices with Result Caching
Because cached results bypass the security of invoking an external service directly, do not use result caching with business services that provide security with a non-static service account or a WS-Security policy.

34.7.5.3 Result Cache Metadata

Following are the metadata used for result caching:

34.7.5.3.1 Request Metadata
Following are the request metadata used with result caching: cache-token and cache-ttl, both String values. You can configure both in the business service configuration. You can also leave the cache token or TTL undefined in the business service and provide the cache token or TTL in the request with these metadata. When you set the cache token or TTL in the request, those values override any cache token or TTL you have defined in the business service configuration.

For more information, see Section 18.2.23, "Message Handling Configuration Page" for business service configuration.

34.7.5.3.2 Response Metadata
Following are the response metadata used with result caching:

cache-token – Contains the cache token that was used to retrieve content from the result cache or add content to the result cache after invoking the external service.

cache-originated – Contains a boolean value, true or false. A value of true means the returned content came from the result cache. A value of false means the returned value came from invoking the external service.

34.7.5.4 Testing Result Caching

Result caching takes effect only when the business service configured with result caching is invoked (for example, with a Route or Service Callout) from a proxy service. Therefore, in order to test result caching, do not invoke the business service directly from the test console. Instead, use the test console to test the proxy service that invokes the business service.

You can, however, invoke Split-Join business services directly to test result caching.

34.7.5.5 Result Caching Advanced Configuration

In each Oracle Service Bus domain, you can modify how the domain uses Oracle Coherence for business service result caching. This section describes default settings and when you should change them.

34.7.5.5.1 Result Cache Setup and Tuning
You can tune cache schemes for the Oracle Service Bus result cache by modifying DOMAIN_HOME/config/osb/coherence/osb-coherence-cache-config.xml. By default, a distributed cache scheme is used for the Oracle Service Bus result cache. For more information, see "Cache Configuration Elements" in the Oracle Coherence Developer's Guide.

34.7.5.5.2 Coherence Cluster Setup
Oracle Service Bus provides its own default Oracle Coherence configuration for the servers in a domain. The configuration file, located at DOMAIN_HOME/config/osb/coherence/osb-coherence-override.xml, provides different properties that control server access to Oracle Coherence cache.

This section describes the default Oracle Coherence configuration settings for Oracle Service Bus single- and multi-server domains, and describes scenarios in which you need to modify the default settings.

Table 34-7 shows the default values in osb-coherence-override.xml for a single-server domain created with the Oracle Service Bus Single Server Domain template. These settings restrict Oracle Coherence cache access to only the local server. With this configuration, nodes started on different servers do not join the same Oracle Coherence cluster to share cached information.

Table 34-7 osb-coherence-override.xml Default Settings for a Single Server Domain Topology

Server DetailsConfiguration File PropertyDefault Value
Unicast Address

OSB.coherence.localhost

127.0.0.1

Unicast Port

OSB.coherence.localport

7890

Well-Known Address

OSB.coherence.wka

127.0.0.1

Well-Known Port

OSB.coherence.wka.port

7890

Time to Live (TTL)

OSB.coherence.ttl

0 (no cache expiration)

Table 34-8 shows the default values in osb-coherence-override.xml for a multi-server domain created with the Oracle Service Bus All Domain Topologies template. The default values create an Oracle Coherence cluster that is shared by any Oracle WebLogic Server node on the same subnet created from the same template.

Table 34-8 osb-coherence-override.xml Default Settings for an All Domain Topologies Domain

Server DetailsConfiguration File PropertyDefault Value
Unicast Address

OSB.coherence.localhost

127.0.0.1

Unicast Port

OSB.coherence.localport

7890

Multicast Listener Address

OSB.coherence.clusteraddress

228.8.8.8

Multicast Listener Port

OSB.coherence.clusterport

9888

The Multicast Address and Multicast Port properties determine how member nodes of the Oracle Coherence cluster are located. This combination must be unique for each Oracle Coherence cluster that is running within the same subnet.

Note:

Even though the All Domain Topologies template provides a default multicast listener, a best practice is to configure the Oracle Coherence cluster to use a unicast listener with an explicit list of nodes for the Oracle Coherence cluster (using the well-known-addresses element, described in Table 34-7). For more information, see "well-known-addresses" at
http://coherence.oracle.com/display/COH35UG/well-known-addresses
.
The following configurations require manual modification of osb-coherence-override.xml to ensure the desired sharing of an Oracle Coherence cluster among multiple servers:

If you want to switch from a multicast listener to a unicast listener with well-known addresses in a cluster, as described in the previous note.

If you have multiple Oracle WebLogic Server clusters in the same subnet, modify the relevant Oracle Coherence address and port properties to ensure desired sharing of an Oracle Coherence cluster. Do not use the same address and port as those used for the Oracle WebLogic Server cluster.

If you have multiple admin servers with managed servers in the same subnet, modify the relevant Oracle Coherence address and port properties to ensure desired sharing of an Oracle Coherence cluster.

If you have any combination of Oracle WebLogic Server clusters and admin servers with managed servers in the same subnet, modify the relevant Oracle Coherence address and port properties to ensure desired sharing of an Oracle Coherence cluster.

If multiple Oracle Coherence clusters are running in the same subnet, modify the Multicast Address and Multicast Port to specify which Oracle Coherence cluster a node should connect to.

34.7.5.5.3 More Information on Configuring Oracle Coherence
You can perform many other types of cache configuration flexibly, without changing application code, using the Oracle Coherence configuration framework. For example, you can use attributes modify cache type and behavior, and you can query cache. For more information, see the Oracle Coherence Developer's Guide.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: