构建 Apache Iceberg 湖仓架构——构建摄入层架构

0 阅读55分钟

本章内容包括:

  • Ingestion performance、reliability 和 latency 需求
  • 比较 batch、micro-batch 和 streaming ingestion strategies
  • Iceberg 如何处理 data writes、commits 和 conflict resolution
  • Spark、Flink 等 ingestion technologies
  • 面向 schema evolution、data quality 和 auditability 的 ingestion patterns

Ingestion layer 是 Apache Iceberg lakehouse 的起点。它是 raw data 进入系统的地方,无论数据来自 operational databases、message queues、cloud services,还是 external vendors。Storage layer 决定数据如何被保存,而 ingestion layer 决定数据如何到达:多快、多干净、多可靠。

设计这一层,不只是选择一个 ETL tool。你必须考虑 latency tolerance、throughput capacity、schema evolution 和 fault recovery。这些需求在不同 use cases 中差异很大。有些 pipelines 交付高频 transactions,必须在数秒内处理;另一些可能会将夜间 logs 或 slowly changing dimensions 打包成 batch。你的 ingestion layer 必须同时支持这些场景,而不牺牲性能或一致性。

本章建立在 storage design 的基础之上,帮助你评估 ingestion strategies 和 technologies。我们会识别塑造 ingestion architectures 的关键需求,包括 performance、reliability 和 operational complexity。接下来,我们会比较 ingestion models,也就是 batch、micro-batch 和 streaming,以理解每种模型最适合的位置。然后,我们会探索 Iceberg 如何管理 data writes,即使在 distributed environments 中也能提供 isolation 和 atomicity。

最后,我们会考察与 Iceberg 良好集成的 ingestion tools,以及它们如何支持不同 architectural patterns。和 storage 一样,目标不是给出一套 one-size-fits-all solution,而是为你提供一个 framework,帮助你选择工具并设计 ingestion flows,使其与组织需求和约束对齐。

6.1 Ingestion Requirements

在选择工具或设计 ingestion pipelines 之前,必须先定义 ingestion layer 需要交付什么。和 storage layer 一样,ingestion 受到一系列技术、运维和组织因素影响。有些 pipelines 要求 high throughput 和 low latency,另一些则优先考虑 fault tolerance、schema evolution 或 auditability。如果没有清晰 requirements,很容易过度工程化,或者让 ingestion architecture 与业务需求错位。

第 4 章描述的 audit process 应该已经揭示了数据如何流入平台、它变化频率如何,以及交付时有哪些约束。这些洞察对塑造 ingestion decisions 至关重要。例如,real-time analytics 可能需要 streaming ingestion、low-latency writes 和 exactly-once guarantees。相比之下,加载 historical archives 的 batch jobs 可以容忍更高 latency,但需要稳健处理 schema drift 和 file-level optimization。

本节探索最常驱动 ingestion design 的核心 requirement categories:throughput and latency、reliability and fault tolerance、schema management,以及 operational complexity。理解这些维度,会帮助你基于 ingestion tools 和 patterns 的特性,以及它们与数据和平台现实的匹配程度来评估它们。

6.1.1 Ingestion Throughput 和 Latency

每条 ingestion pipeline 都必须平衡 throughput 和 data freshness。Throughput 衡量系统在一定时间内可以摄入多少数据。Data freshness 反映新数据在生成后多快可以用于查询,如图 6.1 所示。

image.png

图 6.1:系统在同一时间窗口内能处理的 records 越多,它可以承受的 throughput 就越高。

Latency 衡量数据生成后多快可以用于查询,如图 6.2 所示。这两个 metrics 会塑造 lakehouse 对用户预期和 operational demands 的响应能力。

image.png

图 6.2:如果两个系统处理相同数据,能用更短时间交付数据的系统 latency 更低。

不同 use cases 对 data freshness 有不同要求。Real-time dashboards 和 fraud detection systems 可能要求数据在数秒内可用,而 daily reports、financial close processes 或 regulatory exports 可以容忍分钟级或小时级延迟。尽早定义这些预期非常关键,因为它们会直接塑造 ingestion architecture 的设计,并避免对 “real-time” 的感知需求与 analytical systems 实际可支持能力之间错位。

必须认识到,Apache Iceberg 是为 analytical(OLAP)workloads 设计的,而不是 transactional(OLTP)systems。虽然 Iceberg 支持 near-real-time ingestion,但通常不建议 commit frequencies 快于几秒,实践中即使 5 秒 commits 也已经算激进。那些要求 sub-second visibility 或 continuous record-level updates 的 workloads,更适合由 OLTP databases 或 streaming state stores 支撑,而 Iceberg 则作为 analytical sink,而不是 system of record。

在这些约束内,Apache Flink 等 streaming frameworks 或 Kafka-based ingestion pipelines 可以以受控 commit intervals 向 Iceberg 提供 low-latency、continuous writes。Apache Spark 这类 batch-oriented tools 擅长 scheduled 或 backfill jobs 的 high-throughput ingestion,但会引入更高 end-to-end latency。Airbyte 等 integration frameworks,以及 Amazon Data Firehose 或 Qlik 等 managed services,则提供额外 ingestion paths,用 operational simplicity 换取灵活性。选择这些选项时,应由与 Iceberg analytical execution model 兼容的 freshness requirements 指导,而不是单纯由 real-time expectations 指导。

Throughput constraints 往往更偏技术性。它们受 source data 的 size 和 structure、compute resources 的可扩展性,以及 source 和 destination systems 之间 network bandwidth 影响。Bottlenecks 可能突然出现,从缓慢的 JDBC sources、network congestion,到 processing engine 中 parallelism 不足,都可能成为问题。

在基于 Iceberg 的 lakehouses 中,throughput 和 latency 与 write semantics 紧密耦合。如果管理不当,高频 writes 可能导致过度 metadata growth 和 file fragmentation,二者都会随着时间推移降低 query planning 和 execution 性能。Micro-batching 和 periodic compaction 等技术,可以通过将小 writes 合并成更大 files,并减少 table 必须跟踪的 metadata entries 数量,缓解这些影响。通过控制 commit frequency 并合并 data files,团队可以在 ingestion latency、长期 table health 和可预测 query performance 之间取得平衡。

定义 ingestion performance requirements 时,必须将预期锚定在具体 use cases 上,而不是假设一个单一 scalability target。有些 workloads 优先 steady、predictable throughput;另一些必须容纳短时 bursts 或 seasonal spikes。Benchmarking peak 和 sustained ingestion rates 时,应放在数据如何产生、如何消费,以及这些 patterns 预期如何演进的上下文中完成。通过将 scalability expectations 与具体业务场景绑定,团队可以避免为不太可能出现的极端情况过度工程化,同时确保 ingestion pipeline 在需求变化时保持韧性。

6.1.2 Reliability 和 Fault Tolerance

Reliability 是任何 ingestion system 的基石。它定义 data pipelines 在面对 failures、retries 和 interruptions 时,能否在不损害 data quality 或 system stability 的情况下正常处理。任何架构中,不可靠的 ingestion 都可能导致 data loss、inconsistent table states 和 downstream analytics failures,而这些都会侵蚀对平台的信任。

Fault tolerance 首先要理解 ingestion pipeline 的端到端 delivery guarantees,而这些 guarantees 不仅由 ingestion engine 决定,也受 data source 本身特征影响。有些 systems 提供 at-least-once delivery,也就是 failures 后 records 可能被重新处理,从而可能产生 duplicates,必须在下游处理。Exactly-once semantics 只有在 source 是 replayable 时才可实现,因为 processing engine 可以在 failure 后 deterministic 地重新读取数据。那些只发出一次数据、没有 replay capability 的 sources,会天然限制 downstream systems 能提供的 guarantees。

Apache Flink 等现代 stream-processing engines 在搭配 replayable sources 时,可以通过 checkpointing 和 two-phase commit protocols 协调 state、offsets 和 commits,从而提供 exactly-once processing semantics。在 Iceberg lakehouse 中,这使数据可以写入 tables,并确保来自某个 checkpoint 的所有 changes 要么全部 committed,要么一个都不提交,即使在 retries 或 restarts 之后也是如此。如图 6.3 所示,ingestion engine 与 Iceberg transactional commit model 之间的这种协调,对于构建 reliable、fault-tolerant ingestion pipelines 至关重要。

image.png

图 6.3:通过使用 checkpointing 跟踪哪些 incoming records 已成功提交,系统就知道 failure 发生后应重试哪些 records。

Iceberg 的 write model 支持 atomic、snapshot-based commits,即使在 distributed environments 中,也有助于确保 consistency。如果一个 job 在 commit 前失败,readers 看不到任何 partial writes,从而降低产生 incomplete 或 corrupt table states 的风险。但 ingestion tool 仍然负责协调 retries,并避免引入 conflicting changes 或 duplicates。

Reliability 的另一个关键方面是 resumability。从 databases、APIs 或 message queues 等 external systems 摄入数据,通常需要跟踪 offsets、timestamps 或 change identifiers,以防止 outages 期间重复处理旧数据或跳过新 records。稳健 pipelines 会将这些 state 持久化到外部,并在恢复后从 last known good position 继续 ingestion。在可能的情况下,采用 idempotent consumer pattern,也就是将 ingestion 设计成可以安全地重复处理相同数据而没有副作用,可以增加额外 fault tolerance,并简化 recovery logic。

最后,observability 对可靠 ingestion 至关重要。Pipelines 应输出反映 data volume、error rates、retry counts 和 commit statuses 的 metrics 和 logs。这些 indicators 帮助团队快速检测 anomalies,并在 data integrity 受损之前采取纠正措施。

为 reliability 设计意味着要规划不可避免的情况:network failures、service restarts、bad records 和 resource contention。Resilient ingestion layer 会预判这些场景、优雅恢复,并在整个过程中提供可见性。

6.1.3 Schema Management 和 Evolution

Schema evolution 是现代数据平台中的日常现实。随着业务需求变化和 source systems 改变,incoming data structure 往往会演进。Ingestion layer 必须能够处理这些 changes,而不破坏 pipelines、不引入 data inconsistencies,也不需要人工介入。

