生态 Change Streams:零基建的原生 CDC
- 一句话
- 不需要 Kafka/Debezium,一行 `db.collection.watch()` 就能拿到带断点续传的实时变更流,运维面只有 MongoDB 本身。No Kafka/Debezium needed — one `db.collection.watch()` gets you a resumable real-time change stream, with MongoDB itself as the only operational surface.
- 窄场景
- 中小规模 CDC——把操作型数据同步到数仓/湖仓、缓存失效、事件驱动触发器;团队不想为"搬几张表"而运维一整套 Kafka。数据量和消费者数量上去后,这个能力的边界就到了。Small-to-medium CDC — syncing operational data to warehouses/lakehouses in real time, cache invalidation, event-driven triggers; teams that don't want to operate a whole Kafka stack "just to move a few tables." The capability hits its boundary as data volume and consumer count grow.
- 机制
- 构建在 replica set oplog 之上,对应用暴露可恢复游标:每个事件带 `resumeToken`,消费者重启后从 token 处续读,at-least-once 语义由驱动原生支持,无需外部 offset 存储。代价同样机制性:offset 持久化、多消费者 fan-out、背压、消费 lag 可观测性全要应用自己实现——这正是重型方案存在的理由。Built on the replica set oplog, exposing a resumable cursor to applications: every event carries a `resumeToken`, consumers resume from the token after restart, at-least-once semantics natively supported by drivers — no external offset storage. The cost is equally mechanical: offset persistence, multi-consumer fan-out, backpressure, and consumer-lag observability are all on the application — which is exactly why heavyweight CDC stacks exist.
- 生产验证
- Joey Filichia 用 change stream 直写 Databricks Delta 表,动机是"不想为搬文档而维护 Kafka"(https://medium.com/@jfilich/real-time-mongodb-cdc-into-databricks-without-kafka-b2beac34f518);PhysicsWallah 评估 OLake 做 MongoDB→Iceberg CDC 时,把"resume token + oplog 历史保留"列为正确性核心考量(https://github.com/datazip-inc/olake-docs/blob/HEAD/customer-stories/2026-01-30-physicswallah-mongodb-cdc-iceberg.mdx)。反向验证:vedric 的 ADR-006 对比后选了 Debezium + Kafka,理由是 fan-out、offset 自动管理、可观测性(https://github.com/vedric/mongodb-k8s-dbaas-platform/blob/HEAD/docs/decisions/ADR-006-cdc-debezium-vs-change-streams.md)——社区对"轻量用原生、重型用 Kafka"的分界线有明确共识。Joey Filichia wrote change streams straight into Databricks Delta tables, motivated by "not wanting to maintain Kafka just to move documents from point A to B" (https://medium.com/@jfilich/real-time-mongodb-cdc-into-databricks-without-kafka-b2beac34f518); PhysicsWallah, evaluating OLake for MongoDB→Iceberg CDC, listed "resume token + oplog history retention" as a core correctness consideration (https://github.com/datazip-inc/olake-docs/blob/HEAD/customer-stories/2026-01-30-physicswallah-mongodb-cdc-iceberg.mdx). Reverse validation: vedric's ADR-006 compared both and chose Debezium + Kafka, citing fan-out, automatic offset management, and observability (https://github.com/vedric/mongodb-k8s-dbaas-platform/blob/HEAD/docs/decisions/ADR-006-cdc-debezium-vs-change-streams.md) — the community has a clear consensus on the "native for light, Kafka for heavy" boundary.
- 竞品差距
- DynamoDB Streams 保留仅 24 小时、与 Lambda 深度绑定,跨云/自建消费别扭;PostgreSQL 逻辑复制需要外部连接器,数据库本身不给开箱即用的应用层订阅 API。文档/KV 类产品里,原生、驱动级、带断点续传的 CDC 订阅能力,MongoDB 是事实标准。DynamoDB Streams retains only 24 hours and is deeply bound to Lambda, awkward for cross-cloud/self-hosted consumption; PostgreSQL logical replication needs external connectors — the database itself gives you no out-of-the-box application-level subscription API. Among document/KV products, MongoDB's native, driver-level, resumable CDC subscription is the de facto standard.
- 证据等级
- 官方文档(机制)+ 社区共识(轻/重分界线)+ 独立生产个案。诚实备注:at-least-once 下的幂等去重要应用自己做,社区 ADR 已明示。Official docs (mechanism) + community consensus (the light/heavy boundary) + independent production cases. Honest note: idempotent dedup under at-least-once is the application's job, as the community ADR states explicitly.
- 最后核验
- 2026-10-012026-10-01