Common data: using data in your application
Data issues is a common problem for financial applications: regardless of how much data can be shared and preloaded in the service instances, you still must pass some task-specific data between the IBM® Spectrum Symphony client and service through the IBM Spectrum Symphony task message. In many financial applications, a market data set is shared by more than one task. If you send this market data set through task-specific input messages, the same data is sent more than once across the network. To reduce network traffic, maximize the shared (common) data and minimize the task-specific data.
Common data
If you have input that is common to all tasks within a session, such as data that is required by every service invocation for a given session, you can create a Message object to encapsulate this common data. In this context, the Message object is referred to as common data.Common data represents the state that can be made available to service instances for the duration of a session.
Use common data when you must set up the session-specific state of a service and you only want to do it once per session, not on every task. Common data is useful for passing data from a client to a service. The service loads the data when the session is created.
You can use common data, for example, to set the environment in the service that is common to all tasks in a session. You only need to set the environment once, when the session is created.
Session-to-service instance affinity
IBM Spectrum Symphony attempts to use the same service instance for all tasks in a session as much as possible.A service instance is made available to other sessions only when session workload completes, a session is closed or aborted, or when another more deserving session is assigned the service instance.
Lifetime of common data
You can access the common data in the service during execution of onSessionEnter( ) on the ServiceContainer.The common data object sent from the client can be deleted after the Connection.createSession( ) call returns.
IBM Spectrum Symphony common data retrieval
- Common data updates
- IBM Spectrum Symphony provides
common data updates, which allows a client application to send updates to initial common data after
a session is created. You can send the updates from the client to your service by calling the
update() method on the session object. Access the updated common data in the service by executing
the onSessionUpdate( ) API on the ServiceContainer.
During a session's lifecycle, there can be multiple updates to common data. For newly-started or idle service instances on compute hosts, the host receives both the initial common data and all updates to this common data. For example, in a session with three updates to the common data, IBM Spectrum Symphony uses the initial common data, and all three common data updates to process pending tasks to run workload.
- Common data replacement
- Common data updates can be frequent and data transmission over the network can affect service
performance. To reduce the amount of data transmitted over the network, if you do not require all
common data updates, you can enable common data replacement so that IBM Spectrum Symphony ignores previous updates,
and only uses the initial common data and any common data updates created after setting the
SessionUpdateAttributes.setCommonDataReplacementAttr(true) API.
For example, in a session with three updates to the initial common data, and you submit task A, IBM Spectrum Symphony processes the task using the initial common data, and all three common data updates. Then, if you set the SessionUpdateAttributes.setCommonDataReplacementAttr(true) API method, and submit task B, and there are two additionally common data updates (that is, a fourth and a fifth update), IBM Spectrum Symphony ignores the first, second, and third common data updates, and simply uses the initial common data and the fourth and fifth common data updates.
With common data replacement, when a client application calls the Session.update(SessionUpdateAttributes attributes) API to update the common data, the client application first sends the common data to the SSM. When the service instance executes a new task, or if it is idle within the session, it then pulls the common data updates from the SSM so that the common data updates are immediately available for pending tasks in the session. If you require that these pending tasks not be computed against the common data updates, wait for those tasks to complete before sending your update.