Apache Iceberg 在设计上支持 schema evolution,可以在不重写已有 data files 的情况下,执行添加、重命名、重排序或删除 columns 等 changes。这得益于 Iceberg 使用 stable field IDs,它们独立于 column 在 schema 中的 name 或 position,保留每个 column 的 logical identity。因此,在旧 schemas 下写入的数据,可以与新 schema definitions 安全共存,并且仍然以一致方式可查询。

截至 version 3,Iceberg 也支持 variant data types,使 semistructured 或 evolving attributes 可以被捕获,而不必立即做出刚性的 schema decisions。Variants 在从 event streams、APIs 或 logs 等 sources 摄入数据时尤其有用,因为这些场景中的 fields 可能出现、消失或随时间变化形态。通过结合 explicit schema evolution 和 variant columns,Iceberg 为 evolving datasets 提供灵活性,同时在结构已知的部分仍然支持 governance 和 optimization。

不过,这种灵活性依赖 ingestion tools 有意识且一致地处理 schema changes。Ingestion jobs 必须检测 incoming schemas,将它们与当前 Iceberg table definition 验证,并根据需要应用安全 mappings 或 transformations。例如,当 source data 中出现新 field 时,pipeline 可能需要扩展 table schema、将该 field 路由到 variant column,或将它 cast 成兼容类型。管理不善的 schema changes 可能导致 rejected records、silent data corruption 或 inconsistent query behavior。

对于 batch 和 micro-batch ingestion,schema alignment 通常发生在每个 job 开始时。Job 会读取当前 Iceberg schema,检查 incoming data,并应用必要 transformations 或 mappings。在 streaming contexts 中,这个过程更复杂。Apache Flink 和 Kafka Connect 等 systems 必须持续调和 schema differences,通常使用 schema registries 或 metadata catalogs 来确保 compatibility。

当 schemas 演进时,可能出现 conflicts,例如 data types 改变,或 field names 被复用但含义不同。如果没有正确验证,这些 changes 可能导致微妙错误或 data loss。幸运的是,Iceberg 通过使用 stable field IDs 而不是依赖 field names 执行 DDL operations,缓解了许多风险。这允许 columns 被安全添加、删除或重排序,而不会破坏 downstream queries。不过,ingestion pipelines 仍然必须通过 validation 执行 schema compatibility,无论是使用 fail-fast checks、controlled casting,还是两者结合,以确保 incoming data 与当前 table definition 对齐。

Ingestion 期间的 Fail-Fast Checks 和 Controlled Casting

可靠 data ingestion 中一个更重要的考虑,是 pipelines 如何处理 unexpected 或 malformed records。在基于 Iceberg 的 systems 中,这通常涉及管理 data type mismatches、missing fields 或 schema inconsistencies。有几种可用策略,每种都在 resilience、data quality 和 operational complexity 上有取舍。

一种严格方法是 fail-fast ingestion,当数据不符合预期 schema 时,pipeline 会拒绝或停止处理。这通过防止 invalid records 进入 Iceberg tables 来执行高 data quality。它也与 Iceberg 的 strong typing 非常契合,并能在 data lifecycle 早期暴露问题。但在 source data quality 波动的 environments 中,这种策略可能导致频繁 failures 和长时间 downtime。因此,fail-fast 在生产中很少是理想策略,除非只选择性地用于 critical fields。

另一种替代方案是 controlled casting,也就是 pipeline 将与 target schema 不完全匹配的 values 强制转换。这可能包括将 strings 转换为 timestamps、截断 decimals,或为 missing values 插入 nulls。有些 tools 只支持有限形式的 promotion,例如 int 到 long,而另一些提供更灵活 casting capabilities。这种方法可以提升对 upstream inconsistencies 的 resilience,但也有引入 silent errors 或 unintended transformations 的风险,从而降低数据可信度。

一种更具韧性且越来越常见的模式,是使用 dead-letter queue(DLQ)。Pipeline 不会失败或转换问题 rows,而是将它们捕获到 side channel 中,供后续检查或修正。这使 ingestion 可以顺畅运行,同时保留 rejected data 的记录,用于 quality control。处理 semistructured 或 externally sourced data 时,DLQs 尤其有用,因为错误是预期会出现的,但不应完全阻塞 ingestion。

实践中,稳健 pipelines 通常会组合这些策略。例如,你可以对 essential fields 应用 fail-fast checks,对 optional 或快速演进的字段使用 controlled casting,并将所有无法解决的 errors 重定向到 DLQ。这种 hybrid approach 在 data quality enforcement 和 operational continuity 之间取得平衡,并提供一个 safety net,用于处理中断之外的 edge cases。

虽然 ingestion systems 必须适应 schema changes,但它们通常不负责跟踪这些 changes 的完整历史。存储和管理这种级别的 metadata 可能增加不必要 overhead。更实用的方法是利用 Iceberg 内置 metadata tables,这些 tables 会自动捕获 schema evolution,并与 table snapshots 一起记录。它们为 debugging、governance 和 impact analysis 提供可靠 audit trail,而不增加 ingestion layer 负担。在 regulated environments 中,这种能力尤其有价值,因为它可以展示 data structures 随时间如何变化。

最终,强 schema management 支持敏捷性。它允许团队根据不断变化的需求调整 data models,而不打断 downstream systems。设计良好的 ingestion layer 会无缝支持这种演进,使 Iceberg 即使在数据形态变化时,也能交付一致、可查询的数据。

6.1.4 Operational Complexity 和 Maintainability

无论 ingestion system 多么高性能或可靠,其长期价值都取决于它是否容易运维、维护和扩展。Operational complexity 往往成为隐藏成本,拖慢创新、消耗工程时间,并增加变更期间的 failure 风险。

几个因素会塑造 ingestion layer 的 operational footprint。其中最重要之一是 pipeline orchestration。Batch jobs 通常依赖 Apache Airflow 等 external schedulers,或 AWS Step Functions 等 managed orchestration services。这些 tools 协调 task execution、retries 和 dependencies。相比之下,streaming jobs 会持续运行,需要 persistent deployment、monitoring 和 tuning。实时管理 stateful、fault-tolerant processing 通常需要更深专业能力和更强 operational discipline。

其次,automation 和 observability 是简化运维的关键。设计良好的 pipelines 会输出 data volume、processing time 和 failure rates 等 metrics。它们会与 logging 和 alerting systems 集成,以支持 proactive monitoring。Automated retries、backoff policies 和 dead-letter queues 有助于防止 transient errors 需要人工介入。

Configuration management 是另一个考虑因素。随着 pipelines 数量和范围增长,管理其 configurations、source connections、schema mappings 和 transformation logic 会变得繁重。支持 declarative pipeline definitions 或 templated deployments 的方案,可以减少这种 overhead 并提升 reproducibility。

此外,所选 ingestion framework 的 learning curve 和 tooling maturity 也会影响 operational efficiency。Apache Spark 或 Flink 等开源工具提供灵活性,但可能需要 custom engineering 才能集成和扩展。AWS Glue、Azure Data Factory 或 Google Dataflow 等 cloud-native tools 提供 managed services,能减少 setup 和 maintenance,但可能对 customization 施加约束。

最终,合适的 ingestion architecture 会在 capability 和 maintainability 之间取得平衡。它应与团队 skill set 对齐,顺畅融入现有 operations stack,并能扩展而不需要持续调优。可管理的 ingestion layer 让团队能专注 value-added work,而不是不断救火处理常规 pipeline problems。

6.2 Ingestion Models 和 Architectures

定义 ingestion requirements 后,下一步是选择与这些需求对齐的 architectural model。Ingestion approaches 在处理 data timing、failure recovery 和与 downstream systems 集成方面有所不同。正确选择取决于 latency、freshness、reliability 和 operational overhead 目标。

大多数 ingestion models 分为三大类:batch、micro-batch 和 streaming。Batch ingestion 常因 operational simplicity 和清晰 execution boundaries 被选择。Jobs 通常在定义好的 input dataset 上运行,并为该次运行产生 deterministic output。虽然 batch pipelines 在实践中经常被视为 idempotent,但这个属性取决于 input state 如何定义和管理。许多 batch jobs 从 mutable sources 中读取,而没有明确 snapshot boundaries,这会使 retries 和 recovery 复杂化。Batch ingestion 仍然非常适合 historical backfills、periodic processing,以及 recovery procedures 可以被仔细控制的 workloads。

Micro-batch ingestion 介于 batch 和 streaming 之间,以短而规律的间隔交付数据,通常是几秒或几分钟。该模型提供更快 data availability,同时保留 batch processing 的大部分结构。在许多现代 systems 中,例如 Spark Structured Streaming,micro-batch execution 使 idempotency 和 fault recovery 相比 ad hoc batch jobs 更容易推理,因为 input offsets、state 和 commit boundaries 被明确跟踪。取舍是相比简单 batch pipelines,它增加了 operational complexity,因为 micro-batch systems 必须持续管理 executions 之间的 state、scheduling 和 coordination。

Streaming ingestion 会在数据到达时持续捕获数据,为将数据送入 lakehouse 提供最低可能 latency。一个常见误解是 streaming ingestion 总是要求 real-time processing。事实上,它只是支持 real-time availability;consumers 仍然可以选择以 batches、micro-batches 或 real time 的方式处理数据。其收益是立即落地数据,让 downstream systems 可以按适合其 use case 的任意 cadence 消费。

本节会审查每种模型,强调它们在 Apache Iceberg lakehouse 中的优势、取舍和典型 use cases。通过理解这些 ingestion patterns,你可以设计满足 requirements、并随数据和业务需求演进的 pipelines。

6.2.1 Batch Ingestion

Batch ingestion 是将数据移动到 analytical platforms 中最成熟、使用最广泛的模型。它会在一个定义好的时间段内收集数据,例如 hourly、daily 或 weekly,然后以离散单元加载到 lakehouse 中,如图 6.4 所示。对于大量历史数据或 slowly changing data,这种方法很高效,因为这类场景 latency 不如 throughput、reliability 和 cost control 关键。

image.png

图 6.4:每天一次,通过 batch job 摄入当天数据。

