@effect/cluster provides unified interfaces for building distributed systems with Effect, enabling sharding, distributed state management, and cluster coordination.
Installation
Core Concepts
@effect/cluster enables you to build resilient distributed systems by providing:
- Sharding: Distribute entities across cluster nodes
- Message Passing: Type-safe communication between entities
- Persistence: Durable state management
- Cluster Coordination: Node discovery and health monitoring
- Load Balancing: Automatic entity distribution
Quick Start
Define an Entity
Create a sharded entity using Effect:Start a Cluster Node
Persistence
Entities can persist state to a database:Message Broadcasting
Send messages to multiple entities:Cluster Management
Node Discovery
Health Checks
Monitor cluster health:Deployment
Kubernetes
Docker Compose
Storage Backends
Choose a storage backend for cluster state:PostgreSQL
MySQL
SQLite
Integration with Workflows
Combine with@effect/workflow for durable execution:
Best Practices
- Entity Design: Keep entities small and focused
- Message Immutability: Use immutable message types
- Idempotency: Design message handlers to be idempotent
- Error Handling: Handle failures gracefully with retries
- Monitoring: Use OpenTelemetry for distributed tracing
- Testing: Test entities in isolation before clustering
Related Resources
API Reference
Complete API documentation
@effect/rpc
RPC for inter-service communication
@effect/sql
SQL toolkit for persistence
@effect/workflow
Durable workflow execution