Artica Wiki

The Rock system Cache ( multiple CPU support )

The rock cache stores all objects in a single database shared by every proxy worker: why to use it on a multi-CPU proxy, how Artica places your caches, Central Cache settings, size and memory, and how to check it.

Back to Proxy Cache main section

A rock cache stores all cached objects in a single database file, cut into fixed-size slots. Unlike the classic disk caches (aufs, ufs, diskd), a rock cache can be shared by all the proxy workers: it is the cache type made for proxies that use several CPUs.

Why rock when the proxy uses several CPUs

To use several CPUs, the proxy runs several workers, independent processes that share the traffic. Each worker has its own view of the disk caches:

Disk I/O for rock caches is done by separate helper processes (diskers). They can become a bottleneck under heavy load, so give the proxy a large enough memory cache: it is shared by all workers too, and serves the most popular objects without reading the disk. The default configuration only keeps small objects in the memory cache; raise its size and its maximum object size on busy proxies.

How Artica places your caches

Cache One worker Several workers (multiple CPUs)
Central Cache (rock, see below) not used: it needs several workers shared by all workers
Caches Center cache of type rock used shared by all workers
Caches Center cache of type aufs / ufs / diskd used used by one worker only: the process chosen in the cache settings (process 1 by default)

Enable the Central Cache

When you apply the settings, Artica rebuilds the cache configuration, creates the rock database and then:

Disabling the feature removes the cache from the proxy and deletes the rock directory, only when it really contains a proxy cache.

Size and memory

The proxy keeps the index of a rock cache in shared memory (/dev/shm). The largest size Artica proposes is therefore computed from the shared memory available: about 32 times 70% of /dev/shm. If the size you need is not proposed, add memory to the server.

Advanced options

SWAP timeout:
The proxy will not start writing a cached object to, or reading a cached object from, the disk if it estimates that the operation will take more than the specified number of milliseconds. By default, and when set to zero, the disk I/O time limit is disabled. Ignored with a blocking I/O module, because blocking synchronous I/O does not let the proxy estimate the expected wait time.

Max SWAP rate:
Artificially limits disk access to the specified I/O rate. Write requests that would push the average I/O rate above the limit are delayed. Individual read requests (cache HITs) are not delayed, but they count in the measured rate and wait in the same queue as writes, so they may wait longer when this value is small. This is useful on file systems that buffer "too many" writes and then block the proxy and other processes while committing them to disk. Usually used together with the SWAP timeout to avoid long delays and queue overflows when disk demand exceeds the disk bandwidth. By default, and when set to zero, the I/O rate limit is disabled.

The slot size of the rock database is fixed by Artica to 32,000 bytes.

Check that the cache works