在 batch workflow 中,数据通常从 operational databases、flat files 或 APIs 等 source systems 中抽取,然后经过 transformation,并以 Parquet files 写入 Iceberg tables。Apache Spark、dbt 或 Airflow 通过 scheduled jobs 或 pipelines 编排这些流程。由于所有 records 都在一次 run 中处理,batch ingestion 简化了协调,并通常允许更全面的 data validation 和 transformation logic。

Apache Iceberg 无缝支持 batch ingestion。Jobs 可以使用 append mode 写入新数据,也可以在需要时执行 overwrites 和 upserts。每次 batch write 都会生成新的 Iceberg snapshot,保留 data version history 并启用 time travel。Iceberg 对 atomic commits 的支持也确保 batch jobs 要么完整成功,要么不留下任何痕迹,从而消除 partial writes 或 data corruption 的风险。

Batch ingestion 的主要优势是它可以让 failure recovery 更容易,但这只有在 input data 被明确限定且定义良好时才成立。Batch jobs 必须有意识地运行在 fixed snapshot 或 clearly scoped chunk of data 之上。如果没有明确的 input state 定义,retries 可能会悄悄重新处理与原始 run 不同的数据,从而导致 unexpected changes,而不是真正的 idempotent behavior。

当 batch pipelines 设计了清晰 boundaries 后,它们可以安全 rerun,以从 errors 中恢复,或重新处理历史数据,而不引入 duplicates 或 inconsistencies。这使 batch ingestion 非常适合 backfills、reconciliations 和 corrective processing。Batch jobs 也通常以固定间隔调度,这增加了 operational predictability,虽然这只是次要收益,而不是主要动机。

主要取舍是 freshness。由于数据按 schedule 处理,用户必须等到下一次 batch run 才能看到更新结果。对于需要 near-real-time visibility 的 use cases,这种延迟会成为限制因素。

Batch pipelines 通常使用固定 batch sizes,这可以简化 tuning 和 resource allocation。但如果 incoming data volume 显著增加,而 batch size 保持不变,就可能形成不断增长的 backlog,延迟 data availability,并给 downstream systems 施加压力。虽然这类 pipelines 较少因 input fluctuations 而失败,但仍可能需要调整 scheduling、parallelism 或 job frequency,以跟上不断演进的 data loads 和 schema complexity。

尽管有这些限制,batch ingestion 仍然是许多 Iceberg lakehouse implementations 的可靠基础。它特别适合 backfills、bulk imports,以及不需要 real-time visibility 的 analytics use cases。结合 Iceberg 的 metadata optimizations 和 snapshot isolation,batch workflows 可以在不增加不必要复杂性的情况下交付 scale 和 consistency。

6.2.2 Micro-Batch 和 Incremental Ingestion

Micro-batch ingestion 通过在 ingestion pipeline 中引入显式 state,弥合传统 batch processing 与 continuous streaming 之间的差距。数据以小而频繁的 intervals 处理,通常是几秒或几分钟。但不同于 ad hoc batch jobs,micro-batch systems 会通过 offsets、checkpoints 或其他形式的 pipeline state 跟踪 progress。这允许每次 execution 只处理自上次成功运行以来的新数据,而不是依赖 time-based 或松散定义的 input boundaries。

由于 micro-batch pipelines 能感知哪些数据已经处理过,它们通常比 stateless batch jobs 更能抵抗 failures,也更容易进行 operational 推理。如果发生 failure,pipeline 可以从已知位置恢复,而不是重新处理一个模糊的数据切片,例如“昨天”。该模型非常适合那些需要 near-real-time updates,但又希望避免完全 continuous streaming systems 复杂性的 use cases,如图 6.5 所示。

image.png

图 6.5:Micro-batching data,ingest job 会摄入过去 5 分钟内的所有新数据。

在 micro-batch workflow 中,incoming data 会在短时间窗口内收集,并作为离散 chunks 摄入。Apache Spark Structured Streaming 等工具会将每个 interval 视作一个 mini-batch,以周期性 schedule 触发新的 execution cycle。这些小 jobs 可以向 Iceberg tables append data,每次 commit 都触发新的 snapshots。Iceberg 的 metadata layer 会高效处理 incremental updates,其 snapshot isolation model 确保 readers 只看到完整、已提交的 states。

Micro-batching 非常适合从 SaaS platforms、APIs 和 periodic file uploads 等 sources 摄入数据——这些 sources 不会产生 continuous stream of records,但可以被定期 polling 或 triggered。它在 high-latency batch jobs 与 continuous streaming 的复杂性之间提供中间路线,能在不要求 fully stateful、long-running applications 的情况下交付更新鲜的数据。通过将小量数据累积成 timed batches,micro-batching 提供可预测 processing intervals,并简化来自 semistructured 或 event-driven external systems 的 ingestion。

该模型也能很好地配合 Iceberg 的 maintenance features,我们会在第 10 章 lakehouse maintenance 中进一步讨论。频繁 small writes 可能导致 metadata growth 和 file fragmentation,并随时间降低 query performance。Iceberg 支持 background compaction processes,将 small files 合并成优化后的 columnar blocks,确保 ingestion speed 不以 read efficiency 为代价。

Micro-batching 的一个挑战是调优 batch interval。Intervals 太短可能因频繁 job launches 和 metadata commits 增加 overhead;intervals 太长则可能延迟 data availability。正确配置取决于系统能力和用户对 fresh data 的预期。

Micro-batch ingestion 在 throughput、latency 和 maintainability 之间提供强平衡。它适合 lakehouse environments,在这些环境中数据需要持续到达,但也有足够容忍度来简化 orchestration 和 resource allocation。结合 Iceberg 的 transactional model 和 file-level optimizations,它为广泛 real-time analytics needs 提供高效且灵活的 ingestion approach。

6.2.3 Streaming Ingestion

Streaming ingestion 被设计为在数据产生时持续处理数据,这不同于 batch 和 micro-batch models,后两者基于明确定义的 input ranges 运行。Streaming pipelines 在概念上会把 records 作为 unbounded streams 处理,并维护 internal state 来跟踪 progress、offsets 和 recovery。

在基于 Iceberg 的 lakehouses 中,streaming ingestion 并不意味着 per-record writes 或 immediate visibility。所有已知 frameworks 仍然会以 bounded units 向 Iceberg commit data,导致 streaming ingestion 在 table level 表现为受控 micro-batches。这意味着数据以低但非零的 latency 交付,由 commit intervals 而不是 record arrival time 决定。

尽管有这一约束,streaming ingestion 对 low-latency analytical use cases 仍然至关重要,例如 fraud detection、monitoring、personalization 和 near-real-time dashboards。在这些场景中,以秒为单位衡量的 freshness 已经足够,而 transactional commits 带来的 reliability benefits 超过了 per-event visibility 的需求。

image.png

图 6.6:Streaming data 会在到达 destination 时被持续摄入。

在 streaming workflow 中,数据会逐条 record 或以小型 micro-batches 摄入,intervals 通常为个位数秒,如图 6.6 所示。Apache Flink、Kafka Streams 和 Spark Structured Streaming 等 systems 支持复杂 stream processing,具备 event-time handling、watermarking 和 stateful transformations 等功能。这些工具可以使用 connectors 直接写入 Apache Iceberg tables,connectors 会 buffer records、以安全 intervals commit changes,并与 Iceberg 的 snapshot-based architecture 协调。

Apache Iceberg 与 streaming paradigms 集成良好,尤其是它支持 incremental writes,并且在搭配 compatible engines 时支持 exactly-once semantics。Streaming ingestion 通常会向 table append 新数据,每次 commit 生成一个新 snapshot。Streaming writers 经常会把 records 分组成 small files,以降低 overhead,并以 batches 方式 commit,从而在 freshness 和 performance 之间取得平衡。

Streaming ingestion 引入了几个独特挑战。一个是 commit frequency:commit 太频繁会产生过多 metadata 并降低 query performance,而 commit 太不频繁又会延迟 data availability。找到合适平衡,对同时维护 freshness 和长期 table health 至关重要。

另一个挑战是 state management 和 fault recovery。由于 streaming jobs 是 long-running,它们必须持久化 processing state,并在 failures 后可靠恢复。Apache Flink 等 frameworks 会独立于 storage layer 维护 state,并主要使用 checkpointing 作为 recovery mechanism。当与 Iceberg transactional commit model 集成时,这使 streaming pipelines 可以从 known state 恢复,同时确保只有 fully completed batches 被提交到 tables。

Streaming pipelines 还必须处理 out-of-order 或 late-arriving events,如果处理不当,这些会影响 analytical accuracy。最后,streaming systems 中的 error handling 需要仔细设计,但它与 batch processing 并没有本质区别。Invalid 或 malformed records 可以被过滤、重定向到 dead-letter queue,或记录下来供以后检查,而不会停止整个 pipeline,使 continuous ingestion 可以继续进行,同时保持 operational stability。

Scalability 也是关键关注点。Streaming systems 必须处理波动 data rates,通常还会出现高峰负载。它们需要 elastic resource allocation 和强 backpressure handling,以防止 data loss 或 lag。

Streaming ingestion 的一个关键优势是支持 stateful transformations,也就是 pipeline 能跨多个 events 维护上下文。常见例子包括 deduplication、sessionization 和 change data capture(CDC)logic。这些 patterns 通常很难或低效地在传统 batch pipelines 中实现,因为 batch pipelines 缺少 continuous state,并且必须反复重新处理重叠数据范围。

除了改善 freshness,streaming ingestion 还可以降低成本。通过只 incrementally 处理新数据,并避免反复 full-table scans,组织可以相比大型周期性 batch jobs 降低 compute usage。例如,Uber 曾记录,将部分 data lake ingestion 从 batch 迁移到使用 Apache Flink 的 streaming 后,processing costs 约降低 25%,同时 data latency 从小时级改善到分钟级。这种效率来自减少 redundant work,并让 processing 随时间更均匀分布。

需要注意的是,在基于 Iceberg 的 lakehouses 中,Spark micro-batch pipelines 和 Flink streaming pipelines 最终都会以 bounded units commit data。两者都不会对 Iceberg tables 执行 per-record writes。它们的主要差异在 execution models、state management 和 operational characteristics,而不是 table level 的 commit 方式。

