π π Quick Start
Langfuse v3 replaces the Postgres-only core with a ClickHouse-centric data stack. Self-hosted deployments must provision ClickHouse, Redis/Valkey, an S3-compatible Blob Store, and an asynchronous Worker Container.
π§ π§ Configuration
Required environment variables for linking the new stack:
CLICKHOUSE_URL="http://clickhouse:8123" # Must be version 24.3+
CLICKHOUSE_MIGRATION_URL="http://clickhouse:8123" # Dedicated migration endpoint
CLICKHOUSE_USER="default"
CLICKHOUSE_PASSWORD="securepassword"
CLICKHOUSE_CLUSTER_NAME="my_cluster" # Explicitly set if using external cluster
NODE_OPTIONS="--max-old-space-size=8192" # Required to prevent OOM during migration
LANGFUSE_SKIP_INGESTION_CLICKHOUSE_READ_MIN_PROJECT_CREATE_DATE="2024-11-01" # Skips unnecessary readsπ¦ π¦ Dependencies
- ClickHouse: Version >= 24.3 (Avoid specific 25.5.2+ releases due to memory issues).
- Redis / Valkey: Queuing and caching tier.
- S3 / Blob Store: Offloads large objects to cold storage.
- Worker Container: Processes asynchronous background events.
π‘ π‘ Best Practices
- Ingestion Optimization: Set
LANGFUSE_SKIP_INGESTION_CLICKHOUSE_READ_MIN_PROJECT_CREATE_DATEprior to your project creation date. This dramatically reduces read loads during high-throughput ingestions. - Read-Side Deduplication:
ReplacingMergeTreededuplicates asynchronously. Design queries to expect fluctuating counts and implement read-side deduplication. - Separation of Concerns: Split the
langfuse-webdeployment into separate ingestion and UI/API services under heavy load. - Data Tiering: Use ClickHouse native TTL features to move old data to S3. This avoids scaling expensive block storage.
π¨ π¨ Gotchas / Warnings (Anti-Patterns)
- βDirty Databaseβ State: Failed migrations lock the
schema_migrationstable. You must manually clean this table in ClickHouse to retry. - Batch Size Overflows: Default Postgres
background_migrationsbatch sizes often cause HTTP 413 Payload Too Large errors. Edit theargscolumn to reducebatchSizeto 100 or 250. - Memory Exhaustion: Migrations require at least 8 GiB memory per replica. Missing
NODE_OPTIONSmemory flags guarantees OOM crashes. - Single-Shard Limitation: Multi-shard ClickHouse configurations are unsupported. Forcing multi-shard setups corrupts data consistency and breaks migrations.
- ENABLE_ANALYZER Errors: Upgrading ClickHouse can trigger
CAST AS Mapquery errors. These stem from the new ClickHouse analyzer; verify GitHub issues for version-specific flags.
π π Research / References