Reducing ClickHouse disk usage in self-hosted Langfuse

Reclaiming disk on a self-hosted Langfuse ClickHouse starts with knowing which tables grew and which mechanism deletes the data. This page covers the options, the order of work and the checks that keep trace history safe.

On this page

Reducing ClickHouse disk usage in self-hosted Langfuse starts with knowing what grew

When the ClickHouse volume in a self-hosted Langfuse fills up, the first step is finding out which tables grew, because the fix depends on that answer. ClickHouse holds the analytical trace data that Langfuse reads for its dashboards, filters and evaluations, so its disk use follows two things: how much data your applications send and how long you keep it. A busy ingestion pipeline with long retention will fill a volume that a small team with short retention never notices. Reducing disk usage means either shrinking what is stored, shortening how long it is kept, or adding capacity, and only the first two change the growth curve.

Teams usually need this work in three situations: a disk alert fires on the ClickHouse host or volume, a major upgrade is being planned and the team must know how much headroom a backfill will need, or the storage cost of the volume is under review. The Langfuse self-hosting documentation describes the same codebase that runs Langfuse Cloud, so the data model you are working with is the one the vendor documents. Confirm against your own Langfuse version which tables hold observations, scores and the event store, and which ClickHouse system tables are present, since table names and defaults can change between releases.

Before changing anything, record the current size of each table, the partition layout, and the ingestion rate over a normal week. Ask your Langfuse vendor or check the release notes for your version whether any retention setting applies to ClickHouse system log tables, and whether a retention job runs on a schedule and how long it is allowed to take. Those answers decide whether the next steps are configuration changes, scheduled clean-up or a capacity decision.

Where ClickHouse disk goes in a self-hosted Langfuse

The diagram starts with an application SDK or OpenTelemetry client sending traces to Langfuse Web, which hands work to Langfuse Worker. The worker writes trace and observation rows into ClickHouse, and the retention job removes rows that fall outside the retention you configure. ClickHouse writes its own server activity to system log tables and applies TTL rules where they are set. The operator owns the disk volume that holds the data, its sizing and the backups. When disk use grows, check each branch separately: first confirm which tables are growing, then decide whether the growth comes from Langfuse data or from ClickHouse logs.

ClickHouse writers grouped by who controls each part of the disk footprint.

Which reclaim option fits which disk problem

This table compares the ways to reclaim ClickHouse disk in self-hosted Langfuse, from retention policies to adding capacity. Read each row against the disk problem you actually have, then check who owns the change and what must be confirmed before you run it. The main takeaway is that deleting data and adding capacity solve different problems, and the 3x backfill headroom applies to any plan that reprocesses historic data.

OptionWhen it fitsWhat it deletes or keepsWho owns the change and what to confirm
Langfuse data retention policiesTrace and observation data grows faster than the business needs it, and you want a project-level or organization-level age limitDeletes Langfuse trace data older than the configured window; keeps data newer than itNeeds an Enterprise license key. Platform team and data owner agree the window. Confirm how the policy reaches ClickHouse data and how long deletion takes
ClickHouse TTL rules on Langfuse tablesYou need a table-level expiry outside the Langfuse UI, and you have confirmed the table and column names for your Langfuse versionExpired rows are removed by ClickHouse during background merges; the timing is not immediateDBA or platform team owns it. Test on a non-production copy first. Confirm the schema for your version and that no Langfuse migration resets the rule
Opting out of or limiting ClickHouse system log tablesSystem log tables such as query and metric logs are a large share of disk and you do not need them for troubleshootingRemoves ClickHouse's own operational logs; keeps all Langfuse trace, prompt and evaluation dataPlatform team owns the ClickHouse server configuration. Confirm the log settings for your ClickHouse version and keep enough history for incident investigation
Manual partition removalA specific time range is confirmed as safe to delete and a retention job is failing or too slowDrops whole partitions in one operation; deleted data cannot be recovered from ClickHouseSenior DBA only, with a verified backup first. Confirm partition keys with the Langfuse schema for your version and check that dependent jobs will not fail
Retention job timeoutsRetention deletes run but do not finish, so old data keeps accumulatingDoes not delete data itself; changes how long the retention job is allowed to run before it stopsPlatform team adjusts settings in coordination with Langfuse support. Confirm the timeout setting name and default for your version before changing it
Adding disk or a larger volumeData is legitimately needed, the growth rate is steady, and deletion is not an option for compliance reasonsKeeps all data; increases capacity onlyInfrastructure team owns storage. Confirm volume expansion steps for your platform and plan for the 3x ClickHouse disk headroom during any v4 backfill
Sizing the 3x backfill headroomYou plan a v3 to v4 upgrade or any backfill of historic data into the observations-first modelKeeps everything; reserves free space so the backfill can runUpgrade owner plans it before cutover. Confirm current disk usage and free space against the 3x guidance in the v4 upgrade guide before starting