尽管有这些好处,将 streaming ingestion 写入 Iceberg 也带来额外 operational considerations。频繁 commits 会增加对 compaction 的需求,以管理 small files 和 metadata growth。今天,这仍然是团队必须仔细规划的领域。未来 Iceberg versions 的改进预计会加强 ingestion 和 maintenance workflows 之间的集成,但目前,streaming pipelines 应该带着明确 compaction strategies 来设计。

配置正确时,streaming ingestion 为 near-real-time analytics 和 operational intelligence 提供 resilient、low-latency foundation。它非常适合 event-driven architectures,在这些场景中,几分钟延迟就可能降低业务价值,但团队必须考虑当前围绕 commit frequency、table maintenance 和 operational complexity 的取舍。

6.3 Iceberg 如何管理 Writes

选择正确 ingestion model 只是整体图景的一部分。无论数据通过 batch jobs、micro-batches 还是 streaming pipelines 交付,最终都必须写入 Iceberg tables。理解 Iceberg 如何管理这些 writes,对构建既高性能又可靠的 ingestion workflows 至关重要。

Iceberg 不只是 file format。它是一种 transactional table format,旨在把类似数据库的 guarantees 带入数据湖。Iceberg 中的每个 write operation 都会创建新的 table snapshot,更新 metadata 以反映 changes,而不修改已有 data files。这种方法支持 atomic commits、time travel 和 concurrent write isolation,而这些都是可靠 data ingestion 的关键。

本节会考察 Iceberg 如何处理不同 write operations,包括 appends、overwrites、upserts 和 deletes。我们还会探索 Iceberg commit protocol 在确保 distributed systems 中 consistency 方面的作用,以及它如何与标准 ingestion engines 集成,以管理 conflicts、retries 和 incremental updates。这些机制构成了现代 lakehouse 中可靠、multiwriter data pipelines 的基础。

6.3.1 Iceberg 中的 Write Semantics

Apache Iceberg 支持一系列 write operations,使 data engineers 能实现多样 ingestion patterns,同时维持 consistency、scalability 和 query performance。每次 write 都会创建一个新 snapshot,表示 table 在特定时间点的一致视图。这些 snapshots 是 Iceberg 设计的核心,支持 atomicity、isolation 和 time travel。

最常见的 write operation 是 append,也就是添加新数据而不修改或删除已有 files,如图 6.7 所示。这非常适合 streaming 或 micro-batch ingestion,其中新 records 持续写入 table。由于 append operations 不改变历史数据,它们效率很高,并且可以由多个 writers 并发执行,前提是每个 batch 落在不同 files 中。

image.png

图 6.7:Append 之后,新 snapshot 包含所有之前 data files 和新的 data files。

Iceberg 支持 overwrite operations,用于 data correction 或 periodic rebuilds 等 use cases,如图 6.8 所示。Overwrite 会基于 filter 或 partition specification 替换 table 中的一部分数据。这适合按 partition refresh 数据的 pipelines,例如 daily snapshots,或需要 deterministic reprocessing 的场景。在 multiwriter environments 中必须谨慎使用 overwrites,以避免 conflicts,因为它们可能使 targeted scope 内的已有 files 失效。

image.png

图 6.8:Overwrite 中,包含 deleted 或 updated records 的 files 会被新 data files 替换。

Iceberg 支持两种互补方式处理 row-level updates 和 deletes:copy-on-write 和 merge-on-read,如图 6.9 所示。这些机制将 data lake workflows 扩展到 append-only patterns 之外,并支持 fine-grained data corrections,而无需重写整张 tables。

在 merge-on-read model 中,changes 被记录为 delete files,并在 query time 应用。Iceberg 支持两种 deletes:position deletes,通过 file 和 row position 标识要删除的 rows;以及 equality deletes,通过 logical predicates 匹配跨 files 的 rows,如图 6.9 所示。Position deletes 通常在 read time 更快解析,也更容易 compact,但 writer 必须精确知道要删除哪些 rows。Equality deletes 对 streaming 和 CDC-style ingestion 更灵活,但在 reads 期间评估成本更高,并且显著更难高效 compact。

相比之下,copy-on-write 会在 commit time 通过重写受影响 data files 来应用 updates,生成已经反映 change 的新 Parquet files。这种方法完全避免 delete files,通常提供更好 read performance,代价是 updates 的 write amplification 和 latency 更高。

Engine support 会影响哪种 delete strategy 实际可行。Apache Spark 当前支持 position deletes,而 Apache Flink 支持 equality deletes。一些 managed ingestion tools 和 connectors 在支持内容上也不同,这会影响 operational complexity 和长期 table maintenance。

Iceberg 也通过暴露 snapshots 之间的 row-level changes 来支持 CDC use cases。这使其适用于 slowly changing dimensions、regulatory corrections、data subject erasure 和 downstream synchronization 等场景,而不需要 full-table rewrites。在 copy-on-write 和 merge-on-read 之间选择时,团队应仔细考虑 delete type、compaction strategy、engine support 和 query performance tradeoffs。关于详细 semantics 和 implementation guidance,请参考附录 C 中的 Iceberg specification。

image.png

图 6.9:使用 delete files 时,existing data files 中 updated 和 deleted records 会被忽略,同时写入只包含 updated records 的新 data files。

另一种 operation 是 merge,它允许基于 user-defined logic 执行 conditional upserts 和 deletes,如图 6.10 所示。Merge statements 通常用于 transactional ingestion patterns,其中新数据可能插入 fresh records,也可能更新 existing records。Apache Flink 和 Spark 等 engines 通过其 Iceberg connectors 支持 merge operations,允许复杂 data transformation pipelines 直接针对 Iceberg tables 运行。

image.png

图 6.10:Merge transactions 允许你将 records 与 staging dataset 比较,并有条件地 insert、update 和 delete records。

这些 write semantics 赋予 Iceberg 灵活性,使它可以支持从 immutable append-only data 到 fully mutable、transactional-style updates 的广泛 ingestion patterns,同时保留 consistency 并支持 efficient reads。不过,必须注意,这些行为是由与 Iceberg 交互的 compute engines 实现的,并不是 Iceberg specification 本身直接定义的。MERGEUPDATEDELETE 等 operations 由 Spark 或 Flink 等 engines 表达和执行,然后由这些 engines 将其转换为 Iceberg-compatible commits。

因此,选择合适 write strategy 不只是 table design decision,也是 engine-level decision。Engine capabilities、delete type support 和 compaction strategy 的组合,最终决定 lakehouse architecture 中 performance、cost 和 correctness 的平衡。

6.3.2 Commit Protocols 和 Conflict Handling

Apache Iceberg 的 commit protocol 是它在 distributed environments 中保持 consistency 和 isolation 的核心。无论数据通过 batch jobs、streaming pipelines 还是 interactive tools 写入,每个 write operation 都以一次 atomic commit 结束,并发布新的 table snapshot。该机制确保 readers 始终看到 table 的一致视图,即使多个 writers 并行操作也是如此。

Commit process 会生成新的 snapshot metadata file,该文件引用新写入的 data files 和所有相关 deleted files。为了发布该 snapshot,Iceberg 会对 table metadata pointer 执行 atomic compare-and-swap operation,更多内容见第 8 章。如果期间没有其他 writer 修改 table,新 snapshot 就成为最新状态。如果已有另一个 commit 发生,该 operation 会失败,writer 必须 retry。

这种 optimistic concurrency control model 允许在不需要 distributed locks 的情况下实现 high throughput 和 scalability。它也确保 concurrent writes 不会彼此干扰,前提是它们操作的是不相交 datasets。例如,两个写入不同 partitions 的 append operations 可以各自成功,而两个重叠的 overwrites 可能触发 conflict。

Commit conflicts 在 ingestion workflows 中很常见,尤其是 streaming 或 concurrent micro-batch jobs。处理它们涉及 retries、backoff strategies,以及在某些情况下重新评估当前 table state,以判断 retry 是否合适。大多数支持 Iceberg 的 ingestion frameworks,例如 Apache Flink 和 Spark,都内置 commit retry logic,以简化这一过程。

Commit behavior 也直接影响 performance 和 scalability。主要关注点不是 commit frequency 本身,而是随时间累积的 metadata 量。每次 commit 都会添加 snapshots、manifests 和相关 metadata,这些在 planning 期间必须处理。理论上,只要 historical metadata 被定期 prune 和 compact,Iceberg table 可以非常频繁地写入,而不会降低性能。

实践中,在 commit 前 batching writes 仍然是一种常见策略,因为它可以限制 metadata growth,并降低 catalogs 和 storage systems 的压力。不过,更长 commit intervals 会增加 data freshness lag,因此 ingestion pipelines 必须在 metadata volume、query-planning efficiency,以及新数据多快需要变为可见之间取得平衡。

最终,Iceberg 的 commit protocol 使各种 deployment patterns 中的可靠 ingestion 成为可能。它抽象了 concurrency、conflict resolution 和 transactional isolation 的复杂性,让团队可以专注构建 resilient pipelines,而不牺牲 consistency 或 performance。

6.4 Ingestion Tools 和 Frameworks

定义 ingestion requirements 并选择合适 architectural model 后,下一步是选择实现它的工具。现代数据生态提供多种 ingestion frameworks,每种都有不同优势、operational models,以及与 Apache Iceberg 的集成程度。正确工具取决于 latency needs、source systems、team expertise,以及 data flows 的规模和频率。

本节会探索开源和商业生态中最常用的 ingestion tools。我们会从 Apache Spark 和 Apache Flink 开始,它们是 batch 和 streaming workloads 中最广泛采用的两个 engines,并且都与 Iceberg 有深度原生集成。接着,我们会看 Apache NiFi,这是一个灵活、low-code 的工具,可以用最少 custom code 构建 data flows。

我们还会考察流行的 commercial 和 open source connectors 与 ELT platforms,例如 Fivetran、Airbyte 和 Qlik,后者收购了 Upsolver,它们简化从 SaaS applications 和 databases 的 ingestion。对于 event-driven architectures,我们会考虑 Confluent 和 Redpanda 等 stream-processing platforms,它们提供 Kafka-compatible capabilities,并通过 connectors 或 sinks 提供通向 Iceberg 的 integration paths。

