Skip to content
Home
Data Ingestion Guide

Data Ingestion Guide

Data Engineering Data Engineering 7 min read 1472 words Beginner ExcellentWiki Editorial Team

Data ingestion is the first step in any data pipeline. Get this wrong, and everything downstream is unreliable.

Ingestion Modes

Batch Ingestion

Data is collected and loaded in scheduled intervals (hourly, daily, nightly).

ProsCons
Simple to implementData delay (not real-time)
Easy error recoveryRequires scheduling infrastructure
Cost-effective (resource-efficient)Hard to handle late-arriving data
Well-understood tools

Best for: Historical data, aggregated reporting, non-time-critical analytics.

Streaming Ingestion

Data is ingested continuously, with sub-second latency.

ProsCons
Real-time insightsComplex infrastructure
No batch windowsHarder error recovery
Handles late data naturallyMore expensive

Best for: Real-time dashboards, fraud detection, IoT sensors, monitoring.

Micro-batch

Small batches every few seconds to minutes (Spark Streaming, Flink).

Best for: Near-real-time without full streaming complexity.

Ingestion Sources

Databases

TechniqueLatencyComplexityUse Case
JDBC/ODBC pullMinutes-hoursLowSmall tables, periodic sync
SQL dump + loadHoursLowFull database snapshots
Change Data Capture (CDC)SecondsHighReal-time sync, minimal load

Change Data Capture (CDC)

Captures database changes as they happen.

Methods:

  • Log-based (Debezium): Reads WAL (Write-Ahead Log). No performance impact.
  • Trigger-based: Database triggers on INSERT/UPDATE/DELETE. Adds load.
  • Timestamp-based: Query rows where updated_at > last_run. Simple but misses deletes.
-- Timestamp-based CDC
SELECT * FROM orders
WHERE updated_at > last_checkpoint;

Files

File TypeBest For
CSVSimple, universal. No schema support.
JSONNested data, API payloads
ParquetColumnar, analytics, best compression
AvroRow-based, schema evolution, streaming
ORCColumnar, Hive/Presto

Rule: For production data lakes, use Parquet or Avro. CSV is for ad-hoc analysis.

APIs

Making API calls to external or internal services:

# Example: paginated API ingestion
def fetch_all_pages(base_url, api_key):
    page = 1
    while True:
        resp = requests.get(
            f"{base_url}?page={page}",
            headers={"Authorization": f"Bearer {api_key}"}
        )
        data = resp.json()
        if not data["results"]:
            break
        yield data["results"]
        page += 1
API TypeComplexityRate LimitsReliability
RESTLowCommonGood
GraphQLMediumVariableGood
WebhooksLowNoneEvent-driven
gRPCHighConfigurableBest

Ingestion Patterns

Full Load

Copy the entire source every time.

Source → [SELECT * FROM table] → Target
  • Pros: Simple, ensures complete data
  • Cons: Slow for large tables, wastes bandwidth
  • When: Small dimension tables (< 100K rows)

Incremental Load

Copy only new/changed data.

Source → [WHERE updated_at > last_run] → Target
  • Pros: Fast, efficient
  • Cons: Misses deletes, requires timestamp column
  • When: Large fact tables, regular schedules

Upsert (Merge)

Apply changes to existing records.

Source → [INSERT OR UPDATE WHERE key matches] → Target
  • Pros: Handles changes, idempotent
  • Cons: More complex, can be slow
  • When: When data is updated in place

Ingestion Pipeline Architecture

Simple Pipeline (Batch)

Source DB → Python script (SQL export) → S3/GCS (CSV/Parquet) → Data warehouse

Orchestrated Pipeline

Source DB → Airflow (scheduler) → Spark/EMR (transform) → Data lake
                                       ↓
                              Incremental load to warehouse

Streaming Pipeline

DB CDC (Debezium) → Kafka → Flink/Spark Streaming → Kafka sink → Warehouse
                          ↓
                Real-time dashboard

Common Ingestion Tools

| Tool | Type | Best For | |

Batch vs Streaming Ingestion

Batch Ingestion

Batch ingestion processes data in discrete chunks at scheduled intervals. It is simpler to implement, easier to debug, and more cost-effective for large volumes. Common batch tools include Apache Airflow (orchestration), Spark (processing), and AWS Glue (serverless ETL).

Best for: Historical data, daily reporting, non-time-sensitive analytics, large file processing.

Streaming Ingestion

Streaming ingestion processes data in real-time as it arrives. It requires more infrastructure — message brokers (Kafka, Kinesis), stream processors (Flink, Spark Streaming), and state management.

Best for: Real-time monitoring, fraud detection, clickstream analytics, IoT data.

Change Data Capture (CDC)

CDC captures database changes in real-time without impacting source performance. Tools like Debezium (Kafka Connect) read the database transaction log (binlog, WAL) and stream changes to downstream systems:

PostgreSQL WAL → Debezium → Kafka → Flink → Data Lake

CDC enables real-time synchronization from operational databases to analytical systems with near-zero latency and minimal overhead on the source database.

Ingestion Formats

Choose data formats carefully based on use case:

  • Parquet — Columnar format optimized for analytics. Compresses well (3-5x reduction). Best for data lakes and analytical queries.
  • Avro — Row-based format with embedded schema. Best for streaming and Kafka.
  • JSON — Flexible but verbose. Best for semi-structured data and API responses.
  • CSV — Universally readable but no schema enforcement. Best for simple exports.

