Skip to main content
Archil caches your data at two distinct layers:
  • The Archil storage system cache is a durable, multi-Availability-Zone caching layer that runs server-side, between your clients and your data source. It’s where your active data is durably stored (a successful fsync() commits to it) and where it’s metered, and it serves data with sub-millisecond latency. See Architecture for how it fits in.
  • The client-side cache is an in-memory cache inside each Archil client — one per mount. It holds recently used data so that repeated access is served locally, without even a round-trip to the storage system.
This page is mostly about the client-side cache: what it holds, how it’s sized and evicted, and the commands you use to warm, refresh, and tune it. To warm the storage system cache without a mounted client, see Warming the storage system cache with the API.

What the client caches

The client maintains several in-memory caches, all populated on demand as your application reads and writes:
  • File data — the contents of files. This is the bulk of the cache.
  • File and directory attributes — metadata such as size, timestamps, and permissions (the result of a stat).
  • Directory listings — the entries returned by readdir (i.e., ls), so repeated traversals of the same directory don’t round-trip to the server.
  • Extended attributes — when xattrs are enabled.
When your application requests data that isn’t in the client cache, the client fetches it from the Archil storage system — which serves it from its durable cache (sub-millisecond) or, on a miss there, from the backing data source (for Amazon S3, typically 10–30 ms) — and then caches the result in memory for future requests.

Cache size and eviction

The client’s in-memory data cache is bounded by two settings on archil mount:
  • --max-cache-mb — the hard ceiling on the client cache size. Default: 1/4 of available RAM or 2048 MiB, whichever is smaller.
  • --target-cache-mb — the size the client aims to keep the cache near, leaving headroom for bursts of new reads. Default: 75% of the maximum.
When the cache fills, the client evicts older entries to make room for new data. Two kinds of entries are never evicted:
  • Unflushed (dirty) writes — data you’ve written that hasn’t yet been committed to the storage system is always preserved locally, so eviction can never lose your writes.
  • Entries still in use — anything an application currently has open is kept until it’s released.
Because the client cache is bounded, reading or pre-fetching more data than --max-cache-mb can hold will evict earlier entries before you use them. Size the cache for your working set when you plan to keep a large data set hot on a client.
For example, to give a read-heavy client a larger cache:

Freshness and consistency

Serving reads from the client cache is what lets a client avoid contacting the storage system on every operation, which also means a client can serve stale data after another client changes a file. By default:
  • Opening a file checks it with the storage system, so reads after open see every write that reached the disk before it.
  • Attributes that stat returns are cached for up to 30 seconds.
  • Directory listings, and the names learned from them, are cached for up to five minutes. Tune this per directory or for the whole mount with archil set-cache-expiry.
For the full model, including when another client’s write reaches the disk, see Consistency.

Warming the client cache

By default the client cache fills lazily as data is read, so the first read of any file on a client pays the fetch latency. When you know which files you’ll need — loading a model, starting a database, or running a batch job over a known set of inputs — you can warm them ahead of time so the first read is already local. There are two ways to warm the client cache:
Pre-fetched data shares the client cache with normal reads, so it counts against --max-cache-mb and is subject to the same eviction described above.
The client also reads ahead automatically: when it detects sequential reads of a file, it fetches up to 4 MiB beyond them. Change the window with mount --read-ahead <BYTES>, or pass 0 to disable it.

Warming the storage system cache with the API

On a miss in the storage system cache, the first read of a file waits on the backing data source. To take that wait out of the first read when you know which files a job will need, call Prefetch File Ranges before the job starts. It warms the files into the storage system cache, so later reads from any client, serverless exec, or sandbox are served from the cache. It needs no mounted client, so you can call it from a scheduler or control service before the work starts. Each range names one file by its path relative to the disk root, with an optional offset and length in bytes. A range without them warms the whole file. A request can name up to 1,000 ranges.
The response has one result per range, in request order:
  • bytesRequested is the size of the range, and bytesWarmed is the part being fetched from the data source; the rest was already cached. The response can return before the fetch finishes.
  • A path that does not exist reports found: false.
  • Ranges must name files. A directory is found but warms nothing, so list its files and pass each one.
  • A range that could not be warmed carries error: retry for a transient failure worth retrying, or failed. Other ranges in the request are unaffected.
If the disk is not mounted anywhere, the request loads it first. Warmed data is active data and is metered like data your clients read.

Refreshing the client cache

To force a client to drop cached entries and re-read from the storage system — for example, when another client has updated files on a --shared or --conditional mount — use archil invalidate-cache. Pass the mount root to refresh everything, or a single file path to refresh just that file. In-flight (dirty) writes are always preserved.

Controls at a glance