最后,我们会涉及 AWS Glue、Azure Data Factory 和 Google Dataflow 等 cloud-native alternatives,它们提供与各自 cloud ecosystem 紧密耦合的 managed ingestion services。虽然没有任何单一工具能完美覆盖所有 use cases,但本节旨在清楚展示每个选项的优势,以及它在 Apache Iceberg lakehouse architecture 中的位置。

6.4.1 Apache Spark

Apache Spark 是一个强大的 distributed processing engine,广泛用于 batch 和 micro-batch data pipelines。它与 Apache Iceberg 的集成,使其成为许多 lakehouse ingestion workflows 的基础工具,尤其适合涉及大规模 transformations、scheduled ETL jobs 或 near-real-time streaming 的场景。

Iceberg 通过 Iceberg Spark runtime module 为 Spark 提供原生支持,使 Spark SQL 和 DataFrame APIs 可以执行 read 和 write operations。Spark 对写入 partitioned data、执行 compactions,以及管理 upserts 或 overwrite workflows 尤其实用。下面是 Apache Spark 中向 Apache Iceberg table append data 的示例。

这是一个 Spark 基础 append operation:

import org.apache.spark.sql.SparkSession  #1
val spark = SparkSession.builder()
    ➥.appName("IcebergAppendExample")
    ➥.config("spark.sql.catalog.my_catalog",
    ➥"org.apache.iceberg.spark.SparkCatalog")
    ➥.config("spark.sql.catalog.my_catalog.type ", "hadoop")
    ➥.config("spark.sql.catalog.my_catalog.warehouse",
    ➥"s3a://my-bucket/warehouse")
    .getOrCreate()  #2
val df = spark.read.json(
    ➥"s3a://input-bucket/new-data.json")  #3
df.writeTo("my_catalog.db.my_table")
    ➥.append() #4
#1 导入 Spark session
#2 使用 Iceberg catalog configs 构建 Spark session
#3 将 JSON 文件中的数据读取到 dataframe
#4 将 dataframe 中的数据写入新的 append snapshot

这是 partitioned overwrite operation:

df.writeTo("my_catalog.db.my_table")
    .overwritePartitions()

该操作只替换受影响的 partitions,保留 table 其余部分,并最小化 write amplification。

这是 Spark 3.3+ 中使用 Iceberg 的 merge,也就是 upsert:

MERGE INTO my_catalog.db.my_table t
USING my_catalog.db.staging_table s  #1
ON t.id = s.id #2
WHEN MATCHED THEN UPDATE SET * #3
WHEN NOT MATCHED THEN INSERT * #4
#1 将 staging table,也就是 s 中的 records,与目标 table,也就是 t 进行 reconciliate
#2 首先检查 records 的 ID 是否匹配
#3 如果匹配,则更新 record,使其与 staging 一致
#4 如果不匹配,则将 record 插入 table

Spark 的 merge support 允许用户实现 slowly changing dimensions、处理 late-arriving data,并简化 data reconciliation workflows。

Spark 也使用 Structured Streaming 支持 streaming ingestion。在这个模型中,micro-batches 会写入 Iceberg,以支持 checkpointing 和 exactly-once semantics,前提是 streaming source 和 processing logic 得到适当配置。示例如下:

val inputStream = spark.readStream
  .format("kafka")
  .option("kafka.bootstrap.servers", "broker:9092")
  .option("subscribe", "input-topic")
  .load() #1
val parsed = inputStream.selectExpr("CAST(value AS STRING) as json")
  .select(from_json($"json", schema).as("data"))
  .select("data.*") #2
parsed.writeStream
  .format("iceberg")
  .outputMode("append")
  .option("checkpointLocation", "s3a://checkpoints/my-table/")
  .start("my_catalog.db.my_table") #3
#1 连接 Kafka 并从指定 topic 读取数据
#2 将 topics 转成 JSON,并强制转换为正确 schema,再转成 dataframe
#3 将该 dataframe 写入 table,并更新 checkpoint,以支持 exactly-once semantics

Spark 的灵活性、广泛生态支持和规模化性能,使它成为各种 ingestion use cases 的自然选择。结合 Iceberg 的 transactional model,Spark 可以在 lakehouse environment 中支持稳健 batch pipelines 和灵活 near-real-time data flows。

6.4.2 Apache Flink

Apache Flink 是一个高性能、stateful stream-processing engine,适用于 low-latency、event-driven applications。它对 Iceberg 的原生支持,加上 exactly-once semantics 和 event-time processing 等强大能力,使其成为向 Iceberg lakehouse 进行 real-time ingestion 的强选择。

Flink 通过 Iceberg Flink sink 与 Iceberg 集成,支持 streaming 和 batch writes。当数据持续到达,并且需要以强 consistency guarantees 逐步 commit 时,它尤其有效。

这是一个将 streaming 写入 Iceberg 的 Flink SQL 示例:

CREATE TABLE source_kafka (
  id STRING,
  event_time TIMESTAMP(3),
  data STRING,
  WATERMARK FOR event_time AS event_time - INTERVAL '5' SECOND
) WITH (
  'connector' = 'kafka',
  'topic' = 'events',
  'properties.bootstrap.servers' = 'broker:9092',
  'format' = 'json'
); #1
CREATE TABLE sink_iceberg (
  id STRING,
  event_time TIMESTAMP(3),
  data STRING
) WITH (
  'connector' = 'iceberg',
  'catalog-name' = 'my_catalog',
  'catalog-type' = 'hadoop',
  'warehouse' = 's3a://my-bucket/warehouse',
  'format-version' = '2'
); #2
INSERT INTO sink_iceberg
SELECT * FROM source_kafka; #3
#1 从 Kafka topic 创建 sources
#2 在 Iceberg catalog 中创建目标 table
#3 将 source 中的数据插入 destination

Flink 也支持在 ingestion 前执行复杂处理,例如 filtering、enrichment、joins 和 aggregations。这些 transformations 可以使用 DataStream API 或 SQL 编写,并以 streaming 方式 commit 到 Iceberg。下面是一个使用 Iceberg 的 DataStream API 示例:

DataStream<Row> inputStream = env.addSource(new FlinkKafkaConsumer<>("events",
    ➥new SimpleStringSchema(), props))
    ➥.map(json -> parseJsonToRow(json)); #1Table inputTable = tableEnv.fromDataStream(inputStream);  #2
tableEnv.executeSql(
  "CREATE TABLE iceberg_sink (id STRING, data STRING) WITH (...)"
➥ );  #3inputTable.executeInsert("iceberg_sink");  #4
#1 创建 datastream object,从 Kafka stream 拉取数据
#2datastream object 创建 table
#3 定义接收数据的 Iceberg table
#4 开始将 stream 中的数据插入 Iceberg table

Flink 的 checkpointing 与 Iceberg 的 atomic snapshot system 集成,在正确配置时支持 exactly-once delivery。这对 mission-critical data flows 至关重要,因为这类场景无法容忍 duplicates 或 data loss。

由于 Flink 对 event-time semantics 有丰富支持,它在 out-of-order 或 late-arriving data 场景中尤其有效。它还支持 deduplication、windowed aggregations 和 CDC processing,这些都可以直接输入 Iceberg tables,用于 incremental modeling。

总之,Flink 擅长构建 real-time ingestion pipelines,这类 pipelines 需要 fine-grained control、strong consistency 和 low-latency delivery。搭配 Iceberg 时,它可以支持 durable、versioned ingestion workflows,并跨 streaming 和 batch use cases 扩展。

6.4.3 Apache NiFi

Apache NiFi 是一种 visual data flow tool,旨在简化跨不同系统的数据移动、转换和路由。不同于 Spark 或 Flink 这类聚焦 high-throughput processing 的 engines,NiFi 擅长通过 user-friendly、drag-and-drop interface 管理 data ingestion pipelines,提供 fine-grained flow control、backpressure handling 和 lineage tracking。

NiFi 的核心概念是 processors,也就是执行离散任务的模块化单元,例如 fetching files、transforming formats、routing content 或 invoking APIs。用户可以可视化地将这些 processors 连接成复杂 pipelines,以构建符合自身需求的 ingestion flows,并且通常不需要编写 custom code。

在 Apache Iceberg context 中,NiFi 作为灵活的 pre-ingestion 和 delivery layer。虽然 NiFi 2.0.0 移除了直接 Iceberg support,但 NiFi 1.19.0 引入并维护到 1.23.1 的 PutIceberg processor,可以写入 existing Iceberg tables。不过,NiFi 不支持 table creation 或 compaction;这些 tasks 必须由 Spark 或 Trino 等 external engines 处理。

一个标准 NiFi-to-Iceberg flow 可能如下:

  1. 使用 GetFile 监控 local directory。
  2. 使用 ConvertRecord 标准化并转换 data formats,例如 CSV 到 Parquet。
  3. 使用 RouteOnAttribute 基于 metadata logic 路由 records。
  4. 使用 PutS3Object 将 files 写入 S3 bucket。
  5. 下游由 Iceberg-compatible engine,例如 Spark 或 Flink,将这些数据摄入 Iceberg table。

使用 Apache NiFi,可以通过以下步骤使用 PutIceberg processor 直接写入 Iceberg tables:

  1. 使用通过 HiveCatalogService 配置的 Iceberg-compatible Hive Metastore。
  2. 为 object storage 设置 credentials 和 Hadoop configuration,例如 core-site.xml
  3. 定义 schema、table name 和 file format,最好是 Parquet 或 ORC。
  4. 确保 target table 已存在,并且已由 Spark 或其他 engine 创建。

NiFi 的 operational features,例如 backpressure、retries 和 provenance tracking,使它适合 edge ingestion 和高度可观测 dataflows。虽然它把 heavy processing 和 table management 留给其他工具,但它仍然是 Apache Iceberg lakehouse architecture 中的关键 orchestration component。

6.4.4 Fivetran

Fivetran 是一个 fully managed ELT platform,旨在简化从 source systems 到 cloud data warehouses 和 data lakes 的数据移动,这些 source systems 包括 SaaS applications、operational databases 和 event platforms。它的 Managed Data Lake Service 提供对 Apache Iceberg 的原生支持,允许用户将 structured data 直接摄入主要 cloud providers 上的 Iceberg tables。

