Spark Streaming!!
In this post, I will be exploring the facts about Spark Streaming.
- What is Streaming?
A method of transmitting or receiving data (especially video and audio material) over a computer network as a steady, continuous flow, allowing playback to start while the rest of the data is still being received.(Definition from Google dictionary)
- What is Spark Streaming?
It is a core spark API extension that enables scalability, fault-tolerant, high-throughput steaming processing of live data. This data can been ingested (Input) by Kafka, flume, HDFS, S3/blob/GCS and can be ingested by using complex algorithms created with high-level functions like map, reduce, joins and windows. Finally, this processed data can be pushed out to filesystem, databases, data lake or like dashboards.
Internally, it will work as follows, Spark streaming receive live input data from different sources and divide into small batches, which are then processed by spark engine to generate final results in batches.
Spark Streaming gives High-level abstraction called discretized steam or DStream. This is used in spark for continues data streaming. This can be created either from input source mentioned above or by applying high level operation on DStreams. Eventually it will represent sequence of RDDs.
Structured Streaming:
Structured streaming is fault tolerant highly scalable streaming engine which is build on spark SQL engine. This will allow you to perform action on batch mode it means on static data using Spark’s structured APIs, and run them in steaming fashion. This will reduce the latency issue.
- What is Realtime Analytics?
- Processing large amount of data in real time which is continuously increasing.
- There are always 3 Vs in big data: Volume, Velocity & Variety.
- The real time processing include all 3Vs in big data architecture.
- This streaming data can be generated from thousand of data sources, which sends the data continuously. Ability to process and collects TB’s Data and do the analytics on that data.
- Batch Processing Vs Realtime Processing
- Use cases for Realtime Analytics:
- IOT sensors: To take any action on IOT sensors, we need real time information. ex. Google nest Smart Sensor.
- Social media Trends:
- Twitters top trending keywords.
- Facebook personalized Adds. - Real time fraud detection in credit card and banking transaction. This need real time information to analysis.
- Google map shows real time traffic updates.
- Simple demo on Spark Streaming!
As per above Diagram Sections can be divided as follow:
Get Naval Hatode’s stories in your inbox
Join Medium for free to get updates from this writer.
Data:
You can use any data to ingest to the spark. I am using Datagen Source which will continuously generate the data to collect.
Collect:
Here, I am using Kafka cloud to collect the data. There are two ways to create the Kafka Cluster.
a. Install Kafka on the local/cloud vm and create the producers & consumer
b. Create Kafka Cloud account.
- Create Kafka Cloud free Account click here.
- Create Kafka cluster, use this link to create cluster.
- Create Kafka Topic, use this link to create topic
- Create connector to generate data (Producer/source) which will store the generated data in the topic.
Process:
Again there are different ways to connect to Spark. I used Azure native data-bricks service to use spark streaming. You have full liberty to choose any cloud providers Databricks service or for demo purpose you can also use spark standalone cluster and can connect with Jupyter notebook to execute the program.
I am use Azure Databricks workspace to demo Spark Streaming.