How retention deletes data and why timing matters

Retention in self-hosted Langfuse works at two levels, and operators need to know which one they are changing before they expect disk to free up. The Langfuse-level data retention policy is an Enterprise license feature that tells the application how long trace data should be kept. A database-level TTL is a ClickHouse rule attached to a table that removes rows or parts once they age out. The two can coexist: Langfuse may issue deletions through its own jobs while a TTL on the same table also expires rows independently. Before changing either, confirm in your own environment which controls are active, which tables carry TTL clauses, and whether a policy you set in the UI is actually being applied by the worker.

Deletion is asynchronous, and disk space does not return at the moment rows are removed. ClickHouse marks rows as deleted or expires them during background merges, then removes the underlying data parts later. Until merges complete, system.parts and disk metrics can show little change even though a retention job has run. Measure disk usage before and after a job over a period long enough for merges to finish, and compare row counts with byte counts. Retention jobs can also time out on large datasets. Do not assume a run succeeded because the setting is saved. Check the worker logs for job completion, confirm the expected date range was processed, and rerun or split the work if it stopped partway.

A major upgrade can change the work a retention or disk plan requires. The Langfuse v3 to v4 guide moves to an observations-first ClickHouse data model, so the tables involved in storage and deletion differ from the ones you measured on v3. Backfilling historic data into the new model needs substantial temporary space, and the guide advises about 3x ClickHouse disk headroom for that backfill. Plan that headroom before starting the upgrade, not after the disk fills, and recheck table sizes and retention behavior once the migration completes. The Langfuse v3 to v4 upgrade guide lists the exact requirements for the target version.

Measure the largest tables before changing retention

This sequence establishes how fast disk is filling, which ClickHouse tables hold the space, and whether that space belongs to Langfuse data or system logs, so retention changes target the right data after a verified backup.

  1. Record current disk use per volume

    The operator records used and free space for every volume that holds ClickHouse data on each ClickHouse node, using the host's own disk tools or the platform's storage metrics. Record the same figures at a fixed interval, for example daily, across a period that includes normal ingestion. Store the readings with timestamps in your monitoring or a shared sheet. This step is done when you have at least two readings separated by a full ingestion cycle and you can state the growth rate per volume. If the disk is shared with PostgreSQL, Redis or blob storage, note that now so growth is not misattributed.

  2. List tables by on-disk size and row count

    Connect to ClickHouse with a read-only account and query the system views that report active parts, bytes on disk and row counts per table and database. Confirm the exact view names and column names in your ClickHouse version's documentation before running them, since these have changed across releases. Sort by compressed bytes on disk, then compare with row counts to separate tables that are large because they hold many rows from tables that hold a few very wide rows. Save the output. This step is done when you have a ranked list of the top tables with their size, row count and database name, and the top entries account for most of the used space.

  3. Match the largest tables to Langfuse data or system logs

    Map each large table to its origin. Tables belonging to Langfuse's own data model hold trace, observation, score and related event data, while ClickHouse system log tables are created by the server itself for query and part logging. Check the table names and the database they sit in against the Langfuse self-hosting documentation for your version, and confirm which tables the Langfuse migrations create. Mark each large table as Langfuse data, system log or unknown. This step is done when every table in the top of the ranked list has a label and any unknown tables have been raised with the team that operates ClickHouse.

  4. Confirm the Langfuse version and retention settings

    Record the Langfuse version running in each environment and the Langfuse Web and Worker image tags. Check whether data retention is configured for the project or organization. Data retention policies are an Enterprise license feature in self-hosted Langfuse, so confirm whether your instance has a valid license key before assuming retention can be set in the UI or API. If no license is present, retention changes will need to be made directly in ClickHouse, which should be reviewed with Langfuse documentation for your version. This step is done when you have a written record of version, license status and any existing retention configuration.

  5. Verify the backup before any delete

    Before any table is dropped, altered or has data removed, take a backup of the affected tables and confirm it can be restored. Use the ClickHouse backup tooling your team has validated, store the backup on separate storage, and test the restore on a non-production instance by checking row counts and a sample query against the source. Record the backup identifier and the row count it captured. Ensure there is enough free disk for the backup itself, since writing it can consume the space you are trying to reclaim. This step is done when a restore test has passed and the backup record is filed with the change request.

  6. Compare growth against the ranked tables

    Repeat the size query after the same ingestion period used in the first step and calculate the growth per table. Tables whose size grew in line with trace volume are Langfuse data candidates for retention. Tables that grew steadily without matching trace volume may be system logs that need their own setting. Compare the growth totals with the disk growth recorded in step one to confirm the table list explains the increase. This step is done when the growth per table adds up to within a reasonable margin of the volume-level growth, and each candidate for retention has a documented reason.

