Last Updated: January 8, 2026
In the first chapter of this section, we explored batch and stream processing as two distinct paradigms. Batch gives you accurate results on complete data but with high latency. Stream gives you fast results but on potentially incomplete data. What if you need both?
Consider a real-time dashboard showing total revenue. Users want to see current numbers updating live, but they also need accurate end-of-day totals. Stream processing can show approximate real-time updates, but late events and edge cases mean it might miss some transactions. Batch processing captures everything but only updates once a day.
Lambda Architecture addresses this by running both systems in parallel. The batch layer provides accuracy. The speed layer provides low latency. The serving layer merges the results. You get the best of both worlds at the cost of maintaining two separate pipelines.
In this chapter, you will learn:
Many real systems need two things at the same time:
That combination is common in revenue, fraud, recommendations, IoT monitoring, and social media metrics.
If you choose only one paradigm, you usually sacrifice the other.
| Requirement | Batch | Stream |
|---|---|---|
| Complete data | Yes | Maybe (late events) |
| Exact aggregates | Yes | Approximate |
| Real-time updates | No | Yes |
| Handle reprocessing | Easy | Complex |
| Use Case | Why Both? |
|---|---|
| Revenue dashboards | Live updates + accurate daily totals |
| Fraud detection | Immediate alerts + refined analysis |
| Recommendation engines | Real-time personalization + accurate models |
| IoT analytics | Live monitoring + historical trends |
| Social media metrics | Live counts + accurate engagement stats |
Lambda Architecture was introduced by Nathan Marz in his book "Big Data." It proposes three layers:
| Layer | Purpose | Processing | Latency |
|---|---|---|---|
| Batch Layer | Complete, accurate results | Processes all historical data | Hours |
| Speed Layer | Real-time updates | Processes recent events | Seconds |
| Serving Layer | Merge and serve queries | Combines both views | Milliseconds |
The batch layer processes the entire dataset to produce accurate views.
| Characteristic | Description |
|---|---|
| Immutable master data | All raw data stored permanently |
| Recompute from scratch | Each run processes entire history |
| Eventually consistent | Results available after job completes |
| Fault tolerant | Can always recompute from raw data |
Storing raw, immutable data enables:
The speed layer exists for one reason: users do not want to wait for batch.
It processes only the newest data and produces a real-time view that fills the gap until batch catches up.
| Characteristic | Description |
|---|---|
| Incremental updates | Only processes new events |
| Eventual replacement | Batch layer eventually overwrites |
| Approximate results | May miss late events |
| Low latency | Updates in seconds |
The speed layer only covers recent data:
The speed layer only needs to cover data since the last batch run.
Once the batch layer recomputes and publishes new batch views, the speed layer’s older data becomes redundant and can be cleared.
This keeps the speed layer lightweight.
The serving layer makes Lambda usable. Without it, you would have two separate systems and no clean way to query them.
For aggregation queries, merging is straightforward:
Serving needs stores optimized for reads. Common choices include:
| Store Type | Use Case | Examples |
|---|---|---|
| Key-value | Simple lookups | Redis, Cassandra |
| Document | Flexible schemas | MongoDB, Elasticsearch |
| Time-series | Metric queries | InfluxDB, TimescaleDB |
| OLAP | Complex aggregations | Druid, Pinot, ClickHouse |
When batch completes, it overwrites the batch view:
A typical deployment looks like this:
| Component | Option 1 | Option 2 | Option 3 |
|---|---|---|---|
| Ingestion | Kafka | Kinesis | Pulsar |
| Batch storage | HDFS | S3 | ADLS |
| Batch compute | Spark | MapReduce | Flink Batch |
| Stream compute | Flink | Spark Streaming | Kafka Streams |
| Batch serving | Druid | ClickHouse | Cassandra |
| Speed serving | Redis | Memcached | Cassandra |
The biggest criticism of Lambda Architecture: You end up implementing the same business logic twice.
| Challenge | Description |
|---|---|
| Duplicate logic | Same transformation in two codebases |
| Different languages | Batch in Scala, stream in Java |
| Testing complexity | Must verify both produce same results |
| Maintenance burden | Every change requires two updates |
| Skill requirements | Team needs both batch and stream expertise |
Some approaches to reduce duplication:
| Approach | How It Helps |
|---|---|
| Unified frameworks | Spark, Flink support both batch and stream |
| Shared libraries | Core logic in reusable modules |
| SQL-based processing | Same SQL for batch and stream |
| Code generation | Generate both from common definition |
Running Lambda Architecture requires:
Lambda Architecture provides both accuracy and low latency by running parallel pipelines: