DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • Building Your Tech Career Like Code: A Systematic AI Approach
  • The Real-time Data Transfer Magic of Doris Kafka Connector's "Data Package": Part 1
  • The Evolution of Adaptive Frameworks
  • How to Design Event Streams, Part 1

Trending

  • Building a DevOps-Ready Internal Developer Platform: A Hands-On Guide to Golden Paths, Self-Service, and Automated Delivery Pipelines
  • Data Contracts as the "Circuit Breaker" for Model Reliability
  • Feature Flag Debt: Performance Impact in Enterprise Applications
  • When Snowflake Lies to You: Understanding False Failures in dbt Pipelines
  1. DZone
  2. Data Engineering
  3. Big Data
  4. Throttle Spark-Kafka Streaming Volume

Throttle Spark-Kafka Streaming Volume

Time to dive into the settings to configure your loads.

By 
Sudhish koloth user avatar
Sudhish koloth
·
Updated Dec. 21, 20 · Tutorial
Likes (4)
Comment
Save
Tweet
Share
8.9K Views

Join the DZone community and get the full member experience.

Join For Free

This article will help any new developer who wants to control the volume of Spark Kafka streaming.

A Spark streaming job internally uses a micro-batch processing technique to stream and process data. The initial state of the job will be in the "queued" status, then it will then move to the "processing" status, and then it is marked with the "completed" status.

Prerequisites

  • The developer should be familiar with Spark streaming
  • The developer should have some knowledge of Kafka and Spark.

Problem Statement

Apache Spark is often used for data streaming. One of the streaming stacks it is well aligned with is Kafka. Kafka, as we know, is a powerful distributed platform. There are instances where the Spark streaming job is up and running, and the sudden increase in data volume may cause some bottlenecks.

Though Spark is a great processing engine, given a multi-tenant cluster, and if your app is consuming a high volume of Kafka messages, then there is a high chance of messages getting stuck in the queued status.

Since volume is high and there are not enough resources, there are many jobs stuck in the queue. This problem is due to the fact that your job runs on some defined configuration; let's say it normally handles 2,000 TPS, but your app suddenly got an inflow of 15,000 TPS. 

This happens frequently — it can happen is when your Hadoop cluster is down for a prolonged duration, for example. Let's assume the job is down for four hours, and after it is up, when the job resumes, then a huge load of data piles up, and eventually your Spark job will not have enough resources to handle all that pending data at once.

Throttling Technique  

The throttling technique comes up in rescue to solve this problem. Using this technique you can control the volume of data that your spark streaming job can handle maximum at once. 

For Spark streaming Kafka, there is one key property that can be used to control the volume.

Python
 




x


 
1
spark.streaming.kafka.maxRatePerPartition 3000
2
#Configured while creating topic
3
spark.kafka.topic.partition 16



In the above properties, 'spark.streaming.Kafka.maxRatePerPartition'  plays a key role in throttling the messages. 

Above, we defined the throttling value as 3,000, and the actual partition for this topic is 16. Now the maximum it can process at one micro-batch is:

Plain Text
 




x


 
1
max = 16*2*3000



So, at max, 96K messages will be processed per micro-batch. 

This is one example — the actual settings will differ from job to job, and so will the max volume of data your job can process. Based on your executors and executor memory, you have to define the right configuration to throttle. 

Throttling is a key technique for your job stability. Determining the right settings and configuration will play a crucial role in the processing of a high volume of data. 

career kafka Data (computing)

Opinions expressed by DZone contributors are their own.

Related

  • Building Your Tech Career Like Code: A Systematic AI Approach
  • The Real-time Data Transfer Magic of Doris Kafka Connector's "Data Package": Part 1
  • The Evolution of Adaptive Frameworks
  • How to Design Event Streams, Part 1

Partner Resources

×

Comments

The likes didn't load as expected. Please refresh the page and try again.

  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook