Sunday, 1 November 2026

⚡ Batch Processing vs Stream Processing: What’s the Difference?

 Imagine a bank processing millions of transactions every day.

At the end of the day, the bank wants to know:

"How much money was transferred today?"

But there's another question:

"Is this transaction happening right now suspicious?"

Both questions use transaction data.

But they need completely different ways of processing it.

That is where Batch Processing and Stream Processing come in.


📦 First, What Is Batch Processing?

The simplest way to understand batch processing is:

Collect data first. Process it later as a group.

Imagine a company collecting all its sales transactions throughout the day.

Instead of processing every transaction immediately, it waits until midnight.

10:00 → Transaction
11:00 → Transaction
12:00 → Transaction
...
23:59 → Transaction

          ↓

     Batch Processing

          ↓

    Daily Sales Report

The entire collection of data is treated as a batch.


🧑‍🍳 A Simple Analogy

Think about a restaurant preparing food.

Instead of preparing one meal every time an ingredient arrives, the chef might prepare a large batch of ingredients together.

That's essentially the idea behind batch processing.

Accumulate → Process → Produce Result


🏢 Where Is Batch Processing Useful?

Batch processing works well when immediate results aren't required.

For example:

Banking

Generate a daily transaction report.

Retail

Calculate yesterday's sales.

HR

Generate monthly payroll.

Data Warehousing

Load data from operational databases every night.

Machine Learning

Process millions of historical records to create a training dataset.


🧠 A Simple Batch Example

Suppose we have:

transactions.csv
transaction_id,amount
101,500
102,1200
103,750
104,3000

We could process the entire file using Python:

import pandas as pd

df = pd.read_csv("transactions.csv")

total = df["amount"].sum()

print("Total transactions:", total)

The program reads the dataset as a batch and produces the result.


⚡ Now Let's Look at Stream Processing

Stream processing takes a completely different approach.

Instead of waiting for data to accumulate:

Process data as it arrives.

Imagine a transaction happening right now.

Transaction
     ↓
Event
     ↓
Stream
     ↓
Processing
     ↓
Result

There is no waiting for the end of the day.


🏦 Let's Return to Our Banking Example

Suppose a customer makes this transaction:

₹2,00,000

The system receives the event immediately.

A stream-processing system could:

Transaction
     ↓
Kafka
     ↓
Stream Processor
     ↓
Fraud Detection Model
     ↓
Risk Score
     ↓
Alert

If the transaction looks suspicious, an alert can be generated almost immediately.

That's where streaming becomes valuable.


🔥 Batch vs Stream — The Fundamental Difference

The easiest way I remember it is:

Batch

"Give me the data, and I'll process it together."

Stream

"Give me each event as it happens, and I'll process it immediately."


📊 Technical Comparison

CharacteristicBatch ProcessingStream Processing
DataCollection of recordsContinuous events
ProcessingPeriodicContinuous
LatencyMinutes → hoursMilliseconds → seconds
VolumeLarge batchesContinuous flow
Typical useReportsReal-time decisions
ComplexityRelatively simplerMore complex
ExampleDaily sales reportFraud detection

The exact latency depends on the architecture; "real-time" does not necessarily mean zero delay.


⏱️ Latency vs Throughput

This is an important concept.

Two systems can process the same amount of data but have very different characteristics.

Latency

How long does it take for one event to be processed?

For example:

Transaction occurs
        ↓
     100 ms
        ↓
Fraud decision

That's low latency.


Throughput

How much data can the system process in a given period?

For example:

1 million events / second

That's high throughput.

A good streaming architecture often needs to balance latency, throughput, scalability, and reliability.




🔄 One Event vs One Batch

This is perhaps the simplest visual comparison.

Batch

Data Data Data Data Data
        ↓
   [COLLECT]
        ↓
      BATCH
        ↓
    PROCESS

Streaming

Data → Data → Data → Data → Data
  ↓      ↓      ↓      ↓      ↓
PROCESS PROCESS PROCESS PROCESS PROCESS

The difference isn't merely how fast they are.

It's when the system chooses to process the data.


📨 Where Does Kafka Fit?

You'll often hear Apache Kafka mentioned whenever streaming is discussed.

Kafka is commonly used as an event streaming platform.

It acts as a durable, distributed layer through which producers publish events and consumers read them.

A simplified architecture looks like:

Producer
   ↓
Kafka Topic
   ↓
Consumer

For example:

Banking Application
        ↓
   Kafka Topic
        ↓
Fraud Detection

Another consumer could independently read the same stream:

                  → Fraud Detection
                 /