根据配置不同,Fivetran 会将 source data 转换为 Parquet files,并写入 Iceberg 或 Delta Lake tables。它支持 Amazon S3、Azure Data Lake Storage(ADLS)和 Google Cloud Storage(GCS,beta),支持 multicloud flexibility。该服务的一个关键特性是,它使用 Fivetran Iceberg REST Catalog 维护 Iceberg tables 的 metadata,该 catalog 与任何支持 Iceberg REST interface 的 engine 兼容。

以下是 Fivetran Iceberg integration 的一些关键特性:

  • Automated table maintenance,包括 compaction、cleanup of old snapshots、orphan files 和 stale metadata。
  • 生成 column-level statistics,例如 minimum 和 maximum values,以提升 query performance。
  • 内置支持多个 query engines,包括 Spark、Dremio、Athena 和 Snowflake。
  • 通过 automatic column renaming 支持 reserved Iceberg field names。

下面是一个 Fivetran architecture 示例:

  1. Fivetran 从 Salesforce、PostgreSQL 或 Fivetran 支持的许多其他服务中拉取数据。
  2. 它使用 Fivetran Iceberg REST Catalog,以 Iceberg format 将 Parquet files 写入 S3。
  3. Snowflake 或 Dremio 等 query engines 连接到 catalog 并读取 Iceberg tables。

Fivetran 对于希望将 Iceberg 集成到数据平台中,但不想手工构建和维护 ingestion pipelines 的组织尤其有用。它抽象了 schema mapping、transformation、metadata coordination 和 table lifecycle management 的运维负担,使其成为在生产中采用 Iceberg 的低摩擦入口。

对于聚焦于从 business systems、SaaS platforms 和 transactional databases 进行 near-real-time syncs 的 use cases,Fivetran 提供了 automation、governance integration 和跨 cloud environments 的 Iceberg compatibility 的强组合。

6.4.5 Qlik

收购 Upsolver 后,Qlik 现在提供 ingestion 和 optimization capabilities,旨在支持 real-time data delivery into Apache Iceberg lakehouses。Qlik 可以规模化管理 streaming 和 semistructured data,重点是使用 declarative data flows 将 streaming pipelines 集成到 Iceberg table formats 中。

整合后的平台提供 ingestion pipelines,可以从 Kafka、cloud object storage 和 enterprise systems 等 high-throughput sources 捕获数据,并将这些数据直接写入 Iceberg tables。这包括对 schema evolution、partitioning strategies 和 background optimization routines 的支持,以改善 query performance 和 storage efficiency。

Qlik 方法的一些差异化特性包括:自动处理 compaction、small file management 和 partition optimization。这些能力帮助最小化在 continuous ingestion workloads 下管理 Iceberg tables 通常伴随的 operational overhead。该系统支持每秒数百万 events 的 ingestion rates,同时管理数百个 Iceberg tables。

Qlik 平台将该 ingestion layer 与更广泛 data tools 生态集成,包括多样 data sources 的 connectors,并兼容多个 query engines。该架构被设计为支持 multicloud 和 hybrid deployments,同时通过 Iceberg 等 open table formats 保持 openness。

最适合该平台的 use cases 包括大规模 behavioral event pipelines、real-time analytics 和 streaming AI/ML model inputs,尤其是在 automation 和 reduced operational complexity 是优先事项的场景中。虽然该集成在 Qlik 品牌下仍在演进,但其技术模型仍聚焦于高效摄入 open table formats,并强调 automation、scale 和 integration flexibility。

6.4.6 Airbyte

Airbyte 是一个 open source data integration platform,通过 configurable connectors 简化 ELT workflows。它支持的 destinations 之一是 S3 Data Lake connector,该 connector 允许以 Apache Iceberg format 将数据写入 S3-compatible storage systems。

该 connector 允许用户将 supported Airbyte sources 直接摄入 Iceberg tables,使用 Amazon S3 或 self-hosted S3-compatible systems 上的 storage,并与 REST、AWS Glue 或 Nessie 等 supported Iceberg catalog 集成。根据 sync mode 和 schema configuration,connector 支持 append、overwrite 或 merge-on-read write strategies。

数据以 Parquet files 摄入,metadata updates 通过所选 Iceberg catalog 协调。使用 merge-on-read mode 时,Airbyte 通过 equality deletes 和 inserts 支持 deduplication,这依赖 source system 中的 primary keys 和 cursor ordering。该策略假设 source 能一致且有序地发出 changes,而这并不适用于所有 APIs。

Airbyte 在特定条件下支持 schema evolution,例如添加或删除 columns,以及 widening types。更破坏性的 schema changes 需要 complete refresh 或 manual intervention,以调整 table definitions。Nested 或 complex fields,例如 arrays 或 objects,会作为 serialized JSON strings 存入 Iceberg tables。

Airbyte 中每次 sync 都会在 Iceberg table 中创建一个新 snapshot。在 truncate operations 期间,数据会先 staged 到临时 Iceberg branch,然后被 atomically promoted 到 main branch。这让 readers 可以在 ingestion 期间继续访问 stable data,这在处理大型 updates 或不稳定 source systems 时很有价值。

Airbyte 的 S3 Data Lake destination 为将 structured data pipelines 集成到 Iceberg lakehouses 提供了一条直接路径,尤其适合那些想要 declarative、connector-based ingestion workflows,而不想管理 stream-processing infrastructure 的团队。它最适合定期 syncs 和 batch-style ingestion into Iceberg tables,且这些 tables 托管在 cloud object storage 上。

6.4.7 Confluent

Confluent 是 Apache Kafka 背后的公司,它在 Confluent Cloud 平台中提供 Tableflow,用于简化 Kafka topics 与 Iceberg tables 的集成。Tableflow 允许组织将 Kafka 中的 streaming data 直接 materialize 成 Apache Iceberg 或 Delta Lake table formats,而无需构建 custom ingestion pipelines。

Tableflow 自动化了连接 operational,也就是 streaming,和 analytical,也就是 lakehouse,环境时常见的关键 tasks。这些包括 type conversions、使用 Confluent Schema Registry 的 schema evolution、CDC stream materialization,以及 file compaction 等 background table maintenance。Tableflow 可以使用 Confluent Managed Storage 或 Bring Your Storage,例如 Amazon S3,写入 Iceberg tables。

Materialized tables 以 Iceberg format 暴露,并可以注册到 AWS Glue、Iceberg REST Catalog 和 Snowflake Open Catalog 等 catalog services。这允许 Athena、Snowflake 或 Trino 等 query engines 访问数据。从 external compute engines 视角看,这些 Iceberg tables 是 read-only 的,这简化了 streaming data 流入 analytics systems 的过程,并避免 duplication。

Tableflow 与 Confluent Cloud for Apache Flink 集成,可以在 ingestion 前进行 data processing,支持 filtering、joins 或 PII-scrubbing 等 real-time transformations,然后再 materialization。该设计支持 shift-left processing model,也就是将 stream-processing logic 更早应用在 pipeline 中,从而减少 post-ingestion cleanup 的需要。

Tableflow 支持 Avro、Protobuf 或 JSON Schema formats 的数据,并基于 Schema Registry 中定义的 compatibility rules 管理 schema evolution。它自动发布 Iceberg table metadata,并维护多个 table snapshots,以支持 versioning 和 rollback。

以下是使用 Tableflow 的一些考虑和限制:

  • Tableflow 仅在 Bring Your Own Storage 下支持 external catalog integration。
  • Materialized tables 是 append-only;不支持 upserts 和 retract changelog modes。
  • 每个 Kafka cluster 同一时间只能与一个 catalog 集成。
  • Tableflow 当前仅限于 AWS 上的 Confluent Cloud。
  • 一些 compute engines,例如 Confluent Cloud for Flink,无法直接查询 Iceberg tables。

Confluent Tableflow 最适合那些已经运行在 Confluent Cloud 生态中,并希望以最少 custom infrastructure 将 Kafka streams 摄入 Iceberg tables 的团队。它的 catalog integration 和 automation features 降低了将 real-time operational data 移动到 analytical systems 的复杂性。

6.4.8 Redpanda

Redpanda 是一个 Kafka-compatible streaming platform,支持与 Apache Iceberg 直接集成。该集成允许 Redpanda topics 被 materialized 为存储在 cloud object storage 中的 Iceberg tables,从而简化 analytical tools 对 streaming data 的访问,而无需 intermediate ETL pipelines。

启用后,Redpanda 会将 topic data 写入 Iceberg-compatible Parquet files,并管理相关 metadata,使 Spark、Flink、Snowflake 和 ClickHouse 等 downstream systems 可以将 streaming data 当作可查询 tables 来处理。Redpanda 支持 Iceberg table format version 2,并通过 REST endpoints 或 filesystem-based catalogs 提供 catalog integration 选项。

要启用 Iceberg support,Redpanda 用户必须配置 iceberg_enabled cluster setting,并定义 redpanda.iceberg.mode topic property。可用三种 ingestion modes:

key_value——将 records 作为 binary payloads 与 metadata 一起存储。

value_schema_id_prefix——使用 Schema Registry 中注册的 schemas 写入 structured data,要求 wire format。

value_schema_latest——使用给定 subject 的最新 schema 写入,而不要求 wire format。

Avro 和 Protobuf 支持 schema evolution,允许添加 fields 或重排序 columns 等 changes。如果 schema conversion 失败,例如由于 invalid wire format,失败 records 会被路由到 dead-letter queue table,供检查和可选 reprocessing。

Redpanda 支持使用 topic-level settings 对 Iceberg tables 进行 partitioning,使你可以根据频繁查询字段优化 table layout。这可以通过减少 reads 期间扫描的 files 数量来提升 query performance。

Redpanda 还允许用户在两类 Iceberg catalogs 之间选择:

REST catalog——适合 production environments,允许 metadata 在 tools 之间共享。

Filesystem-based catalog——将 metadata 与 data 一起存储在 object storage 中,需要 clients 手动刷新 table。

虽然不原生支持 JSON schemas,但仍可以使用 key_value mode 摄入 JSON data。Performance considerations 包括 Iceberg translation tasks 增加 CPU usage,以及在 cluster resources 不足时可能对 producers 产生 backpressure。

