Home United States USA — software Streaming in Spark, Flink, and Kafka Streaming in Spark, Flink, and Kafka

Streaming in Spark, Flink, and Kafka Streaming in Spark, Flink, and Kafka

305
0
SHARE

Learn about what Apache Spark, Apache Flink, and Apache Kafka are and get a comparison between each so that you know when you should use which for streaming.
Both Spark streaming and Flink provide exactly one guarantee: that every record will be processed exactly once, thereby eliminating any duplicates that might be available. Both provide very high throughput compared to any other processing system, like Storm, and the overhead of fault tolerance is low in both the processing engines, whereas Kafka clients can be created for at-most-once, at-least-once, and exactly-once message processing needs. Kafka gets used for two broad classes of applications:
There is a need for real-time stream processing, as data is arriving as continuous flows of events; for example, cars in motion emitting GPS signals; financial transactions; the interchange of signals between cellphone towers; web traffic including things like session tracking and understanding user behavior on websites; and measurements from industrial sensors.
So with all these types of data, stream processing turns out to be a good method. Stream processing is challenging when it comes to maintaining consistency and fault tolerance because, with the dynamism that is associated with this data generation and processing, you need a system that can keep up with that and handle interruptions of connectivity. You also need the ability to consume the data from the stream processor, so you need to be able to answer complex queries in the form of windows. Thus, you need rich windowing definitions and different ways to pull out information and roll up and aggregate information. Also, you don’ t want the system to be bogged down, so you need low latency and high throughput in a stream processor.
The point where Spark streaming and Flink differ is in their computation model. While Spark has adopted micro batches, Flink has adopted a continuous flow operative-based streaming model. As far as window criteria, Spark has a time-based window criteria, whereas Flink has record-based or any custom user-defined window criteria.
Flink and Spark are both general-purpose data processing platforms and top-level projects of the Apache Software Foundation (ASF) . They have a wide field of applications and are usable for dozens of Big Data scenarios. Both are capable of running in standalone mode, yet many are using them on top of Hadoop (YARN, HDFS) . They share strong performance due to their in-memory nature.
Let’s have a look on Spark, Flink, and Kafka, along with their advantages.
Spark is an open-source cluster computing framework with a large global user base. It is written in Scala, Java, R, and Python and gives programmers an Application Programming Interface (API) built on a fault tolerant, read-only multiset of distributed data items. In two years since its initial release (May 2014) , it has seen wide acceptability for real-time, in-memory, advanced analytics — owing to its speed, ease of use, and the ability to handle sophisticated analytical requirements.
Advantages of Spark:
Apache Flink is an open-source platform for distributed stream and batch data processing. Flink’s core is a streaming data flow engine that provides data distribution, communication, and fault tolerance for distributed computations over data streams. Flink also builds batch processing on top of the streaming engine, overlaying native iteration support, managed memory, and program optimization.
Advantages of Flink:
Apache Spark is considered a replacement for the batch-oriented Hadoop system. But it includes a component called Apache Spark Streaming, as well. Contrast this with Apache Flink, which is a Big Data processing tool and it is known to process big data quickly with low data latency and high fault tolerance on distributed systems on a large scale. Its defining feature is its ability to process streaming data in real time.
Apache Kafka is a distributed streaming platform. For more complex transformations, Kafka provides a fully integrated Streams API. The Streams API allows an application to act as a stream processor, consuming an input stream from one or more topics and producing an output stream to one or more output topics, effectively transforming the input streams to output streams.
Kafka helps to provide support for many stream processing issues:
These facilities help solve the hard problems that application faces: handling out-of-order data, reprocessing input as code changes, performing stateful computations, etc.
The streams API builds on the core primitives Kafka provides: it uses the producer and consumer APIs for input, uses Kafka for stateful storage, and uses the same group mechanism for fault tolerance among the stream processor instances.
Here’s a comparison of Spark and Flink based on data processing, memory management, data flow, CLI, and support for other streaming products.
Spark processes data in batch mode while Flink processes streaming data in real time. Spark processes chunks of data, known as RDDs while Flink can process rows after rows of data in real time. So, while a minimum data latency is always there with Spark, it is not so with Flink.
Flink can automatically adapt to varied datasets but Spark needs to optimize and adjust its jobs manually to individual datasets. Also, Spark does manual partitioning and caching. So, expect some delay in processing. Flink has a different approach to memory management. Flink pages out to disk when memory is full, which is what happens with Windows and Linux too. Spark crashes that node when it runs out of memory. But it does not lose data since it is fault tolerant.
Flink is able to provide intermediate results on its data processing whenever required. While Spark follows a procedural programming system, Flink follows a distributed data flow approach. So, whenever intermediate results are required, broadcast variables are used to distribute the pre-calculated results through to all the worker nodes.
Spark has CLIs in Scala, Python, and R. Flink does not really have a CLI, but the distinction is subtle.
To have a Spark CLI means users can start up Spark, obtain a SparkContext, and write programs one line at a time. That makes walking through data and debugging easier. Walking through data and running map and reduce processes, and doing that in stages, is how data scientists work.
Flink has a Scala CLI, too, but it is not exactly the same. With Flink, you write code and then run print () to submit it in batch mode and wait for the output.
Both Flink and Spark work with Kafka, the streaming product written by LinkedIn. Flink also works with Storm topologies.

Continue reading...