Tuesday
Hi Databricks Community,
I am working on a data lakehouse architecture on AWS, where HVR captures changes from OLTP databases such as Oracle and PostgreSQL, AWS S3 is used for storage, and Databricks handles data processing across Bronze, Silver, and Gold layers.
We need to maintain accurate downstream Delta tables while processing inserts, updates, and deletes from source systems.
I would like to understand the recommended architectural approach for the following scenarios:
Out-of-order events: If multiple updates for the same primary key arrive out of order, how can we ensure that an older event does not overwrite the latest record?
Duplicate events and retries: How should we handle duplicate CDC records or replayed files without creating inconsistent target data?
Delete propagation: What is the recommended approach to propagate source deletes from Bronze to Silver and Gold while retaining audit history where required?
Incremental processing: Would you recommend implementing custom Delta MERGE logic or using Lakeflow Declarative Pipelines AUTO CDC APIs for this type of architecture?
Performance: What are the best practices for handling high-volume CDC data, small files, and frequent MERGE operations on Delta tables stored in S3?
Our current architecture uses HVR for source ingestion and Databricks for downstream processing. I am particularly interested in a production-ready solution that balances data correctness, performance, maintainability, and cost.
If anyone has implemented a similar architecture, I would appreciate suggestions, design patterns, or code examples.
Thank you!
Wednesday
For this architecture, I'd keep Bronze as an immutable, replayable CDC layer and use Lakeflow AUTO CDC in Silver, provided HVR supplies reliable source sequencing metadata.
The key is to order changes using source transaction sequence or equivalent metadata rather than file arrival time, so late events don't overwrite newer values. I'd also define the delete strategy upfront: SCD Type 1 for current-state replication or SCD Type 2 when audit history is required.
For performance, I'd focus on incremental processing, controlling small-file growth, and monitoring MERGE duration and pipeline latency. AUTO CDC could simplify the sequencing and history-management logic compared with maintaining all of it in custom MERGE statements.
Wednesday
Hi @krishgarikipati ,
Thanks,
Khasim.
Wednesday
Hello, Use a source sequence number or commit timestamp to ensure only the latest change per primary key is applied. Deduplicate CDC records before merging, handle deletes with soft-delete flags or Delta Change Data Feed for audit requirements, and consider Lakeflow AUTO CDC for maintaining SCD Type 1 or Type 2 tables.
Wednesday
For this architecture, I'd keep Bronze as an immutable, replayable CDC layer and use Lakeflow AUTO CDC in Silver, provided HVR supplies reliable source sequencing metadata.
The key is to order changes using source transaction sequence or equivalent metadata rather than file arrival time, so late events don't overwrite newer values. I'd also define the delete strategy upfront: SCD Type 1 for current-state replication or SCD Type 2 when audit history is required.
For performance, I'd focus on incremental processing, controlling small-file growth, and monitoring MERGE duration and pipeline latency. AUTO CDC could simplify the sequencing and history-management logic compared with maintaining all of it in custom MERGE statements.
Wednesday
Hi @krishgarikipati ,
Thanks,
Khasim.
Wednesday
Great discussion! I’d lean toward AUTO CDC for handling out-of-order events and deletes, with proper sequencing and deduplication to keep the Delta tables consistent. Performance tuning and audit history are also key for a reliable production setup.
Wednesday
Ingestion: Land HVR output in Bronze as append-only with Auto Loader checkpoints. Keep HVR’s operation-type and sequence/commit columns, since ordering and deletes depend on them.
Out-of-order events: Prefer AUTO CDC with sequence_by set to the HVR sequence/commit column. It handles late events and delete tombstones. Prefer Custom Merge if AUTO CDC doesn't fit.
Audit: Don’t rely on time travel, since VACUUM removes old versions. Use SCD Type 2 or the immutable Bronze layer.
Performance: Enable deletion vectors on Silver tables with frequent MERGEs. Use liquid clustering on commonly filtered or joined columns. Predictive Optimization only covers UC managed tables, so schedule OPTIMIZE and VACUUM for external ones.