Choosing a fix by how the disk filled

Normal ingestion adds data in a line that follows your traffic, so disk climbs at a rate you can forecast. The usual causes are higher trace volume, larger payloads such as long prompts and completions, and more scores attached to each trace. Start by checking whether growth tracks request volume or jumped at a specific point.

  • Confirm the trend: Record the ClickHouse data directory size on a fixed schedule and compare it with trace counts from your own usage data.
  • Find the largest tables: Query ClickHouse system tables for bytes per table and partition, and note which Langfuse tables account for most of the space.
  • Review payload size: Large inputs and outputs often drive more growth than trace count, so check the average size of recent traces.
  • Set retention deliberately: Decide how long each class of data must stay. Data retention policies in the UI need an Enterprise license key, so confirm your edition first (Langfuse license key docs).
  • Add capacity early: Expand disk before the trend reaches your alert threshold, since every retention cut removes history that audits or debugging may need.

Before you cut retention on a healthy system, confirm that the growth rate matches your traffic, because deleted trace history cannot be recovered from ClickHouse.

Security and data handling while deleting trace data

Deleting trace data reduces disk use but also removes evidence, and it can touch personal data that operators are obligated to protect. The controls below connect backups, approvals, separation of duties, personal data handling, access, and monitoring so that each cleanup is recoverable, traceable and reviewable by your compliance team.

Back up and test restore first

Take a ClickHouse backup and confirm that a restore works on a non-production copy before any delete or TTL change runs. A backup that has never been restored tells you little about recovery. Record the backup identifier, the time taken, the table list and the restore test result in the change record. Ask your team who owns the backup tooling and where the copies are stored, since those copies hold the same trace content as the live cluster.

Langfuse upgrade guide

Change records for retention changes

Treat every change to retention settings as a controlled change with a written reason, the scope of affected data, the expected effect on disk, and a rollback step. Keep the record with the platform's change history so an auditor can trace why trace data disappeared from a given date. Name the approver and the date of approval before the change window opens.

Separate who changes and who reviews

Limit the people who can alter retention settings or run deletion jobs to a small operator group, and assign review of those changes to someone outside that group. In an Enterprise deployment, project-level RBAC roles and data retention policies are gated by a license key, so confirm which roles you can assign before you design the split. Where the platform cannot enforce this, document the manual review step and keep the evidence.

Personal data left in backups

Deleting data from the live cluster does not remove copies held in older backups. Decide with your privacy and legal teams how long backups persist, whether they can be expired on a schedule, and how a deletion request for a specific trace is handled when only a backup still contains it. Document this decision so it matches the retention commitments in your records of processing.

Access control on ClickHouse and its volumes

