Advanced Local Caching
This example demonstrates how to enable local disk caching with advanced options for improved S3 performance.
Features
- Local disk caching at
/tmp/s3-pv1-cache
- Configurable cache size (500 MB)
- Metadata TTL presets:
minimal
andindefinite
- Custom metadata TTL values in seconds (3 seconds in this example)
Deploy
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
|
Key Mount Options
cache /tmp/s3-pv1-cache
- Cache directory path (must be unique per volume)metadata-ttl 3
- Cache metadata for 3 secondsmax-cache-size 500
- Limit cache to 500 MB
Metadata TTL Configuration
The metadata-ttl
flag controls how long Mountpoint considers its file system metadata (file existence, size, object etag, etc) accurate before re-fetching from S3.
Mountpoint will typically perform fewer requests to the mounted S3 bucket, but will not guarantee that the information it reports is up to date with the content of the mounted S3 bucket.
With local caching enabled, the stored data is considered accurate until the metadata TTL expires. After this period, Mountpoint revalidates if the cached data is still accurate by verifying the object's etag hasn't changed.
TTL Presets
Mountpoint provides two presets which trade off consistency and performance/cost optimization:
metadata-ttl minimal
- For scenarios where the mounted S3 bucket content is modified by another client and you require recently up-to-date informationmetadata-ttl indefinite
- For workloads that don't require consistency, such as when the S3 bucket content doesn't change
Custom TTL Values
You can also specify custom TTL values in seconds:
metadata-ttl 300
- Allows Mountpoint to delay updates for up to 300 seconds, reducing S3 requestsmetadata-ttl 3
- Short TTL for more frequent validation (as shown in this example)
Important Notes
⚠️ Cache Path Uniqueness: Each volume must use a unique cache path on each node to avoid conflicts.
Check Pod-Level Access to the Mounted S3 Volume
1 2 3 4 5 |
|
Cleanup
1 2 3 |
|