Documentation Index
Fetch the complete documentation index at: https://mintlify.com/durable-streams/durable-streams/llms.txt
Use this file to discover all available pages before exploring further.
Overview
The Caddy server (durable-streams-server) is a production-ready implementation of the Durable Streams protocol built as a Caddy v2 plugin. It provides both in-memory and file-backed (LMDB) storage options.
Installation
Quick Install (Recommended)
macOS & Linux:Manual Download
Download the latest release for your platform from GitHub Releases: macOS (Apple Silicon):.zip file from releases and extract to your PATH.
Build from Source
Quick Start
Dev Mode (Zero Config)
Start the server with sensible defaults:- URL: http://localhost:4437
- Endpoint: http://localhost:4437/v1/stream/*
- Storage: In-memory (no persistence)
- Zero config: No Caddyfile needed
Production Mode
Create aCaddyfile for production with persistent storage:
Configuration
Thedurable_streams Caddyfile directive accepts the following options:
Caddyfile Syntax
Configuration Options
Directory for storing stream data. If empty, uses in-memory storage (for testing).Example:
Maximum number of open file handles to cache.Example:
Default timeout for long-poll requests. Supports Caddy duration syntax (e.g.,
30s, 1m, 500ms).Example:How often SSE connections should reconnect for CDN cache collapsing.Example:
Configuration Examples
In-Memory Mode (Default)
For development and testing:File-Backed Mode (LMDB)
For production with persistent storage:Custom Timeouts
With TLS
Multiple Endpoints
JSON Configuration
The Caddy plugin can also be configured using JSON:JSON Configuration Fields
Must be
"durable_streams" to use this plugin.Directory for storing stream data. If empty, uses in-memory storage.
Maximum number of open file handles to cache.
Default timeout for long-poll requests.
How often SSE connections should reconnect.
Protocol Headers
The server implements the following protocol headers:Request Headers
Content-Type- Media type of the stream (required for POST/PUT)Stream-Seq- Sequence number for write coordinationStream-TTL- Time-to-live in secondsStream-Expires-At- Absolute expiry time (ISO 8601)Stream-Closed- Close the stream (“true” to close)Producer-Id- Producer ID for idempotent writesProducer-Epoch- Producer epoch for idempotent writesProducer-Seq- Producer sequence for idempotent writesIf-None-Match- ETag for conditional GET
Response Headers
Stream-Next-Offset- Offset after this operationStream-Cursor- Cache collision prevention cursorStream-Up-To-Date- Client is at stream tail (“true”)Stream-Closed- Stream is closed (“true”)Stream-SSE-Data-Encoding- SSE data encoding (“base64” for binary)Producer-Epoch- Echoed producer epochProducer-Seq- Highest accepted producer sequenceProducer-Expected-Seq- Expected sequence (on gap)Producer-Received-Seq- Received sequence (on gap)ETag- Entity tag for cachingLocation- New stream URL (on 201 Created)Cache-Control- Caching directives
HTTP Methods
PUT - Create Stream
Creates a new stream or returns existing stream if configuration matches. Request:HEAD - Get Metadata
Returns stream metadata without body. Request:GET - Read Data
Reads data from a stream starting at an offset. Request:POST - Append Data
Appends data to a stream. Request:DELETE - Delete Stream
Deletes a stream and all its data. Request:Live Modes
Long-Polling
Wait for new messages with automatic timeout:long_poll_timeout for new messages. Returns 204 No Content on timeout.
Server-Sent Events (SSE)
Real-time streaming with automatic reconnection:sse_reconnect_interval.
Storage Architecture
MemoryStore
In-memory storage for development:- Fast, ephemeral storage
- No persistence across restarts
- No file I/O overhead
FileStore (LMDB)
Production file-backed storage:- LMDB for metadata and producer state
- Append-only log files for stream data
- Configurable file handle pool
- Crash-safe writes
Development
Running Tests
Building
Deployment
Systemd Service
Create/etc/systemd/system/durable-streams.service:
Docker
Kubernetes
Releasing
Releases are automated via GoReleaser when a tag is pushed:- Build binaries for all platforms
- Create GitHub release with artifacts
- Generate checksums
- Auto-generate changelog
Troubleshooting
Port Already in Use
Change the port in your Caddyfile:Permission Denied (data_dir)
Ensure the data directory is writable:File Handle Limits
Increase system limits for production:Performance
Benchmarks
Typical performance on modern hardware:- Throughput: 50,000+ requests/sec (in-memory)
- Latency: <1ms p50, <5ms p99 (in-memory)
- Concurrent Streams: 100,000+ (with file-backed storage)
- Long-Poll Connections: 10,000+ concurrent