Choosing a Chunk Size
The chunk is the unit of everything in flexBlock: a fixed-size span of the device that is one object in the bucket and one slot on the cache device. You choose its size once, when you create the volume, so it is worth a moment’s thought.
The flag
Section titled “The flag”| Command | Flag | Default | Meaning |
|---|---|---|---|
init | --chunk-size <1M|2M|4M|8M> | 2M | Unit of caching and storage, one object and one slot each. Fixed for the volume’s life. |
sudo flexblock init --chunk-size 1M --device-size 2TWhat the chunk size controls
Section titled “What the chunk size controls”- Caching. The cache holds whole-chunk slots. A read miss fetches one chunk object from the bucket.
- Object storage. Each chunk is one object, overwritten in place by every flush. A small write to a chunk eventually uploads the whole chunk.
- Largest I/O. The device advertises the chunk size as its optimal and maximum I/O size, so filesystems align to it without being told.
- Memory. In copy mode the I/O buffer pool is sized by the chunk, so a larger chunk costs more RAM despite needing fewer slots. See Memory.
Trade-offs
Section titled “Trade-offs”| Smaller chunks (1 MiB) | Larger chunks (4 or 8 MiB) |
|---|---|
| Less write amplification for random I/O | Better sequential throughput and read-ahead |
| More objects in the bucket and more slot metadata | Fewer objects and less slot metadata |
| Smaller copy-mode buffer pool | Larger copy-mode buffer pool |
Recommendations
Section titled “Recommendations”| Workload | Chunk size |
|---|---|
| General-purpose filesystems | 2 MiB (the default) |
| Random-heavy databases | Consider 1 MiB |
| Sequential archives | Consider 4 or 8 MiB |
The chunk size also sets the default queue depth (--queue-depth auto is 64 for 1 MiB chunks and 32 above), and the device size must be a multiple of it.
You can check the chunk size of a serving volume with flexblock show or the flexblock_chunk_size_bytes metric.