This document describes the architecture of TAG (Tigris Acceleration Gateway), a high-performance S3-compatible caching proxy with an embedded distributed cache.
┌─────────────────────────────────────────────────────────────────────────┐
│ TAG Proxy │
│ ┌─────────┐ ┌──────────┐ ┌─────────┐ ┌─────────┐ ┌─────────────┐ │
│ │ Handler │──│ Auth │──│ Proxy │──│ Cache │──│ Forwarder │ │
│ │ Server │ │ Validator│ │ Service │ │ Client │ │ │ │
│ └────┬────┘ └──────────┘ └────┬────┘ └────┬────┘ └──────┬──────┘ │
│ │ │ │ │ │
│ │ │ ┌──────┴──────┐ │ │
│ │ │ │ Embedded │ │ │
│ │ │ │ Cache │ │ │
│ │ │ │ (RocksDB) │ │ │
│ │ │ └──────┬──────┘ │ │
└───────┼──────────────────────────┼────────────┼───────────────┼─────────┘
│ │ │ │
▼ │ ▼ ▼
┌─────────┐ │ ┌─────────┐ ┌─────────┐
│ Clients │ │ │ Other │ │ Tigris │
│(S3 SDKs)│ │ │ TAG │ │ Storage │
└─────────┘ │ │ Nodes │ └─────────┘
│ └─────────┘
┌────┴────┐
│Broadcast│
│ Manager │
└─────────┘
The HTTP server that receives incoming S3 requests.
- server.go: HTTP server setup, routing, and middleware
- errors.go: S3-compatible error responses
Routes requests to appropriate handlers based on HTTP method and path:
GET /{bucket}/{key}→ GetObjectPUT /{bucket}/{key}→ PutObjectDELETE /{bucket}/{key}→ DeleteObjectHEAD /{bucket}/{key}→ HeadObjectGET /health→ Health checkGET /metrics→ Prometheus metrics
AWS Signature Version 4 authentication and request signing.
- credentials.go: Credential store for access/secret key pairs
- validator.go: Validates incoming request signatures using stored signing keys
- signer.go: Re-signs requests for upstream Tigris
- proxy_signer.go: Computes proxy headers for transparent proxy mode
- parser.go: Parses Authorization headers and presigned URLs
- key_unwrapper.go: Decrypts derived signing keys from upstream responses (AES-256-GCM)
- derived_key_store.go: LRU cache of pre-derived SigV4 signing keys for local validation
- authz_cache.go: Per-bucket authorization cache tracking
(accessKey, bucket)decisions
Authentication Flow (signing mode):
1. Extract access key from Authorization header or query params
2. Look up secret key from credential store
3. Compute expected signature using AWS SigV4 algorithm
4. Compare with provided signature
5. If valid, re-sign request for upstream with same credentials
In transparent proxy mode (default), TAG forwards the client's original Authorization header as-is and adds proxy headers so Tigris validates the signature against the original host. TAG also performs local SigV4 validation using pre-derived signing keys learned from Tigris responses, enabling cache hits to be served without an upstream round-trip. Anonymous requests (missing auth) are forwarded to Tigris for authoritative handling (e.g., public bucket access), while malformed auth headers are rejected at TAG.
See security.md for the full access control flow, local authentication mechanism, and authorization lifecycle.
Core proxy logic including caching and request coalescing.
- service.go: Main request handling, cache logic, broadcast coordination
- forwarder.go:
RequestForwarderinterface and sharedbaseForwarderlogic - forwarder_transparent.go: Transparent proxy forwarding (preserves client signatures)
- forwarder_signing.go: Signing mode forwarding (validates and re-signs requests)
- broadcast/: Streaming broadcast pattern for request coalescing
Interface to the embedded OCache module with RocksDB storage.
- cache.go: OCache client wrapper with TAG-specific methods
- object.go: Cached object metadata structure
TAG embeds OCache directly, providing:
- High-performance RocksDB-based storage
- Optional clustering via gossip protocol (memberlist)
- gRPC-based cache routing between nodes
- Consistent hashing for key distribution
Two-Key Storage Pattern:
Object "bucket/key" is stored as:
- Metadata key: "meta:bucket/key" → JSON with headers, size, etag, etc.
- Body key: "body:bucket/key" → Raw object bytes
This pattern enables:
- Efficient HEAD requests (metadata only)
- Conditional request support (If-None-Match, If-Modified-Since)
- Range requests from cached full objects
Prometheus metrics for monitoring and alerting.
- metrics.go: Metric definitions and recording functions
TAG supports two request forwarding modes, controlled by the transparent_proxy config setting:
Forwards client requests to Tigris as-is, preserving the original Authorization header. TAG adds four proxy headers so Tigris can validate the client's signature against the original host:
X-Tigris-Forwarded-Host- The original Host header from the clientX-Tigris-Proxy-Access-Key- TAG's own access key for proxy authenticationX-Tigris-Proxy-Timestamp- Timestamp for proxy signatureX-Tigris-Proxy-Signature- HMAC signature proving TAG's identity
No local credential store is needed in this mode. URL encoding (including RawPath) is preserved exactly as received from the client.
Validates incoming request signatures against a local credential store, then re-signs requests for the upstream Tigris endpoint. This mode is used when TAG needs to perform credential translation (e.g., clients use different credentials than the upstream Tigris account).
In signing mode, proxy headers (X-Tigris-Proxy-* and X-Tigris-Forwarded-Host) are stripped from client requests to prevent injection of unsigned headers.
Both modes share the same baseForwarder for HTTP execution, response streaming, and cache interactions. Both use SigV4 signing for background cache operations (e.g., fetching full objects for range request caching).
For multi-node deployments, TAG nodes form a distributed cache cluster:
┌─────────────────────────────────────────┐
│ Gossip Protocol │
│ (Cluster Discovery) │
└─────────────────────────────────────────┘
▲ ▲ ▲
│ │ │
┌─────────┴───┐ ┌─────┴───────┐ ┌───┴─────────┐
│ TAG-1 │ │ TAG-2 │ │ TAG-3 │
│ ┌─────────┐ │ │ ┌─────────┐ │ │ ┌─────────┐ │
│ │ Embedded│ │ │ │ Embedded│ │ │ │ Embedded│ │
│ │ Cache │ │ │ │ Cache │ │ │ │ Cache │ │
│ │(RocksDB)│ │ │ │(RocksDB)│ │ │ │(RocksDB)│ │
│ └─────────┘ │ │ └─────────┘ │ │ └─────────┘ │
└──────┬──────┘ └─────┬───────┘ └──────┬──────┘
│ │ │
┌──────┴──────────────┴────────────────┴──────┐
│ gRPC Routing │
│ (Cache Key Distribution) │
└─────────────────────────────────────────────┘
Cluster Components:
| Port | Protocol | Purpose |
|---|---|---|
| 8080 | HTTP | S3 API requests |
| 7000 | TCP | Memberlist gossip (cluster discovery) |
| 9000 | gRPC | Cache routing between nodes |
How Clustering Works:
- Discovery: Nodes join the cluster via seed nodes using memberlist gossip
- Key Routing: Cache keys are distributed across nodes using consistent hashing
- Local vs Remote: Requests for keys owned by another node are forwarded via gRPC
- Rebalancing: When nodes join/leave, keys are automatically redistributed
Client TAG Embedded Cache
│ │ │
│ GET /bucket/key │ │
│────────────────────▶│ │
│ │ Get meta:bucket/key │
│ │──────────────────────▶│
│ │◀──────────────────────│ metadata
│ │ Get body:bucket/key │
│ │──────────────────────▶│
│ │◀──────────────────────│ body (streaming)
│◀────────────────────│ │
│ 200 OK + body │ │
│ X-Cache: HIT │ │
Client TAG Embedded Cache Tigris
│ │ │ │
│ GET /bucket/key │ │ │
│────────────────────▶│ │ │
│ │ Get meta:bucket/key │ │
│ │──────────────────────▶│ │
│ │◀──────────────────────│ not found │
│ │ │ │
│ │ GET /bucket/key (signed) │
│ │───────────────────────────────────────────▶│
│ │◀───────────────────────────────────────────│
│ │ │ 200 OK │
│ │ │ │
│ │ Put meta + body │ │
│ │──────────────────────▶│ │
│◀────────────────────│ │ │
│ 200 OK + body │ │ │
│ X-Cache: MISS │ │ │
Cache population is best-effort. If the cache writer returns an error after a successful upstream response, TAG keeps that response and releases the populate reservation after the cache relay and its buffer holders finish. A cache writer that never returns has no completion guarantee.
Client TAG-1 TAG-2 (owns key) Tigris
│ │ │ │
│ GET /bucket/key │ │ │
│────────────────────▶│ │ │
│ │ Hash(key) → TAG-2 │ │
│ │ │ │
│ │ gRPC: Get(key) │ │
│ │──────────────────────▶│ │
│ │ │ Check local cache │
│ │ │──────┐ │
│ │ │◀─────┘ HIT │
│ │◀──────────────────────│ Return data │
│◀────────────────────│ │ │
│ 200 OK + body │ │ │
Concurrent full-object GETs for the same uncached object share one upstream fetch only when callers subscribe before the first upstream body chunk begins. The diagram shows callers that join during that window. A GET arriving after streaming starts cannot join that broadcast and starts its own upstream fetch.
Client1 TAG Tigris
Client2 │ │
Client3 │ │
│ │ │
│ GET /bucket/key │ │
│────────────────────▶│ (becomes fetcher) │
│ GET /bucket/key │ │
│────────────────────▶│ (joins as listener) │
│ GET /bucket/key │
│────────────────────▶│ (joins as listener) │
│ │ │
│ │ GET /bucket/key (single request) │
│ │─────────────────────────────────▶│
│ │◀─────────────────────────────────│
│ │ 200 OK (streaming) │
│ │ │
│◀────────────────────│ chunk 1 (broadcast to all) │
│◀────────────────────│ │
│◀────────────────────│ │
│ │ │
│◀────────────────────│ chunk 2 (broadcast to all) │
│◀────────────────────│ │
│◀────────────────────│ │
│ │ │
│◀────────────────────│ complete │
│◀────────────────────│ │
│◀────────────────────│ │
Key Points:
- First request becomes the "fetcher" and initiates the upstream request
- Requests that subscribe before streaming starts join as "listeners"
- All listeners of a broadcast receive the same upstream response as chunks arrive
- Memory usage scales with listeners, not object size
- For live requests, an upstream failure before response commitment is returned through the existing S3 error mapping for each waiting GET; after commitment, the stream cannot be replaced by an error document
Range requests use a background fetch pattern for optimal ML training workloads:
Client TAG Embedded Cache Tigris
│ │ │ │
│ GET /bucket/key │ │ │
│ Range: bytes=0-1023 │ │ │
│────────────────────▶│ │ │
│ │ Get meta:bucket/key │ │
│ │──────────────────────▶│ │
│ │◀──────────────────────│ not found │
│ │ │ │
│ │ GET /bucket/key Range: bytes=0-1023 │
│ │───────────────────────────────────────────▶│
│ │◀───────────────────────────────────────────│
│◀────────────────────│ 206 Partial │
│ 206 Partial │ │
│ │ │
│ │ (Background: fetch full object) │
│ │───────────────────────────────────────────▶│
│ │◀───────────────────────────────────────────│
│ │ 200 OK (full object) │
│ │ Put meta + body │ │
│ │──────────────────────▶│ │
Benefits:
- Low latency: Client gets range immediately
- Future ranges served from cache
- Background fetches are coalesced (multiple range requests = single fetch)
type CachedObjectMeta struct {
Bucket string // Source bucket
Key string // Object key
StatusCode int // HTTP status (usually 200)
ContentLength int64 // Object size in bytes
ContentType string // MIME type
ETag string // Entity tag for conditional requests
LastModified time.Time // Last modification time
CacheControl string // Cache-Control header
Headers map[string]string // Additional headers to preserve
}Metadata key: "meta|bucket|key"
Body key: "body|bucket|key"
Objects are cached when:
- Response status is 200 OK
- Size is within
size_threshold(default 1GB) - No
Cache-Control: no-storeorprivateheaders
Objects are NOT cached when:
- Response is not 200 (errors, redirects)
- Size exceeds threshold
- Cache-Control prevents caching
- Cache is disabled
The broadcast manager coordinates request coalescing:
type Manager struct {
active map[string]*Broadcaster // Active broadcasts by key
channelBuf int // Buffer size per listener
}
type Broadcaster struct {
listeners []*Listener // Subscribed listeners
streaming bool // True once first chunk sent
done bool // Broadcast complete
}
type Listener struct {
ch chan Chunk // Chunk delivery channel
headers http.Header // Response headers
status int // HTTP status code
}Policies:
- No Late Joiners: Once streaming starts, new requests start their own broadcast
- Slow Consumer Handling: Listeners with full channels are disconnected
- Memory Bounded:
chunkSize × channelBuffer × numListenersper broadcast
TAG returns S3-compatible XML error responses:
<?xml version="1.0" encoding="UTF-8"?>
<Error>
<Code>AccessDenied</Code>
<Message>Access Denied</Message>
<RequestId>request-id</RequestId>
</Error>| Internal Error | S3 Error Code | HTTP Status |
|---|---|---|
| Invalid signature | SignatureDoesNotMatch | 403 |
| Unknown access key | InvalidAccessKeyId | 403 |
| Request expired | RequestTimeTooSkewed | 403 |
| Slow consumer | InternalError | 500 |
| Uncommitted upstream error | InternalError | 500 |