Join our Streaming Lakehouse Tour!
Register Now.->

Lambda Architecture

The Lambda Architecture is a traditional data processing architecture pattern designed to handle large-scale datasets by combining both batch and stream processing methods. It aims to provide a balance between low-latency real-time data processing and comprehensive, accurate batch analysis.

The architecture is composed of three main layers: the Batch Layer, the Speed Layer (or Streaming Layer), and the Serving Layer.

Core Layers

  1. Batch Layer (Cold Path):

    • Manages the Master Dataset: This layer stores the complete, immutable, append-only master dataset, which is the ultimate source of truth. This is typically stored in a distributed file system like HDFS or cloud object storage.
    • Precomputes Batch Views: Periodically (e.g., hourly or daily), the batch layer processes all or a large portion of the master dataset to produce comprehensive and accurate "batch views." These views are precomputed results of complex analyses.
    • Technologies: Often involves batch processing frameworks like Apache Hadoop (MapReduce), Apache Spark, or Apache Hive.
  2. Speed Layer (Hot Path / Streaming Layer):

    • Processes Real-time Data: This layer handles incoming data in real-time to provide low-latency updates and results for the most recent data. It compensates for the inherent latency of the batch layer.
    • Generates Real-time Views: The speed layer produces "real-time views," which might be incremental updates or approximations.
    • State Management: Requires its own state management for stream processing.
    • Technologies: Utilizes stream processing engines like Apache Storm, Apache Flink, Apache Samza, or RisingWave (though RisingWave often aims to simplify Lambda).
  3. Serving Layer:

    • Responds to Queries: This layer receives queries from applications or users.
    • Merges Views: It merges the results from the precomputed batch views (from the Batch Layer) and the real-time views (from the Speed Layer) to provide a comprehensive answer. The batch views provide accurate historical data, while the real-time views provide updates for recent data not yet processed by the batch layer.
    • Optimized for Reads: The serving layer typically uses specialized databases or data stores optimized for fast read access and querying (e.g., NoSQL databases, document stores, or specialized query engines).

How it Works

  1. All new data entering the system is dispatched to both the Batch Layer and the Speed Layer.
  2. The Batch Layer appends the data to the master dataset and periodically recomputes the batch views.
  3. The Speed Layer processes the new data immediately and updates its real-time views.
  4. When a query arrives at the Serving Layer, it queries both the batch views and the real-time views and combines the results to present a complete picture to the user. For example, a batch view might contain last night's total sales, and the speed layer would provide sales that occurred since then.

Advantages of Lambda Architecture

  • Fault Tolerance: Since the master dataset is immutable and batch views can be recomputed, it's resilient to hardware failures and human errors.
  • Data Accuracy: The batch layer eventually processes all data, ensuring high accuracy for historical analysis.
  • Low Latency for Recent Data: The speed layer provides quick access to insights from the most recent data.
  • Handles Large Datasets: Designed to cope with massive volumes of data.

Challenges and Criticisms

  • Complexity: The primary criticism of the Lambda Architecture is its complexity. It requires maintaining two distinct codebases and infrastructures for the batch and speed layers.
    • Developing, debugging, and deploying logic for two separate systems can be challenging and error-prone.
    • Ensuring consistency between the logic in the batch and speed layers is difficult.
  • Operational Overhead: Managing two separate processing pipelines increases operational burden.
  • Resource Intensive: Running both batch and streaming pipelines can be resource-intensive.
  • Latency in Merging: The serving layer needs to merge data from two sources, which can add some latency to queries, although it's generally designed to be fast.

Lambda vs. Kappa Architecture

The Kappa Architecture emerged as a simpler alternative to Lambda. It proposes using only a stream processing engine to handle both real-time and historical data, with reprocessing from an immutable log (like Kafka) to serve the role of the batch layer.

Modern stream processing systems like RisingWave, especially when combined with a durable log like Kafka and efficient state stores like Hummock, often aim to provide the benefits of Lambda (accuracy and low latency) with the operational simplicity closer to Kappa. By using incremental computation and materialized views, RisingWave can continuously update comprehensive views, potentially reducing the need for a completely separate batch layer for many use cases.

Relevance Today

While the Lambda Architecture was influential, many organizations are moving towards simpler, more unified architectures like Kappa or hybrid approaches leveraging powerful, modern stream processing engines. However, understanding Lambda is still important as it laid the groundwork for many big data concepts and is still in use in some legacy systems or specific scenarios where its trade-offs are acceptable.

Related Glossary Terms

The Modern Backbone for Your
Event-Driven Infrastructure
GitHubXLinkedInSlackYouTube
Sign up for our to stay updated.