Banking App → Kafka
                 \
                  → Analytics

This is one of the powerful ideas behind event-driven architectures.

One event can be consumed by multiple downstream systems.



🧮 A Little More Technical: Windows

Here's where stream processing gets interesting.

Suppose we're receiving thousands of transactions continuously.

We may want to calculate:

How many transactions occurred during the last 5 minutes?

We can't wait for the day to end.

So we can use a time window.

10:00 ───────── 10:05
       5-minute window

Then:

10:05 ───────── 10:10
       next window

Common window concepts include:

  • Tumbling window — fixed, non-overlapping intervals
  • Sliding window — overlapping intervals
  • Session window — groups events based on periods of activity

These concepts allow stream-processing systems to perform calculations over continuously arriving data.



🤖 Stream Processing + Machine Learning

Now we can connect this to Data Science.

Suppose an online payment arrives:

Transaction
     ↓
Feature extraction
     ↓
ML model
     ↓
Fraud probability

The model might return:

Fraud probability = 0.94

The system could then:

0.94 > threshold

       ↓

Flag transaction
       ↓
Generate alert

This is an example of real-time inference.

The ML model doesn't necessarily need to be trained every time.

The trained model can be deployed into the streaming pipeline and used to score incoming events.


⚠️ Streaming Is Not Automatically Better

This is important.

It can be tempting to think:

Streaming = modern
Batch = old

That's not correct.

The processing model should match the business requirement.

Imagine generating a company's annual financial report.

Does it need millisecond latency?

No.

A batch process is perfectly reasonable.

But if you're detecting a fraudulent transaction:

Waiting until tomorrow is useless.

That's where streaming becomes valuable.


🏗️ A Modern Architecture Can Use Both

Real enterprise systems don't necessarily choose only one.

They often use both.

For example:

                    Transactions
                         ↓
                 ┌───────┴───────┐
                 ↓               ↓
             Streaming          Storage
                 ↓               ↓
          Fraud Detection       Batch
                 ↓               ↓
               Alert       Daily Analytics

The same underlying business data can support:

  • real-time decisions
  • historical analysis
  • machine learning
  • reporting

This is sometimes described as a lambda-style architecture, although modern architectures increasingly use other patterns depending on the platform and requirements.


🌍 A Real-World Example

Let's take an e-commerce platform.

A customer places an order.

Real-time path

Order
 ↓
Event Stream
 ↓
Inventory Check
 ↓
Payment Validation
 ↓
Recommendation / Fraud Model

The customer needs a response immediately.

Batch path

At the end of the day:

All Orders
 ↓
Data Warehouse
 ↓
Daily Sales Analysis
 ↓
Management Dashboard

Same business domain.

Two different processing requirements.


🧠 What I Take Away From This

When I first came across batch processing and stream processing, I initially thought the difference was simply:

"Batch is slow and streaming is fast."

But that's an incomplete way to look at it.

The more useful question is:

How quickly does the business need to react to the data?

If the answer is:

"We can wait."

Batch processing may be sufficient.

If the answer is:

"We need to react as the event happens."

Then streaming becomes important.

And once we start thinking in terms of events, latency, throughput, windows, Kafka, and real-time inference, we're no longer just moving data.

We're building systems that can respond to data as it happens.


🌱 Final Thoughts

Data pipelines are not all designed the same way.

Some are built to process large amounts of historical data efficiently.

Others are built to process continuous events with low latency.

And many real-world architectures combine both.

The important thing isn't choosing the "modern" option.

It's understanding the requirement:

Do we need to analyze what happened yesterday, or do we need to react to what is happening right now?

That question often determines whether batch processing, stream processing, or a combination of both makes sense.

Sunday, 16 August 2026

Data Pipelines Explained — How Data Travels from Source to Insight

We generate data constantly.

Every time someone:

  • makes a payment
  • opens a mobile application
  • places an order
  • searches a website
  • sends an API request
  • accesses a server
  • interacts with an IoT device

some form of data is produced.

But there is a gap between:

Data being generated

and

Data becoming useful information.

That gap is where data pipelines come in.


🚚 Think of a Data Pipeline Like a Supply Chain

Imagine ordering a product online.

The product doesn't simply appear at your doorstep.

It goes through:

Manufacturer
     ↓
Warehouse
     ↓
Transportation
     ↓
Distribution Center
     ↓
Delivery
     ↓
You

A data pipeline works in a surprisingly similar way.

Data Sources
     ↓
Data Ingestion
     ↓