该集成最适合希望简化 Iceberg-based architectures 中 real-time data access,同时保持与 Kafka tooling 兼容的用户。Redpanda 可以从同一 source 同时服务 operational 和 analytical workloads,而不复制数据。

6.4.9 Cloud-Native Ingestion Services

主要云厂商提供 managed ingestion services,通过其更广泛的 data lake 和 analytics ecosystems 与 Apache Iceberg 集成。这些 services 通常优先考虑 ease of use、scalability,以及与 provider 的 storage 和 compute platforms 的紧密集成。虽然它们在实现上可能不同,但通常支持 batch 和 streaming ingestion patterns,并可作为 Iceberg-based lakehouses 的 sources 或 transformation layers。

AWS Glue 通过其 Spark-based ETL engine 支持写入 Iceberg tables。Glue jobs 可以配置为使用 Iceberg 作为 table format,并注册到 AWS Glue Data Catalog 以便 discoverability。这适合构建 scheduled 或 event-driven pipelines,将 curated data 落入 Amazon S3 上的 Iceberg tables。

Azure Data Factory(ADF)现在支持在写入 Azure Data Lake Storage Gen2 时,将 Apache Iceberg 作为 sink format。通过 Copy activities,pipelines 可以直接写入 Iceberg tables,只需指定 dataset type 为 Iceberg,并配置合适 format 和 store settings。这可以与 Microsoft Fabric 或 Azure 上的 Databricks 等 downstream tools 无缝集成,后者可以使用 Unity Catalog 或 REST-compatible interfaces 等 external catalogs 读取和管理这些 Iceberg tables。

Google Cloud Dataflow 构建在 Apache Beam 之上,支持 structured data transformations 并交付到 Google Cloud Storage。虽然它不提供直接 Iceberg integration,但 Dataflow pipelines 可以将 Parquet data 落到 GCS,之后使用 Spark 或 Trino 等 compatible engines 注册为 Iceberg tables。Metadata 可以通过 BigQuery metastore 或 REST catalog 跟踪。

每个 provider 也支持 stream-oriented ingestion tools:

  • Amazon Data Firehose 可以将数据以 Parquet format 交付到 S3,或直接写入 Iceberg。
  • Azure Event Hubs 和 Google Pub/Sub 可以与 Spark Structured Streaming 或 Flink 等 stream processors 搭配,将数据写入 Iceberg tables。

这些 services 在各自 cloud environments 中提供强 operational support 和 compliance alignment。不过,它们与 Iceberg 的原生集成成熟度可能不同。希望在 cloud-native stack 中采用 Iceberg 的组织,不仅要评估 storage 和 compute compatibility,也要评估 catalog integration、schema evolution support 和长期 maintenance implications。对许多组织来说,这些 ingestion services 充当连接 legacy 或 proprietary data formats 与以 Iceberg 为中心的更灵活、开放 lakehouse architecture 的桥梁。

6.4.10 Tool Selection Considerations

Apache Iceberg 在组织中的采用增长,带来了多种支持其 ingestion layer 的工具。这些工具包括 Apache Spark 和 Flink 等 general-purpose engines,Fivetran 和 Airbyte 等 connector-based ELT platforms,以及 Confluent 和 Redpanda 等 streaming platforms。每种工具的 ingestion 方法都不同;有些优先 real-time streaming,有些提供 declarative syncs,还有一些聚焦 orchestration 或 transformation。

选择 ingestion tool 时,有几个实践考虑可以指导决策:

Ingestion model——选择与 latency needs 对齐的工具。Flink 或 Redpanda 等 streaming engines 更适合 high-frequency event streams。Spark 或 micro-batch tools 可能更适合 scheduled ETL 或 near-real-time ingestion。

Catalog integration——确保工具支持你选择的 Iceberg catalog type,无论它是 REST catalog、AWS Glue,还是 filesystem-based implementation。Confluent 和 Fivetran 等工具提供 integrated catalog support,可以简化 discovery 和 governance。

Schema evolution support——寻找能有效管理 schema drift 的工具。支持 Schema Registry 的 streaming tools,例如 Redpanda 或 Confluent,通常比 file-based batch tools 提供更具韧性的 evolution capabilities。

Data transformation needs——如果 pipeline 包含 joins、filtering 或 enrichment,stream-processing engine,例如 Flink,或 general-purpose framework,例如 Spark,将提供必要灵活性。

Operational maturity——考虑 deployment、monitoring 和 scaling 的容易程度。Fivetran 或 cloud-native ingestion layers 等 managed services 通常会降低 operational burden,但可能牺牲 customization。

Cloud environment——许多工具在各自 native cloud ecosystems 中表现最好。AWS-based environments 会受益于 Glue 和 S3 integration,而 Azure 和 GCP 可能偏向与其 storage 和 metadata layers 良好互操作的 solutions。

没有 one-size-fits-all ingestion tool。大多数现代 Iceberg deployments 会依赖多种 technologies,以满足不同 data sources、use cases 和 user teams 的多样需求。选择一小组互补你的架构、并且组织技能集中有良好支持的工具,有助于为 Iceberg lakehouse 建立可持续、灵活的 ingestion layer。

6.5 在上下文中应用 Ingestion Requirements

审查主要 ingestion models 和大量可用 tools 后,下一步是理解如何在实践中应用这些概念。本节讨论基于本章前面引入的 requirement categories 的场景:latency、throughput、transformation complexity 和 schema evolution。每个 scenario 都说明某个具体 ingestion need 如何影响 architectural choices。

这些示例不意在提供处方。大多数真实世界 deployments 中,你不会孤立地针对单一 requirement 优化架构。相反,你必须平衡多个优先级,例如在保留 data quality 的同时最小化 latency,或在支持 high schema variability 的同时降低 operational burden。你还必须考虑 existing constraints,例如当前 cloud provider、team expertise 和 governance model。

本节旨在通过探索不同 requirements 如何映射到不同 ingestion models 和 tooling choices,提供一种结构化思考 tradeoffs 的方式。它会帮助你评估如何设计一个与更广泛 data platform strategy 对齐的解决方案。每个 subsection 都展示一个 sample use case,讨论其 dominant requirement 的影响,并概述如何使用前面介绍过的 ingestion tools 来满足该需求。

6.5.1 优先考虑 Low Latency

当 low latency 是首要关注点时,ingestion pipeline 必须被设计为最小化数据生成和进入 Iceberg table 可用之间的时间。这在 fraud detection、personalization engines 或 operational monitoring dashboards 中很常见,因为这些场景需要在数据到达数秒内查询 fresh data。

在这些情况下,streaming ingestion 是首选模型。Apache Flink、Redpanda 和 Confluent Tableflow 支持 streaming ingestion workflows,可以以最小延迟将 Kafka 或 Redpanda topics materialize 到 Iceberg tables。这些工具可以基于 event time 运行,支持 watermarking,并应用 real-time transformations。

示例场景

一家 fintech platform 想要监控 real-time customer transactions,以检测可疑活动。每个 transaction event 必须在发出后的 5 秒内对 analytical systems 可用。

Design considerations:

  • 使用 Apache Flink 从 Kafka 读取数据,应用 filtering 和 enrichment,并每几秒通过 micro-batch commits 写入 Iceberg。
  • 如果需要更强 Kafka compatibility 和更低 overhead,可以使用 Redpanda,尤其是它支持 schema-based topic-to-Iceberg mapping。
  • Catalog consistency 和 commit frequency 必须调优,以确保 Iceberg snapshots 足够快地 committed,满足 freshness requirements,同时不压垮 metadata。

Tradeoffs:

  • Streaming systems 需要仔细调优,以避免频繁 commits 导致 Iceberg metadata bloat。
  • 由于 pipeline 是 continuous nature,monitoring 和 alerting 更关键。
  • 需要 performance tuning,以在规模化 ingestion 时不影响 downstream query workloads。

这种方法确保数据以最小 delay 可用,但要求更高 operational maturity。Low-latency ingestion pipelines 受益于强 schema validation、受控 commit frequencies 和优化 file sizes,以长期保持 Iceberg performance。

6.5.2 管理 High Throughput

面向 high throughput 设计的 ingestion pipelines 优先考虑高效处理大量数据的能力,通常来自多个 sources 并行。这些场景常见于 user-behavior tracking、telemetry pipelines 和大规模 application logging,其中 ingestion systems 必须每天处理数百万或数十亿 records。

Apache Spark、Apache Flink,以及 Redpanda 和 Qlik 等平台,可以在写入 Iceberg tables 时支撑高 ingestion volumes。这些工具支持 bulk writes、batching 和 compaction strategies,有助于管理 Iceberg 产生的 file 和 metadata overhead。

示例场景

一家 media streaming company 从跨设备的数百万用户那里收集 playback 和 interaction events。系统每天摄入超过 1000 亿 events,并将它们存入 Iceberg tables,用于下游分析。

Design considerations:

  • 使用 Apache Flink 搭配 checkpointing 管理 high-velocity Kafka streams,在 commit data 到 Iceberg 之前应用 deduplication 和 partitioning。
  • 使用 Qlik 或 Redpanda 管理数百个 topics 的 ingestion,并通过 automatic compaction 和 schema enforcement 减少 manual overhead。
  • Batch commits 并优化 file sizes,以限制 snapshot growth,并降低 queries 期间的 read amplification。

Tradeoffs:

  • High-throughput pipelines 需要仔细控制 file generation 和 commit frequency,以避免 Iceberg performance degradation。
  • Schema evolution 和 validation 必须自动化,以防止 source-side changes 导致 ingestion interruptions。
  • 长期 operational planning 对管理 partition sizes、metadata growth 和 compaction strategies 至关重要。

虽然系统架构可能强调 throughput,但它也必须考虑 Iceberg 对 metadata 的敏感性。Adaptive compaction、partition tuning 和 snapshot expiration 对于在 data volumes 扩展时稳定 performance 至关重要。

6.5.3 支持 Complex Transformations

有些 ingestion pipelines 在写入 Iceberg tables 之前,需要执行大量 data transformation。这包括跨 streams join、filtering、masking sensitive information,以及派生新字段。这在为 analytics、reporting 或 compliance workflows 准备数据的 pipelines 中很常见。

