Kafka to Iceberg: Why Commits Time Out, Why Small Files Pile Up, and How to Pick an Ingestion Path
Where the commit cycle breaks, and how to choose between a Kafka Connect sink, a Flink job and a managed service
Kafka-to-Iceberg pipelines break at the commit step: every sink writes data files continuously but publishes them to the table only on a commit cycle, and that cycle controls both timeouts and file counts. The Apache Iceberg Kafka Connect docs set the default commit interval to 300,000 ms (5 minutes) and the commit timeout to 30,000 ms (30 seconds). Short intervals produce many small files. Long intervals add latency. A slow commit fails outright.
Key Takeaways
- •The Iceberg Kafka Connect sink commits every 300,000 ms (5 minutes) by default and times out a commit after 30,000 ms, so the commit interval is your first tuning lever for both latency and file count.
- •Flink commits to Iceberg only after a checkpoint succeeds, so your checkpoint interval is your commit interval and your small-file rate.
- •File counts grow with parallel writers multiplied by active partitions multiplied by commits per hour, not with data volume alone.
- •Compaction is part of the design, not an afterthought: choose the ingestion path that tells you who runs it.
- •Pick the path from latency target, partition cardinality and who owns operations, in that order.
Why the commit cycle is the failure point
An Iceberg table changes only when a commit swaps in a new metadata file that points at new data files. A streaming writer cannot commit per record, because each commit costs object-store writes and a metadata update. So every ingestion path buffers rows into data files and batches the commit. That batch boundary is where both of the common failures originate.
The first failure is a timeout. A commit has to coordinate every writer, flush files, and write metadata. If any participant is slow, the whole commit stalls. A widely read dev.to post on Kafka-to-Iceberg at scale quotes a Kafka transaction error, "Timeout expired after 60000ms while awaiting TxnOffsetCommitHandler", and describes it ending in a killed task that needs manual intervention. The author works on a competing storage-native approach, so we treat the post as a field report, not a benchmark.
The second failure is silent. Files keep arriving, queries slow down, and nothing alerts until planning time or storage listings climb. Neither failure shows up in a row-count check, which is why we think of them as operations problems rather than data-quality problems.
Path one: a Kafka Connect sink
The Connect sink is the lowest-friction option if you already run Connect. Per the Iceberg Kafka Connect docs, it offers exactly-once delivery built on KIP-447, which requires Kafka 2.5 or later. A coordinator gathers the workers' file lists and commits them on the configured interval, with defaults of 300,000 ms for the interval and 30,000 ms for the commit timeout.
The same page documents that the coordinator can be set to terminate after consecutive commit failures, with a default of 1. In our reading, that default means one bad commit stops the coordinator, so you need alerting on connector state, not just on consumer lag. A paused coordinator looks like a healthy consumer group until the table stops advancing.
What the sink leaves to you: compaction, snapshot expiry and orphan-file cleanup are separate jobs. Plan who runs them before the first production topic goes live.
Path two: a Flink job
Flink gives you the most control and the most to operate. According to the Iceberg Flink writes docs, the commit happens after a successful checkpoint, in the notifyCheckpointComplete callback, and uncommitted data stays in temporary files until then. So the checkpoint interval is the commit interval. The docs' own monitoring example uses a 5-minute checkpoint and alerts when time since the last successful commit exceeds 60 minutes.
File counts follow from that design. Each parallel writer closes its open files at every checkpoint, so a job with many writer subtasks and many active partitions can emit a small file per subtask per partition per checkpoint. The docs do not state this formula; it is our inference from the commit-on-checkpoint model, and you should verify it against your own table's file listing.
Illustrative arithmetic, not a measurement: 10 writer subtasks, 200 active partitions and a 1-minute checkpoint could produce up to 2,000 files a minute. The same job at a 5-minute checkpoint produces a fifth as many. The docs also note that rewriteDataFiles() compacts small data files and that the sink can run maintenance tasks after each commit, so compaction can live inside the same job.
Path three: a managed topic-to-table service
A third path is a managed service that materializes topics as Iceberg tables for you. AWS publishes a guide on choosing a streaming ingestion path for Iceberg tables, which is a useful sign that the choice is an architecture decision with several valid answers rather than a default.
What you buy with a managed service is that commit tuning and compaction become someone else's job. What you give up is control over partitioning, schema evolution rules and the commit interval. Check the service's documented limits on column drops, schemaless topics and how it handles updates before you commit a topic to it, because those limits are where migrations get stuck.
We do not think a managed service is the right default for every team. It wins when the team has no capacity to run connectors or Flink jobs. It loses when you need custom partition transforms or row-level upserts with strict ordering.
Five steps to pick a path
Step 1: Set the latency you actually need. If dashboards read the table hourly, a 5-minute commit interval (the Connect default) is already faster than the consumer. Write the number down. Most small-file pain comes from interval settings chosen for a latency nobody needed.
Step 2: Count active partitions, not total partitions. Writers hold open files only for partitions receiving data in the current commit window. A table partitioned by hour with late-arriving data has far more active partitions than one partitioned by day. Multiply writers by active partitions by commits per hour for a worst-case file rate.
Step 3: Decide who owns compaction. This is the deciding question in our experience. If the answer is "nobody yet", pick the path where it is included, or schedule a rewrite job before launch.
Step 4: Test the commit under load. Run the pipeline at peak throughput and watch commit duration against the 30,000 ms timeout default for Connect, or checkpoint duration for Flink. If commits take more than half the timeout at peak, lengthen the interval or reduce writers.
Step 5: Add alerts on table advance, not consumer lag. The Flink docs suggest alerting on elapsed seconds since the last successful commit. Apply the same idea to any path: page when the table snapshot stops moving.
How we handle this with the Streaming Agent
The commit problems above sit between systems: broker settings, connector state, a schema registry and the table's file layout. Our Streaming Agent works on topic governance, schema registry and delivery monitoring, so a question like "why did the table stop advancing at 02:00" can be traced from the topic through the sink to the last snapshot instead of across four dashboards.
We do not claim an agent removes the need to pick a path. It shortens the time between a stalled commit and the person who knows why, and it can flag schema changes upstream that would break a sink before they reach it.
Frequently Asked Questions
Why do Kafka-to-Iceberg commits time out?
A commit needs every writer to flush and report before metadata is written. A slow writer, a busy catalog or a Kafka transaction stall can exceed the limit. The Iceberg Kafka Connect docs default the commit timeout to 30,000 ms, so check commit duration at peak load before blaming the network.
How do I stop small files from piling up?
Lengthen the commit or checkpoint interval, reduce writer parallelism relative to active partitions, and run compaction. The Flink docs describe rewriteDataFiles() for compacting small data files, and the Connect sink leaves compaction to a separate job.
Is a 5-minute commit interval a good default?
It is the Kafka Connect sink default per the Iceberg docs, and it is a reasonable start when consumers read hourly. Shorten it only when a consumer needs fresher data, and expect more files each time you do.