Storage
     ↓
Processing
     ↓
Serving
     ↓
Analytics / ML / AI

The data is generated somewhere, transported, processed, and finally delivered to the place where it creates value.


🏗️ What Exactly Is a Data Pipeline?

A data pipeline is a series of processes that move data from one or more sources to a destination while potentially performing operations such as:

  • collection
  • validation
  • transformation
  • enrichment
  • aggregation
  • storage

A simple example:

Application
     ↓
Database
     ↓
Data Pipeline
     ↓
Data Warehouse
     ↓
Dashboard

But real enterprise pipelines are usually much more complicated.



1️⃣ Data Sources — Where Does Data Come From?

The first question in any pipeline is:

Where is the data being generated?

There could be dozens or even thousands of sources.

Structured sources

Oracle Database
MySQL
PostgreSQL
SQL Server

Files

CSV
JSON
XML
Parquet

Applications

Mobile Apps
Web Applications
APIs
Microservices

Machine-generated data

Server Logs
IoT Sensors
Monitoring Systems
Network Devices

This is why modern data platforms need to support many different ingestion methods.


2️⃣ Data Ingestion — Getting Data into the Pipeline

Now we have data.

But how do we get it into our data platform?

That's the job of data ingestion.

There are several approaches.


📦 Batch Ingestion

Data is collected and moved periodically.

For example:

11 PM → Collect transactions

↓

12 AM → Load data

↓

1 AM → Process data

This might be perfectly acceptable for a daily financial report.


⚡ Streaming Ingestion

Sometimes waiting until midnight isn't good enough.

Imagine a fraud detection system.

A transaction happens:

₹75,000 transaction
       ↓
Streaming pipeline
       ↓
Fraud detection
       ↓
Alert

The data needs to move almost immediately.

Technologies such as Apache Kafka are commonly used in event-streaming architectures.


🔁 Change Data Capture (CDC)

Here's another interesting approach.

Suppose an Oracle database contains:

CUSTOMER_ID | BALANCE
101         | 50000

The customer deposits ₹10,000.

Instead of repeatedly copying the entire table, CDC can capture the change:

UPDATE CUSTOMER
SET BALANCE = 60000
WHERE CUSTOMER_ID = 101;

The downstream system receives the change rather than unnecessarily moving everything again.

This can significantly reduce data movement for large databases.



3️⃣ Storage — Where Does the Data Go?

Once data enters the platform, we need somewhere to store it.

And this is where our previous blog becomes relevant.

Remember:

ETL vs ELT?

In traditional ETL, transformation often happens before the data reaches the warehouse.

Modern ELT architectures often look like:

Source
  ↓
Ingestion
  ↓
Raw Data
  ↓
Cloud Storage / Data Lake
  ↓
Transformation
  ↓
Warehouse / Lakehouse

The raw data may be stored in:

  • Object Storage
  • Data Lakes
  • Cloud Warehouses
  • Lakehouses

🏞️ Raw Data vs Processed Data

Suppose an e-commerce company receives this event:

{
  "customer_id": 101,
  "product": "Laptop",
  "amount": 75000,
  "timestamp": "2026-08-04T10:30:00"
}

The raw event could be stored exactly as received.

Later, the pipeline might transform it into:

customer_id
product
amount
transaction_date
region
tax

This separation between raw data and processed data is extremely useful.

Why?

Because tomorrow you might discover a new use for the original data.


4️⃣ Data Processing — Making Data Useful

Raw data isn't necessarily ready for analytics.

We may need to:

  • remove duplicates
  • handle missing values
  • standardize formats
  • join datasets
  • calculate metrics
  • filter records
  • aggregate data

For example:

SELECT
    customer_id,
    SUM(amount) AS total_spend
FROM transactions
GROUP BY customer_id;

Now we're turning thousands of transactions into useful customer-level information.



5️⃣ Data Quality — The Part We Don't See

Here's something that's easy to overlook.

A pipeline can successfully move data...

and still produce bad results.

Imagine the pipeline says:

Records received: 10,000
Records processed: 10,000
Errors: 0

Looks perfect.

But suppose 2,000 records contain incorrect customer IDs.

The pipeline technically worked.

The data didn't.

That's why production data pipelines need data-quality checks.

Examples:

NULL checks
Duplicate checks
Range validation
Schema validation
Referential integrity
Record count validation

For example:

assert df["customer_id"].notna().all()

This simple check ensures every record has a customer ID.


6️⃣ Data Transformation vs Data Processing

These terms are sometimes used interchangeably, but there is a subtle distinction.

