Caching in Flow services
About Caching
Caching is an optimization feature that can improve the performance of integrations. Service caching operates according to the input signature of the enabled service. When caching is enabled, the service result is stored using the input signature values as the key. If the service defines an output signature, only the fields included in the output signature are cached. However, if there is no defined output signature, the entire pipeline at that specific point is cached.
During subsequent executions of the service with the same input, the cached entry in the service result cache is retrieved. The cached output fields are then merged with the input pipeline and subsequently returned to the client rather than invoking the flow service again.
Caching can significantly improve response time of flow services. For example, flow services that retrieve information from busy data sources such as high-traffic commercial web servers could benefit from caching.
When are Cached Results Returned?
When you enable caching for a flow service, IBM webMethods Integration manages the cached results differently, depending on whether the integration has input parameters. It is recommended that a cached flow service has input parameters.
When a cached flow service has input parameters, at run time IBM webMethods Integration scopes the pipeline down to only the declared input parameters of the flow service. IBM webMethods Integration compares the scoped-down inputs to the previously stored copy of the inputs. If a cached entry exists with input parameters that have the same values, IBM webMethods Integration returns the cached results from the previous invocation.
When a cached flow service does not have input parameters (for example, date/time) and previous results do not exist in the cache, at run time IBM webMethods Integration runs the service and stores the results. When the flow service runs again, IBM webMethods Integration uses the cached copy. In other words, IBM webMethods Integration does not use the run-time pipeline for the current invocation; you will always receive cached results until the cache expires.
Points to Note
-
If a cached integration input signature includes a Document Reference or Document Reference List variable and the referenced document type changes or is modified, you must reset the service cache. If you do not reset it, IBM webMethods Integration uses the old, cached input parameters at run time until such time as the cached results expire. You can reset the cache from the Integrations page.
-
If multiple IBM webMethods Integration servers are available, then the cache is available in all servers and the cache behavior is independent. The caches are not shared between servers. For example, if you have run an integration in Server 1, then Server 1 runs the integration and caches the results. Next time if you have run the same integration with same input values on Server 2, then Server 2 runs the integration and caches the results.
-
The default cache size for IBM webMethods Integration is 10K elements.
-
Cache settings are not stored in version history.
-
Cache settings are not saved when you do the following actions:
- Clone
- Import
- Publish-Deploy You have to manually enable the cache settings.
-
If a tenant is associated with multiple runtime servers, then the cached flow service is run at least once in each server to cache the results in that server. For example, assume a tenant is configured with two runtime servers and a flow service is configured to be cached for an hour. When this flow service is run for every minute, in this case the flow service is listed twice under the Flow services executions table in Monitor for each hour because the flow service must run on both runtime servers at least once to cache the results.
Types of Flow services to Cache
While caching the flow service results can improve performance, not all flow services must be cached. You must never cache the flow services if the cached results might be incorrect for subsequent invocations or if the flow service performs tasks that must be run each time the flow service is invoked. Following are guidelines for you to consider when determining whether to cache the results for a flow service.
Flow services Suited for Caching
- Flow services that require no state information. If a service does not depend on state information from an earlier transaction in the client’s session, you can cache its results.
- Flow services that retrieve data from data sources that are updated infrequently. Flow services whose sources are updated on a daily, weekly, or monthly basis are good for caching.
- Flow services that are invoked frequently with the same set of inputs. If a flow service is frequently invoked by clients using the same input values, it is beneficial to cache the results.
Flow services Not Suited for Caching
-
Flow services that perform required processing. Some flow services contain actions that must be processed each time a client invokes it. For example, if a flow service contains accounting logic to perform charge back and you cache the results, the server does not run the flow service, so the flow service does not perform charge back for the subsequent invocations of the service.
-
Flow services that require state information. Do not cache flow services that require state information from an earlier transaction, particularly information that identifies the client that invoked it. For example, you do not want to cache a flow service that produced a price list for office equipment if the prices in the list vary depending on the client who initially connects to the data source.
-
Flow services that retrieve information from frequently updated sources. If a flow service retrieves data from a data source that is updated frequently, the cached results can become outdated. Do not cache flow services that retrieve information from sources that are updated in real-time or near real-time, such as stock quote systems or transactional databases.
-
Flow services that are invoked with unique inputs. If a flow service manages many unique inputs and very few repeated requests, you gain little by caching the results. You might even degrade server performance by quickly consuming large amounts of memory.
Enabling Caching
-
Open the flow service that you want to cache.
-
Click the ellipsis icon (
) available on the flow service steps page and click Settings from the displayed menu. The Settings dialog box appears.
-
Drag the Enable/disable cache switch to right to enable the cache. The default value is Disabled.
-
Enter the number of minutes that the flow service results must be stored in cache in the Cache expire field. The default value is 15 minutes. The expiration timer begins when the server initially caches the results. The server does not restart the expiration timer each time it retrieves the results from cache. The minimum cache expiration time is one minute.
-
Click Done. The flow service page appears.
-
Save and run the flow service. If the flow service runs successfully, the results are stored in cache. Otherwise, the results are not cached.