Restrict network access to ClickHouse ports to the Langfuse services and approved operator hosts, and limit operating system access to the data directory and disk volumes. Backups and snapshots of those volumes need the same protection as the live data, because trace content can contain prompts, outputs and user identifiers. Confirm the access list in writing and review it after each cleanup.

Monitor the platform during cleanup

Watch ingestion, worker queue length, ClickHouse memory and disk, and error logs while a retention job or large delete runs. A cleanup that slows ingestion or fills disk during a merge can cause data loss elsewhere in the pipeline. Set a stop condition in advance, such as a disk threshold or a rising error count, and name the person who can halt the job.

Questions teams ask before reducing ClickHouse disk usage

How much effort does reducing ClickHouse disk usage take?

The effort depends mainly on how much data sits in ClickHouse, how many tables hold the bulk of it, and whether you have a tested backup and restore path before you change anything. A small instance with one large table and a current backup is a short, contained task. A large instance with several growing tables, unclear retention requirements and no restore test takes more time, because each table needs a decision and each change needs verification. Retention changes also need a plan for data already stored, not only for new data. Ask any provider to break its quote into discovery, the retention decision, the change, and verification. Licensing matters too: the data retention policies that Langfuse documents for self-hosted use need an Enterprise license key, so confirm whether you need that before you plan the retention side of the work.

How long does a ClickHouse disk reduction project take?

Duration is set by the same factors as effort: data volume, the number of tables involved, how much of the data must be kept for compliance or product needs, and how quickly your team can approve a maintenance window. Retention jobs on large tables can run for a long time, so verification and any timeout tuning often take longer than the configuration change itself. Discovery usually comes first, because you cannot choose a retention period until you know which tables dominate disk use and what each one holds. Treat any duration you hear before that discovery as an assumption. Ask the provider to state which of these steps it has assumed and what would change the schedule.

What does the work need from our team?

You will need to give access and make a few decisions. The work needs read access to the ClickHouse instance and its system tables, access to the Langfuse deployment and its configuration, and a maintenance window agreed in advance for changes that affect ingestion or queries. You also need a backup target with enough space and a restore procedure that someone has tested. On your side, a named owner should decide the retention period for each data type, confirm which compliance obligations apply, and approve changes. If you run ClickHouse yourself, a database administrator should review any change to table settings or system log configuration before it goes live.

Can our internal team reduce ClickHouse disk usage without a partner?

Yes, if your team already operates ClickHouse and PostgreSQL in production and has someone comfortable reading table sizes, TTL settings and worker logs. The work is mostly careful measurement, a documented retention decision, a tested backup and a controlled change. Teams without recent ClickHouse operations experience tend to slow down on two points: confirming which tables are safe to trim, and recovering if a retention job times out partway through. A partner can add a second reviewer and a written runbook, but the decision on what data to keep stays with you. Whichever path you choose, make sure the person doing the work has tested restore access before the first change.

What does a fixed-scope DeployOpen engagement include for this work?

DeployOpen works from a written scope that is agreed before work starts. For this topic, a typical scope covers reviewing the current ClickHouse footprint, identifying the largest tables, agreeing retention settings with your team, implementing the changes in your infrastructure, checking that retention jobs complete, and documenting the procedure for your operators. Deliverables and the timeline are written into that scope. Ongoing monitoring, upgrades and continuous checks are separate and can be covered by a retainer. Ask for the exact list of tables, environments and deliverables in the scope document, and confirm what happens if discovery shows the problem is larger than expected.

What should we ask for in a quote for this work?

Ask for the written scope first, because a quote follows from it. Look for these parts: a discovery step that measures table sizes and retention needs, a list of the environments and tables covered, the retention decisions you must make, the backup and restore verification steps, the maintenance window assumptions, and the deliverables such as a runbook and a before and after measurement. Ask which items are one-time and which recur, and what is excluded, such as Enterprise license procurement or ClickHouse capacity changes. For plan details and the cost of Enterprise support, check the vendor's self-hosted pricing page, since Langfuse publishes its plan structure there. DeployOpen does not publish a price list, so the quote is the only figure to compare.

What is the first step before changing any retention setting?

