Urgent.News

What's breaking now, across thousands of outlets.

Tech

Is Your Data Lake Actually A Landfill?

Why I chose this topic: I spent three weeks debugging a "simple" read query that took four minutes to return ten rows because the metadata layer had ballooned to 200,000 snapshots. I’m writing this so you don’t have to explain to your CTO why the data platform is hemorrhaging AWS credits. You ship the job. It passes CI. Your dbt tests are green, and the data lands in S3 right on time. Then, three…

Your data lake may appear to be a storage solution, but it can quickly become a data graveyard filled with unnecessary snapshots and files. This is especially true if you are not implementing proper maintenance practices. A simple read query can take a long time to return data due to an overwhelming amount of metadata. This leads to performance issues that can be costly and frustrating for your team.

The main issue lies in the fragmentation and increased metadata overhead that results from frequent streaming writes and micro-batching. Every time you commit a transaction, Iceberg creates a new snapshot, and every time you overwrite a partition, you leave behind orphaned files. These files accumulate over time, consuming storage space and negatively impacting performance.

To address this issue, you should compact small files, which are the primary reason for slow S3 LIST calls. This can be done using Spark’s rewriteDataFiles procedure. Schedule this process to run periodically instead of every single commit to avoid crashing your cluster. Choose a suitable strategy for your use case, such as 'bin-pack' for general purposes or 'sort' for high-cardinality filters.

Monitor the memory usage of the rewrite-data-files job, and increase executor memory if it fails with an OOM error. Aim for larger file sizes (128MB to 512MB) instead of numerous small ones.

Another critical aspect is expiring snapshots with a strict retention policy. If you perform 50 writes a day, you can accumulate over 18,000 snapshots in a year. Set a default retention period of 7 days, but have a separate safety net for older commits. Use the expire_snapshots procedure to remove references to expired snapshots, ensuring that at least the most recent commits are retained.

Lastly, clean up orphaned files that exist in storage but not in the metadata. Running the remove_orphan_files procedure can help you save money by deleting these unnecessary files. Be cautious with the older_than parameter and ensure that you leave a buffer for production jobs. Following these steps will help you avoid the zombie file scenario and keep your data lake from turning into a landfill.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

More from Wednesday 16 September →