Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion content/self-hosting/configuration/scaling.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,30 @@ On very high loads, it may become necessary to apply additional settings that in
For most environments, we recommend to scale the worker containers by their CPU load as this is a straightforward metric to measure.
A load above 50% for a 2 CPU container is an indicator that the instance is saturated and that the throughput should increase by adding more containers.

In addition, the Langfuse worker also publishes queue length metrics via statsd that can be used to scale the worker containers.
In addition, the Langfuse worker also publishes queue length metrics via StatsD (DogStatsD format) that can be used to scale the worker containers.
`langfuse.queue.ingestion.length` is the main metric that we use to make scaling decisions.

#### Configuring StatsD

Langfuse uses the [`dd-trace`](https://docs.datadoghq.com/tracing/trace_collection/automatic_instrumentation/dd_libraries/nodejs/) package (DataDog's tracing library) which includes a DogStatsD client. The client auto-configures using standard DataDog environment variables:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 The link targets DataDog's APM/distributed-tracing instrumentation page, which focuses on trace collection rather than StatsD/metrics configuration. Readers following this link to learn how to configure DD_AGENT_HOST or DD_DOGSTATSD_PORT will land on unrelated APM setup content. The DataDog DogStatsD docs (https://docs.datadoghq.com/developers/dogstatsd/) more directly describe the DogStatsD client and its environment variables.

Suggested change
Langfuse uses the [`dd-trace`](https://docs.datadoghq.com/tracing/trace_collection/automatic_instrumentation/dd_libraries/nodejs/) package (DataDog's tracing library) which includes a DogStatsD client. The client auto-configures using standard DataDog environment variables:
Langfuse uses the [`dd-trace`](https://docs.datadoghq.com/developers/dogstatsd/?tab=nodejs) package (DataDog's tracing library) which includes a DogStatsD client. The client auto-configures using standard DataDog environment variables:
Prompt To Fix With AI
This is a comment left during a code review.
Path: content/self-hosting/configuration/scaling.mdx
Line: 38

Comment:
The link targets DataDog's APM/distributed-tracing instrumentation page, which focuses on trace collection rather than StatsD/metrics configuration. Readers following this link to learn how to configure `DD_AGENT_HOST` or `DD_DOGSTATSD_PORT` will land on unrelated APM setup content. The DataDog DogStatsD docs (`https://docs.datadoghq.com/developers/dogstatsd/`) more directly describe the DogStatsD client and its environment variables.

```suggestion
Langfuse uses the [`dd-trace`](https://docs.datadoghq.com/developers/dogstatsd/?tab=nodejs) package (DataDog's tracing library) which includes a DogStatsD client. The client auto-configures using standard DataDog environment variables:
```

How can I resolve this? If you propose a fix, please make it concise.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!


| Environment Variable | Default | Description |
| ----------------------- | ------------- | ------------------------------------------ |
| `DD_AGENT_HOST` | `localhost` | StatsD agent hostname or IP |

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 The description for DD_AGENT_HOST says "StatsD agent hostname or IP", but since Langfuse uses DogStatsD format (not vanilla StatsD), this host must point to a DataDog Agent running a DogStatsD listener — a plain StatsD server would not understand the DogStatsD wire format and metrics would be silently dropped. Calling it a "StatsD agent" could lead operators to point it at a generic StatsD endpoint and wonder why nothing shows up in DataDog.

Suggested change
| `DD_AGENT_HOST` | `localhost` | StatsD agent hostname or IP |
| `DD_AGENT_HOST` | `localhost` | DataDog Agent hostname or IP (must run a DogStatsD listener) |
Prompt To Fix With AI
This is a comment left during a code review.
Path: content/self-hosting/configuration/scaling.mdx
Line: 42

Comment:
The description for `DD_AGENT_HOST` says "StatsD agent hostname or IP", but since Langfuse uses DogStatsD format (not vanilla StatsD), this host must point to a **DataDog Agent** running a DogStatsD listener — a plain StatsD server would not understand the DogStatsD wire format and metrics would be silently dropped. Calling it a "StatsD agent" could lead operators to point it at a generic StatsD endpoint and wonder why nothing shows up in DataDog.

```suggestion
| `DD_AGENT_HOST`         | `localhost`   | DataDog Agent hostname or IP (must run a DogStatsD listener) |
```

How can I resolve this? If you propose a fix, please make it concise.

| `DD_DOGSTATSD_PORT` | `8125` | DogStatsD server port |
| `DD_ENV` | — | Environment tag applied to all metrics |
| `DD_SERVICE` | — | Service name tag applied to all metrics |

These variables apply to both the web and worker containers.

Langfuse-specific queue metric configuration (worker container only):

| Environment Variable | Default | Description |
| ---------------------------------------------- | -------- | -------------------------------------------------------------- |
| `LANGFUSE_QUEUE_METRICS_ENABLED` | `true` | Master toggle for publishing queue metrics via StatsD |
| `LANGFUSE_QUEUE_METRICS_INTERVAL_MS` | `1000` | Poll interval for queue depth metrics (minimum 100ms) |
| `LANGFUSE_QUEUE_METRICS_SAMPLE_RATE` | `0.3` | Probability for recording sharded queue depth metrics (0-1) |

The queue metrics can also be published to AWS CloudWatch by setting `ENABLE_AWS_CLOUDWATCH_METRIC_PUBLISHING=true` to configure auto-scalers based on AWS metrics.

### Reducing ClickHouse reads within the ingestion processing
Expand Down