Measure before you change anything. Identify which ClickHouse tables hold most of the disk use and confirm how each is written to and read from. Check that you have a recent backup and that a restore has been tested. Then record the retention requirement for each data type with the people who own compliance and product decisions. Only after those steps should you apply a TTL or retention change, and then verify on a copy or a small window first. Changes applied without this baseline make it hard to tell whether the new setting worked, and hard to recover if a job removes data that someone still needs.

Limits to confirm for your Langfuse and ClickHouse versions

Retention and cleanup on ClickHouse depend on which Langfuse version you run, what your license includes and how much data sits in the instance. Confirm these limits first so that a disk reclaim plan does not stall on a version gap, a missing feature or a retention job that cannot finish.

Langfuse and ClickHouse version match

Langfuse v4 requires ClickHouse 25.12 or later, and 26.4 is the recommended release. Read the v3 to v4 upgrade guide against your running Langfuse and ClickHouse versions, and note that the guide moves the data model to observations-first. Changes to table layout or TTLs made on an older version may not carry over cleanly, so confirm the exact target before editing any table.

v3 to v4 guide

Retention controls on your license

Data retention policies are an Enterprise license feature for self-hosted Langfuse. Check whether your instance has a license key that enables them before you plan to rely on Langfuse-managed retention. If you do not have one, plan disk recovery through ClickHouse-side methods and confirm with the vendor how those interact with Langfuse's own deletion jobs.

License key docs

Retention job behavior at your data size

Ask how the retention job selects and deletes rows, how long it runs on your data volume and what happens when it hits a timeout. A job that works on a test instance can stall on years of traces. Measure job duration on a copy of production data and watch for jobs that restart or leave partial deletions behind.

TTL changes and the upgrade path

Table TTLs set in ClickHouse can conflict with Langfuse migrations or with the observations-first model that v4 introduces. Before adding or changing a TTL, confirm with the vendor whether the migration expects the table as shipped, and record the current table definitions so you can restore them. Test the upgrade on a clone with the same TTL settings.

Replication and cluster topology

Deleting rows, dropping partitions and changing TTLs behave differently on a replicated or clustered ClickHouse than on a single node. Confirm your topology, the replication settings and whether DDL runs on all replicas. A change applied to one node can leave replicas disagreeing about which data exists.

Minimum memory and CPU for ClickHouse

The scaling guide lists 2 CPU and 8 GiB as the minimum for ClickHouse, with at least 16 GiB of memory for larger deployments. Heavy cleanup, merges and backfills use extra memory and disk headroom, and the v4 guide advises about 3x ClickHouse disk headroom when backfilling historic data. Size the node for the cleanup work, not only steady-state ingestion.

Scaling guide

How DeployOpen scopes and delivers ClickHouse disk work for Langfuse

DeployOpen treats ClickHouse disk reduction as a scoped change to your Langfuse data store, not a one-off cleanup. We first measure which tables hold the space, agree on retention and TTL decisions with your data owners, then apply and verify the change in your own infrastructure with a documented rollback path.

How we scope

  • Written scope covers the disk findings, retention decisions, TTL changes and system log settings to be applied to your ClickHouse.
  • We confirm which Langfuse data classes must be kept, and which are candidates for shorter retention, with your team before any change.
  • Engagements are fixed-scope, with deliverables and timelines agreed in writing before work starts.

How we build

  • We record table sizes and disk usage on your ClickHouse and take a backup before any retention or TTL change is applied.
  • We apply TTL and system log settings in a staging copy first, then in production, with each change tracked in version control.
  • We test retention job timeouts under realistic data volumes and confirm the job completes without leaving partial deletions.

How we hand over

  • You receive a findings report listing the largest tables, the applied retention settings and the measured disk recovered.
  • We document the rollback steps, the monitoring checks for disk growth and the owner for each retention decision.
  • Your operators walk through the runbook so the retention job and disk alerts are understood by your own team.

How we support

  • Ongoing support, upgrades and continuous testing are available as retainers after the initial change.
  • Retainers can cover periodic disk growth reviews, especially before major Langfuse upgrades that backfill data.
  • We confirm retention and disk headroom requirements for your ClickHouse version before each planned upgrade window.

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.