Data caching for dashboard components

For specific dashboard components it is possible to cache the data, which is loaded from the data source and then presented to the dashboard user. This is particularly useful when the query (=Entity Report) behind the data source is very complex and time consuming. When using the data cache, the data is only loaded once from the data source and the result is stored in the cache. For further presentations of the same dashboard component the cached data source result is used, which is then very fast.

Currently this feature is available for the Bar Chart, Pie Chart and Channel Status component.

In Product 360 Server the "ehcache" third-party library is used for caching (see https://www.ehcache.org/). The data cache for dashboard components is a cache instance of "ehcache". A cache element within this cache equals to an entity item list of one dashboard component instance of one dashboard. A new cache element is also created if the already cached entity item list was loaded by a user with a different ACL combination than the current user, because then the content of the entity item list might differ. For different data source parameter combination also different cache elements are created, e.g. a selected catalog or a selected time range.

For example:

  • One dashboard is configured, containing a bar chart component with a editable catalog parameter and a pie chart component. For both components the data cache is enabled.

  • Two user groups are defined with different object rights and therefore different ACLs.

  • A user of the first user group accesses the dashboard. Thereby the data is loaded from the data source for the two dashboard components (with the object rights of the first user group), and two cache elements are created.

  • The same user selects another catalog for the bar chart component. Thereby the data is loaded anew from the data source for the bar chart component and stored as a new cache element.

  • Then a user of the second group accesses the same dashboard. Thereby the data is loaded from the data source for the two dashboard components again (with the object rights of the second user group), and two separate cache elements are created.

  • Now, when users of the first or second user group access the dashboard, the data is not loaded from the data source again, but rather the corresponding cache element is used. Also when the first user selects a catalog, which was already selected once before, the data is also loaded from the cache.

Enable caching for a specific dashboard component

In order to enable and configure the cache for a specific dashboard component, the following parameters can be added to the <component> tag within the dashboard XML configuration:

Parameter name

Example values

Description

isCacheable

truefalse (default)

Enables the data cache for this dashboard component.

timeToLiveSeconds

3600 (default)

Specifies in seconds how long a cache element resides in the cache before it is destroyed and loaded from the data source anew.
Therefor the data cache has to be enabled for this component (isCacheable="true"). This parameter is optional.

isRefreshable

truefalse (default)

Enables a button for this dashboard component which forces the reloading of the data from the data source (and thereby destroys the "old" cache element).
Therefor the data cache has to be enabled for this component (isCacheable="true"). This parameter is optional.

Barchar example with cache
<!-- show bars of size 0 for the status values that are not used in any product; enabled data cache and refresh button -->
<component type="barchart" identifier="chart1" i18NKey="Product Status in Master Catalog">
<parameter key="groupingField" value="Product2G.CurrentStatus"/>
<parameter key="showBlankEntries" value="true"/>
<parameter key="isCacheable" value="true"/>
<parameter key="timeToLiveSeconds" value="1800"/>
<parameter key="isRefreshable" value="true"/>
<dataSource identifier="dataSet" type="reportById" ref="com.heiler.ppm.product2g.core.ProductsOfCatalog"/>
</component>

Configure the cache itself

The data cache for dashboard components itself can be configured globally for a Product 360 Server in the ehcache.xml file, which resides in the server's configuration folder. In order to configure the dashboard component data cache, change the following part of the ehcache.xml (or add it, if it doesn't exist yet):

<!-- Data cache for Dashboard Components -->
<cache
name="web.dashboards.entityItemList"
maxElementsInMemory="20"
/>

The attribute maxElementsInMemory specifies how many elements the cache can contain at the maximum. In order to find an appropriate value for maxElementsInMemory, consider the amount of dashboard component instances (across all dashboards), the average amount of parameter combinations of all dashboard components and the amount of different ACL combinations (simply spoken, user groups) that are configured. Also consider the heap memory usage of the cache, see chapter "Sizing considerations" below.

Sizing considerations

It is very important to consider the memory usage of the data cache for dashboard components. Misconfiguration can lead to OutOfMemoryExceptions and therefore to instability or crashes of the Product 360 Server.

Per default, the Product 360 Server's heap memory is used for ehcache cache instances. The heap memory usage of a cache element scales with the number of entity items in a linear way. The following table shows some typical values:

Number of entity items in a cache element

Heap memory usage of a cache element

10.000

0.52 MB

100.000

5.2 MB

1.000.000

52 MB

10.000.000

520 MB

100.000.000

5.2 GB

Furthermore this means that the overall maximum heap memory usage of the data cache for dashboard components is the configured "maxElementsInMemory" in ehcache.xml (see chapter above) multiplied with the maximum number of entity items of dashboard component's data source (=Entity Report).

For example:

If maxElementsInMemory is configured as 20 (which is the default) and the maximum number of entity items of a data source is 1.000.000, then the maximum heap memory usage is:
20 * 52 MB = 1040 MB

This memory usage has to be considered when sizing the Product 360 Server.