Schema Evolution

Data schemas change over time. Ingestion pipelines must handle new columns, deleted columns, changed data types, and renamed fields. Avro and Parquet support schema evolution with defined rules (adding nullable columns is safe, removing columns is breaking). Use schema registries (Confluent Schema Registry, AWS Glue Schema Registry) to enforce compatibility rules across producers and consumers.

FAQ

What is data engineering? Data engineering builds infrastructure and pipelines to collect, store, and process data at scale. It involves ETL/ELT processes, data warehousing, streaming systems, and ensuring data quality and accessibility for analytics and machine learning.

What is the difference between ETL and ELT? ETL (Extract-Transform-Load) transforms data before loading into the target system. ELT (Extract-Load-Transform) loads raw data first and transforms in-place. ELT leverages modern data warehouses like Snowflake and BigQuery for compute power.

What is a data pipeline? A data pipeline moves data from source systems to destinations, applying transformations along the way. Pipelines can be batch (scheduled intervals) or streaming (continuous processing). Tools include Airflow, dbt, and Spark.

Should I use a data lake or a data warehouse? Data lakes store raw data in native formats (cheap, flexible). Data warehouses store structured, curated data optimized for analytics (faster, more expensive). Modern architectures use both — lakehouse architecture combines their strengths.

What is the role of a data catalog? A data catalog indexes and documents available data assets — their schemas, lineage, quality metrics, and ownership. It helps data consumers discover, understand, and trust the data they work with.

Batch vs Streaming Ingestion

Batch Ingestion

Batch ingestion processes data in discrete chunks at scheduled intervals. It is simpler to implement, easier to debug, and more cost-effective for large volumes. Common batch tools include Apache Airflow (orchestration), Spark (processing), and AWS Glue (serverless ETL).

Best for: Historical data, daily reporting, non-time-sensitive analytics, large file processing.

Streaming Ingestion

Streaming ingestion processes data in real-time as it arrives. It requires more infrastructure — message brokers (Kafka, Kinesis), stream processors (Flink, Spark Streaming), and state management.

Best for: Real-time monitoring, fraud detection, clickstream analytics, IoT data.

Change Data Capture (CDC)

CDC captures database changes in real-time without impacting source performance. Tools like Debezium (Kafka Connect) read the database transaction log (binlog, WAL) and stream changes to downstream systems:

PostgreSQL WAL → Debezium → Kafka → Flink → Data Lake

CDC enables real-time synchronization from operational databases to analytical systems with near-zero latency and minimal overhead on the source database.

Ingestion Formats

Choose data formats carefully based on use case:

  • Parquet — Columnar format optimized for analytics. Compresses well (3-5x reduction). Best for data lakes and analytical queries.
  • Avro — Row-based format with embedded schema. Best for streaming and Kafka.
  • JSON — Flexible but verbose. Best for semi-structured data and API responses.
  • CSV — Universally readable but no schema enforcement. Best for simple exports.

Schema Evolution

Data schemas change over time. Ingestion pipelines must handle new columns, deleted columns, changed data types, and renamed fields. Avro and Parquet support schema evolution with defined rules (adding nullable columns is safe, removing columns is breaking). Use schema registries (Confluent Schema Registry, AWS Glue Schema Registry) to enforce compatibility rules across producers and consumers.

—|—|—| | Apache Kafka | Streaming | High-throughput event streaming | | Apache NiFi | Both | File ingestion, data routing | | Airbyte | Both | SaaS data sources (100+ connectors) | | Fivetran | SaaS | Managed connectors (expensive) | | Stitch | SaaS | Simple managed ingestion | | Debezium | CDC | Database change capture | | AWS DMS | CDC | Database migration + sync | | dlt (Python) | Batch | Simple Python ingestion library |

Ingestion Schema Management

Schema-on-Read

Don’t enforce schema at ingestion. Apply it when reading.

  • Pros: Flexible, ingests anything
  • Cons: Downstream queries can break

Schema-on-Write

Enforce schema during ingestion.

  • Pros: Data quality enforced early
  • Cons: Rejects messy data

Best approach: Schema evolution support (Avro, Parquet) with validation warnings, not failures.

Monitoring Ingestion

MetricWhat It Tells You
Rows ingestedVolume
Ingestion latencyTimeliness
Error rateData quality
Duplicate rateReliability
Schema driftSource changes
Freshness (max timestamp)Pipeline health

Set up alerts: If no data arrives for 2x the expected interval, notify.

Ingestion Anti-Patterns

Anti-PatternProblemFix
Querying production DB directlyLoad, risk of crashRead replica or CDC
No error handlingSilent data lossDead letter queue, alerts
One pipeline for everythingComplexity, brittlenessSeparate pipelines per source
Loading without validationGarbage in, garbage outRow counts, null checks
Hardcoded credentialsSecurity riskSecrets manager

A well-built ingestion pipeline is invisible — data just arrives reliably.

ETL Pipelines GuideData Warehousing GuideData Quality Guide

Section: Data Engineering 1472 words 7 min read Beginner 756 articles in section Report inaccuracy Back to top