Transformation generally means changing the data.

For example:

USD → INR
Name → Uppercase
Timestamp → Date

Processing is broader.

It can include:

  • transformation
  • filtering
  • joining
  • aggregation
  • validation
  • enrichment

So transformation can be considered one part of data processing.


7️⃣ Serving Layer — Finally, Someone Uses the Data

We've collected it.

Stored it.

Processed it.

Validated it.

Now what?

The final data can be consumed by different systems.

📊 Business Intelligence

Power BI
Tableau
Oracle Analytics

🤖 Machine Learning

Training dataset
↓
ML model
↓
Prediction

🧠 AI Applications

Data
↓
Embeddings / Vectorization
↓
RAG / AI application

🖥️ Operational Applications

Processed data can also be returned to applications through APIs or other serving mechanisms.





⚡ What About Real-Time Data?

This is where things become really interesting.

Not every pipeline can wait hours.

Consider a banking transaction.

Customer
   ↓
₹50,000 transaction
   ↓
Event
   ↓
Kafka
   ↓
Stream Processor
   ↓
Fraud Model
   ↓
Risk Score
   ↓
Alert

The entire process might need to happen in seconds.

Compare that with a monthly business report.

There, processing once a day might be completely sufficient.

This gives us two broad pipeline patterns:

Batch

Large amount of data
        ↓
Periodic processing

Streaming

Continuous events
        ↓
Continuous processing

And this leads directly into our next topic:

Batch Processing vs Stream Processing


🛠️ A Small Practical Example

Let's imagine we have a CSV containing server performance data:

timestamp,cpu_usage,memory_usage
10:00,35,61
10:01,40,63
10:02,92,81

A simple Python pipeline might look like:

import pandas as pd

# Extract
df = pd.read_csv("server_metrics.csv")

# Transform
df["high_cpu"] = df["cpu_usage"] > 80

# Load
df.to_csv("processed_metrics.csv", index=False)

This tiny example follows the same basic principle as a much larger enterprise pipeline:

Extract
   ↓
Transform
   ↓
Load

The difference is scale, reliability, orchestration, monitoring, and complexity.


🏢 What Does a Production Pipeline Need?

A real production pipeline isn't just:

Read → Transform → Write

It needs to answer questions like:

What if the source database is unavailable?

Retry.

What if 5% of records are invalid?

Quarantine or reject them.

What if the pipeline crashes halfway through?

Resume safely without corrupting the data.

What if the schema changes?

Detect and handle the change.

How do we know the pipeline is healthy?

Monitoring and alerting.

This is where data engineering becomes much more than simply moving data.


🔍 Observability Matters

A production pipeline should provide visibility into:

  • execution time
  • records processed
  • failures
  • latency
  • data quality
  • throughput

For example:

Pipeline: Customer_Transactions

Status: SUCCESS

Records received: 1,250,000
Records processed: 1,247,892
Rejected: 2,108
Processing time: 14 min
Data quality: 99.8%

Now the team knows what actually happened.


🧠 Putting Everything Together

A modern enterprise data pipeline could look like:

                    DATA SOURCES
                         │
       ┌─────────────────┼─────────────────┐
       ↓                                              ↓                                              ↓
   Databases                               APIs                                     Logs
       │                                             │                                             │
       └─────────────────┼─────────────────┘
                         ↓
                  DATA INGESTION
               Batch / CDC / Streaming
                         ↓
                    RAW STORAGE
                    Data Lake
                         ↓
                 PROCESSING LAYER
              SQL / Python / Spark
                         ↓
                DATA WAREHOUSE
                   / LAKEHOUSE
                         ↓
          ┌──────────────┼──────────────┐
          ↓                                      ↓                                      ↓
      Dashboards                    ML                                  AI

And suddenly our original question has an answer.

How does data travel from source to insight?

It travels through a carefully designed pipeline where each stage has a specific responsibility.


🌱 Final Thoughts

When I first came across the term data pipeline, I imagined something relatively simple:

Data goes from A → B.

But modern data pipelines are much more than that.

They have to deal with:

  • huge data volumes
  • multiple data formats
  • real-time events
  • data quality
  • failures
  • schema changes
  • security
  • monitoring

And ultimately, the goal isn't simply to move data.

It's to move trusted data to the right place at the right time.

That's what turns raw data into something useful for analytics, machine learning, and AI.

⚡ Batch Processing vs Stream Processing: What’s the Difference?

 Imagine a bank processing millions of transactions every day. At the end of the day, the bank wants to know: "How much money was tr...