What is a basin?
A basin is a logical container that:- Organizes streams: Groups related streams together
- Provides defaults: Sets default configuration for all streams
- Enables auto-creation: Can automatically create streams on first append or read
- Scopes access: Acts as a boundary for access control (in s2.dev)
Think of a basin like a database or schema in traditional databases - it’s a namespace that groups related data streams together.
Basin naming
Basin names must follow specific rules:- Length: Between 8 and 48 bytes
- Characters: Lowercase letters (
a-z), numbers (0-9), and hyphens (-) - Format: Cannot begin or end with a hyphen
- Uniqueness: Must be globally unique (in s2.dev) or per-instance (in s2-lite)
Valid examples
Invalid examples
Basin configuration
Basins can be configured with default settings that apply to all streams within them:Configuration options
Default stream configuration
Sets defaults for all streams created in the basin:- storage_class:
standard(400ms tail latency) orexpress(40ms tail latency) - retention_policy: How long to keep records before automatic trimming
- timestamping: How timestamps are assigned to records
- delete_on_empty: Automatically delete streams after they’ve been empty for a period
Individual streams can override these defaults with their own configuration.
Auto-creation flags
create_stream_on_append (boolean, default: false)
When enabled, appending to a non-existent stream automatically creates it:
boolean, default: false)
When enabled, reading from a non-existent stream automatically creates it:
Basin states
Basins can be in one of three states:- active: Basin is operational and can be used
- creating: Basin is being provisioned (s2.dev only)
- deleting: Basin deletion is in progress
Basin scope
In s2.dev, basins can be scoped to specific regions:- aws:us-east-1: AWS US East (N. Virginia) region
In s2-lite, basin scope is not applicable as it’s a single-node deployment.
Operations
Creating a basin
Listing basins
Deleting a basin
Reconfiguring a basin
You can update basin configuration after creation:Implementation details
In s2-lite, basins are stored as metadata in SlateDB:- Key:
BasinMeta(BasinName)- Maps basin name to its metadata - Value: Basin configuration including default stream config and auto-creation flags
- Deletion:
BasinDeletionPending(BasinName)key tracks deletion progress
/home/daytona/workspace/source/lite/src/backend/kv/mod.rs:59-66:
Best practices
- Use descriptive names: Choose basin names that clearly indicate their purpose
- Group by lifecycle: Put streams with similar retention needs in the same basin
- Leverage auto-creation: Enable for dynamic stream patterns, disable for strict schemas
- Set appropriate defaults: Configure sensible defaults to avoid per-stream configuration
- Plan for deletion: Remember that deleting a basin deletes all its streams
Next steps
Streams
Learn about streams within basins
Stream configuration
Understand stream-level configuration options