Apache Flink 和 Apache Spark 是该领域能力最强的选项。它们提供表达力强的 APIs 和 SQL interfaces,用于构建复杂 transformation logic。这些工具可以与 schema registries 集成,支持 time-based joins,并为 deduplication 或 windowed aggregations 等任务管理 stateful processing。

示例场景

一家 healthcare provider 从 patient monitoring devices 摄入数据,并将其与 historical records 合并,以跟踪 clinical metrics。Ingestion pipeline 必须在写入 Iceberg table 用于 clinical reporting 之前,对多个 data streams 进行 clean、normalize 和 join。

Design considerations:

  • 使用 Apache Flink 的 SQL 或 DataStream API,在写入 Iceberg 前执行 multistream joins、data cleansing 和 field derivation。
  • 使用 schema evolution support 适应 input formats 随时间变化。
  • 在 Iceberg 中应用 partitioning 和 bucketing strategies,以组织数据并支持下游 query performance。

Tradeoffs:

  • 复杂 transformation logic 会引入更多 moving parts,增加 pipeline failures 或 latency spikes 风险。
  • Stateful processing 需要调优 memory 和 checkpointing strategies,尤其是 long-running jobs。
  • 随着业务逻辑演进,需要更强 developer expertise 和 testing infrastructure 来维护 correctness。

这种 ingestion architecture 强调靠近 data source 的强 transformation capabilities 的重要性。组织通过在存储前执行 enrichment 或 filtering,降低下游 analytics 的成本和 latency,同时在 ingestion 期间执行 data quality 和 governance policies。

6.5.4 处理 Schema Evolution

Ingestion pipelines 经常运行在 data schemas 不断演进的环境中。Source systems 可能引入新字段、重命名已有字段或改变类型,尤其是在 application telemetry、SaaS integrations 或 customer interaction data 等领域。支持这些 changes 且不打断 downstream workflows,对可靠 data ingestion 至关重要。

Apache Iceberg 原生支持 schema evolution,包括添加和重命名 fields、重排序 columns,以及在安全情况下改变 field types。与 schema registries 集成或执行 structured typing 的 ingestion tools,例如 Redpanda、Confluent Tableflow 和 Airbyte,非常适合在 ingestion 期间处理 schema drift。

示例场景

一个 product analytics platform 从多个 mobile applications 摄入 event data。随着 apps 演进,events 会新增 fields,schema 频繁变化。Ingestion system 必须优雅处理这些变化,并将其反映到 Iceberg table structure 中,而不需要人工介入。

Design considerations:

  • 写入前使用带 built-in schema registry support 的工具,例如 Redpanda 或 Confluent,以确保 schema versions 被跟踪并保持 compatible。
  • 将 ingestion 配置为 append 或 merge-on-read mode,以适应 evolving schemas,同时避免 file rewrites。
  • 实施 monitoring 或 alerts,在 incompatible changes 或 schema mismatches 到达 storage layer 前标记出来。

Tradeoffs:

  • 依赖 static schemas 或缺少 schema registry integration 的工具,可能需要 manual updates 才能适应 changes。
  • 如果管理不当,schema evolution 可能引发 performance issues,尤其是在处理 nested fields 或 high column counts 时。
  • Iceberg 中频繁 schema updates 带来的 metadata churn,必须通过 periodic compaction 或 snapshot pruning 处理。

在 schema change 是常态的 environments 中,选择能自动抽象和管理这些 changes 的 ingestion tools,可以降低 operational friction 并提升 data reliability。将 ingestion pipeline 与 Iceberg 的 schema capabilities 对齐,有助于确保 downstream systems 即使在 upstream data 演进时也能持续正常运行。

6.5.5 平衡 Operational Overhead

Ingestion pipelines 不仅由技术 requirements 塑造,也由管理它们的团队的 operational realities 塑造。更简单的 pipelines 需要更少调优、更少 dependencies 和更低持续维护,可以释放时间和资源投入更高价值工作。这对较小团队,或优先快速迭代和降低 infrastructure complexity 的组织尤其重要。

Fivetran、Qlik(Upsolver)和 Airbyte 等工具强调 ease of deployment 和 managed operations。它们非常适合那些希望 ingestion pipelines “just work”,而无需手动管理 stream-processing infrastructure 或实现复杂 ingestion logic 的团队。

示例场景

一家 growth-stage company 需要从 Salesforce、HubSpot 和 Google Ads 等 SaaS tools 摄入 marketing 和 sales data 到 Iceberg tables,用于 dashboarding 和 ML feature generation。数据必须新鲜,但不需要 real time,管理 pipeline 的团队规模较小。

Design considerations:

  • Fivetran 或 Airbyte 等 managed ingestion service 可以将数据抽取并以 Parquet format 落入 cloud object storage。
  • 配置服务直接写入 Iceberg-compatible tables,或编排轻量 transformation step,在数据可查询前完成注册和 compact。
  • 依赖 built-in schema mapping 和 incremental sync modes,减少 manual schema management。

Tradeoffs:

  • 这些平台在 advanced transformations 或 custom data logic 上灵活性较弱。
  • Schema limitations 和 sync models 可能不适合所有 source types 或 change patterns。
  • 某些工具在规模扩大后,相比使用 Spark 或 Flink 自建 pipelines,成本可能更高。

对许多团队来说,降低 operational overhead 是与业务敏捷性和成本控制对齐的战略选择。虽然 managed platforms 未必满足所有 use cases,但它们可以作为 routine ingestion 的有效默认路径,让 engineering resources 专注 pipeline monitoring、validation 和 higher-order data modeling。

6.5.6 考虑 Existing Cloud Environments

虽然技术 requirements 往往驱动架构决策,但在实践中,许多 ingestion pipelines 会受到 existing cloud environments 影响。大多数组织已经标准化在一个或多个 cloud platforms 上,可用 tooling、identity and access management、data governance frameworks 和 operational models 都会影响哪些 ingestion solutions 实际可行。

AWS Glue、Microsoft Fabric 和 Google Cloud Dataflow 等 cloud-native services,能与各自 storage 和 compute platforms 无缝集成。同样,Confluent for AWS 或 Databricks on Azure 等工具经常被选择,不仅因为它们的能力,也因为它们可以干净地融入 existing architectures、compliance boundaries 和 support agreements。

示例场景

一个完全在 AWS 中工作的 data team 想要使用 Amazon S3 上的 Iceberg 构建 data lakehouse。他们已经使用 AWS Glue 做 metadata management,并偏好能在现有 IAM 和 network policies 内运行的工具。

Design considerations:

  • 使用 Glue、Athena 或 Amazon EMR 等 AWS-native tools 编排 ingestion,并在 Glue Catalog 中注册 Iceberg tables。
  • 评估支持 AWS S3 并与 Glue 集成的 managed ingestion solutions,例如 Fivetran 或 Confluent Tableflow。
  • 使用 IAM roles、bucket policies 和 region-based configurations 简化 security 和 cost management。

Tradeoffs:

  • Cloud-native tools 可能缺少更通用 open source platforms 中的一些功能。
  • 如果高度依赖 provider-specific services,切换 cloud providers 或采用 multicloud ingestion strategies 会更困难。
  • 特定 cloud-native tools 的一些 Iceberg integrations 仍在成熟中,尤其是 schema evolution 或 streaming workloads。

将 ingestion tools 与周围 cloud ecosystem 对齐,可以改善 integration、降低 friction,并通常加快 development cycles。虽然这可能限制 tool selection 的灵活性,但它会简化 governance,并帮助团队在现有 operational frameworks 中更快交付价值。大多数成功的 lakehouse architectures 并不是孤立构建的,而是作为现有 environments 和 constraints 的扩展。

本节探索的每个 ingestion requirement category,也就是 latency、throughput、transformation complexity、schema evolution、operational overhead 和 cloud alignment,都提供了评估 architectural decisions 的不同视角。孤立看,每个 requirement 都会指向特定 tools 和 patterns。但实践中,ingestion pipelines 是由这些 priorities 与 organization constraints 的平衡共同塑造的,例如 team size、security policies 和 cloud provider commitments。

我们看过的示例并不是 definitive blueprints,而是展示 data architects 如何权衡取舍并导航 competing needs。一个针对 throughput 优化的 pipeline 可能仍需要优雅支持 schema evolution。一个为 low operational overhead 构建的系统,可能也需要偶尔调优以处理 data volume bursts。选择正确 ingestion strategy,最终是让 capabilities 与 context 对齐。

通过从 functional requirements 和 constraints 的视角进行 ingestion design,而不是从单一工具或技术出发,团队可以开发出 robust、maintainable,并适合不断演进的数据需求的 ingestion pipelines。随着 Iceberg ecosystem 持续成熟,可用 tooling 范围会扩展,因此更需要通过结构化、context-aware analysis 来评估 ingestion options。

小结

向 Iceberg lakehouse 摄入数据可以采用 batch、streaming、micro-batch 或 hybrid models,每种模型适合不同 data latency 和 transformation needs。

Apache Spark 和 Flink 提供灵活、可扩展的 ingestion pipelines,并与 Iceberg 深度集成,非常适合复杂或 high-volume workflows。

Fivetran、Airbyte 和 Qlik(Upsolver)等工具提供 managed ingestion options,可降低 operational overhead,并支持 schema mapping 和 maintenance。

Confluent 和 Redpanda 等 Kafka-native platforms 支持将 topic data 直接 materialize 为 Iceberg tables,支持 low-latency ingestion 和 schema evolution。

AWS Glue、Microsoft Fabric 等 cloud-native services 提供与其 storage 和 catalog ecosystems 对齐的 ingestion capabilities,通常可以简化 governance 和 deployment。

每种 ingestion tool 和 approach 都应根据 functional requirements 评估,例如 latency tolerance、throughput demands、schema variability 和 team capacity。

真实世界 ingestion architectures 往往涉及取舍,并需要在多个 requirements 与现有 cloud 或 infrastructure constraints 之间平衡优先级。

围绕 Iceberg 的优势设计 ingestion pipelines,例如 schema evolution、snapshot isolation 和对 open formats 的支持,可以确保长期 flexibility 和 maintainability。