K2V (Key-Key-Value) is an experimental API designed to efficiently store many small values in Garage buckets, complementing S3’s design for large blob storage.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/deuxfleurs-org/garage/llms.txt
Use this file to discover all available pages before exploring further.
What is K2V?
K2V is an alternative storage API optimized for:- High-volume small values - Efficiently handle thousands of small key-value pairs
- Metadata storage - Store metadata related to S3 objects
- Application state - Manage application data requiring frequent updates
- Bulk operations - Process many values efficiently in batch
Key Differences from S3
| Feature | S3 API | K2V API |
|---|---|---|
| Optimized for | Large blobs (MBs-GBs) | Small values (bytes-KBs) |
| Data structure | Bucket → Key → Object | Bucket → Partition → Sort Key → Value |
| Operations | Individual object ops | Batch operations |
| Use case | File storage | Metadata, indices, state |
| Versioning | Optional | Built-in causality tracking |
Use Cases
Aerogramme (Email Storage)
The Aerogramme project uses K2V to store:- Email metadata and indices
- Mailbox state and flags
- Operation logs
Application Metadata
For applications storing files in S3:Database Indices
Build secondary indices for S3 objects:Getting K2V
Download Pre-built Binaries
K2V-enabled builds are available on the Garage download page under “Extra builds”. These builds have tags ending with-k2v (e.g., v0.9.0-k2v).
Build from Source
Enable thek2v feature flag when building:
Configuration
Enable K2V API
Add a[k2v_api] section to your garage.toml:
- Choose a port not used by S3 API (3900), admin API (3903), or RPC (3901)
- K2V API does not provide TLS - use a reverse proxy for production
- All cluster nodes must use K2V-enabled builds
Restart Garage
After configuration:Authentication
K2V uses the same AWS Signature Version 4 (AWSv4) authentication as S3:- Same access keys and secret keys
- Same AWS region (defined in
s3_regionconfig) - Same bucket-level permissions
Using the K2V API
K2V Client Library (Rust)
Garage provides an official Rust client library: Cargo.toml:K2V CLI Tool
Build the CLI tool from source:k2v-cli --help for complete documentation.
API Specification
The complete K2V API specification is available in the Garage repository: The specification includes:- Data model and semantics
- HTTP API endpoints
- Causality tracking and conflict resolution
- Batch operations
- Performance characteristics
Data Model
Structure
Example Structure
Performance Considerations
When to Use K2V
Good use cases:- Storing thousands of small configuration values
- Frequently updated metadata
- Application indices and catalogs
- Session state and temporary data
- Batch operations on many small items
- Large binary files (use S3 instead)
- Single large values (use S3 instead)
- Infrequent access to large objects
Optimization Tips
- Partition wisely - Group related data in the same partition for efficient batch operations
- Small values - Keep values under a few KB for best performance
- Batch operations - Use batch APIs when operating on multiple items
- Causality tokens - Use them properly to avoid conflicts in concurrent updates
Limitations and Caveats
- Build requirement: Standard Garage builds don’t include K2V
- No versioning UI: Unlike S3, no web interface for K2V data
- Limited tooling: Fewer third-party tools compared to S3
- Specification changes: API may evolve before stabilization
Migration and Compatibility
K2V data is stored separately from S3 data:- Disabling K2V doesn’t affect S3 buckets
- K2V and S3 can use the same bucket names (separate namespaces)
- Switching from K2V build to standard build disables K2V API but preserves data
Future Development
K2V is part of ongoing research into distributed storage systems. Community feedback is valuable:- Report bugs and issues on the Garage repository
- Discuss use cases on community channels
- Contribute improvements and documentation
- Real-world use cases and performance data
- Integration patterns with S3
- API improvements and ergonomics