About Proficy Historian Cache Object
Caching is used in many kinds of server software. You may have a basic idea of the concept and terminology of caching and just need to know how Historian makes use of a cache to give improved performance. The Historian Data Archiver is used to store and retrieve data from gigabytes of archives on disk. All those raw samples can not be kept in memory. For performance reasons, the Data Archiver will attempt to keep the most recently used information in memory. Cache hits avoid file I/O which is the number one negative performance factor in any server software.
As with multiple queues, there are multiple caches in the Data Archiver, each holding a different type of object. As with itemsin queues you want to understand what objectsare in a cache. One Read Call in the overview object becomes one Recv Count in the Queue object which becomes one or more cache hits or misses in the Archive Data Cache. This is because one read may span the raw samples stored in multiple data nodes. Some of those data nodes may be in cache and some may not.
There are four caches within the Data Archiver: ArchiveDataCache, ArchiveIndexCache, ArchiveTagCache, and ConfigTagCache. You can ignore three of them and only monitor the Archive Data Cache. These are raw samples. So, this cache is the simplest to understand and has the biggest effect on performance.
The Archive Data Cache starts empty at Data Archiver startup and fills as data is read and written.
Cache counters, like Queue counts are best viewed as current values in the report view of Performance monitor. These are displayed on the Archive Data Cache instance.
Counter Name | Description |
---|---|
Hits | When a program is queried or re-queried a tag and time range, and it was found in the cache. |
Misses | Data reads where the requested information was either never in cache or had to be removed to make room for more recently accessed data. |
Hit Percentage | Hits divided by Misses expressed as a percent. A high percentage means most data requests are being satisfied without having to access the disk. |
The objects in the Archive Data Cache are the data nodes. One data node is about 250 consecutive raw samples for one tag.
Counter Name | Description |
---|---|
Obj Count | Number of objects (data nodes containing raw samples) in the cache. |
Num Adds | Total number objects added to cache since Data Archiver startup. This number will always be increasing as new data is collected and queried. |
Num Deletes | Total number of objects deleted from cache. Deletes will not happen until the cache has reached its maximum size. |
Size (MB) | The amount of memory used by the cache to contain the raw samples. |
Possible uses of the counters are demonstrated in the sections that follow.
Example: Computing the cache hits for a specific time range
All the counters are numbers since Data Archiver startup, which means it is hard to detect a period of time that had many cache misses. If you know that the read was run at 4pm and took 1 minute, you can get the hits and miss counts at 3:59 and 4:02 and subtract them to know what the hit percentage was at the time the read was done. This is more useful than the hit percentage since startup. When subtracting, verify if the counter had rollover and went back to zero.
Example: Best Case Archive Data Cache hit percentage
Run the exact same SQL query 10 times with fixed start and end times. Your hits would be nine and misses would be one, that is, the first read. This is a cache hit percent of 90%. If you keep doing the read you will keep hitting the same raw samples in the same data nodes.
You must have an auto updating chart that always shows the data up to current time. You will have a high but not 100% cache hit percentage. This is because, as new data is added, you will have one cache miss accessing that newly created data node.
Example: Diagnosing Data Archiver memory growth due to cache
The overall Data Archiver memory usage consists of multiple kinds of objects. But you can monitor the memory usage due to caching in detail.
There are memory usage numbers on the cache and another way to do it is look at the object count in the cache. If Data Archiver Virtual Memory use is increasing, look at the Object Count over the same time period to see if it is also increasing.
Example: Removing items from cache to limit memory usage
There is no maximum reserved size for the cache. If adding more objects would put you past the configured Archiver Memory Usage, then adding one object will delete another object. Or, if the archiver memory is used for non-cache reasons like large tag browses, then the Data archiver cache will remove items to meet the target memory usage.
Example: Monitoring the size in bytes of the cache
Configure the Archiver Memory Size (MB) in the Admin UI to 100 meg and in the Report View of Performance Monitor look at the Size(MB) counter of the ArchiveDataCache instance. It is zero. Now change the Archiver Memory Size to 1700 and restart the data Archiver. The number is still zero.
This is because the counter measures how much space the cache is currently using, not a configured size nor maximum size. If you start reading and writing data, the Size (MB) will grow.