Auto-scaling in Kafka means automatically adjusting the number of Kafka brokers or partitions based on workload to maintain performance and resource efficiency.
Click to reveal answer
beginner
Name two common metrics used to trigger Kafka auto-scaling.
Common metrics include CPU usage of brokers and consumer lag (the delay in processing messages). These help decide when to add or remove resources.
Click to reveal answer
intermediate
Explain horizontal scaling vs vertical scaling in Kafka auto-scaling.
Horizontal scaling means adding or removing Kafka brokers (machines). Vertical scaling means increasing or decreasing resources (CPU, memory) on existing brokers.
Click to reveal answer
advanced
What is a common challenge when auto-scaling Kafka partitions?
Rebalancing partitions can cause temporary performance drops and data movement, so scaling partitions must be done carefully to avoid disruption.
Click to reveal answer
intermediate
How does Kubernetes help with Kafka auto-scaling?
Kubernetes can manage Kafka brokers as pods and use Horizontal Pod Autoscaler to add or remove broker pods based on resource usage or custom metrics.
Click to reveal answer
Which metric is commonly used to decide when to auto-scale Kafka brokers?
AMessage content
BDisk size
CCPU usage
DNumber of topics
✗ Incorrect
CPU usage is a key metric to determine if brokers are overloaded and need scaling.
What does horizontal scaling mean in Kafka auto-scaling?
AAdding more CPU to existing brokers
BReducing number of partitions
CIncreasing message size
DAdding more brokers to the cluster
✗ Incorrect
Horizontal scaling means adding or removing brokers (machines) in the Kafka cluster.
What is a risk when increasing Kafka partitions during auto-scaling?
AData loss
BTemporary performance drop due to rebalancing
CMessages get duplicated
DTopics get deleted
✗ Incorrect
Rebalancing partitions can cause temporary performance issues as data moves between brokers.
Which tool can help automate Kafka broker scaling in container environments?
AKubernetes Horizontal Pod Autoscaler
BDocker Compose
CAnsible
DTerraform
✗ Incorrect
Kubernetes Horizontal Pod Autoscaler can automatically scale Kafka broker pods based on metrics.
Consumer lag in Kafka is used to measure:
ADelay in consumers processing messages
BHow fast producers send messages
CNumber of brokers in the cluster
DSize of messages
✗ Incorrect
Consumer lag shows how far behind consumers are in processing messages, useful for scaling decisions.
Describe how auto-scaling works in Kafka and what metrics are important to monitor.
Think about how Kafka adjusts resources automatically based on workload.
You got /4 concepts.
Explain the difference between horizontal and vertical scaling in Kafka auto-scaling and why each might be used.
Consider adding machines vs upgrading existing machines.
You got /3 concepts.
Practice
(1/5)
1. What is the main purpose of auto-scaling in Kafka clusters?
easy
A. To backup data to external storage
B. To manually add brokers when needed
C. To automatically adjust resources based on workload changes
D. To encrypt messages for security
Solution
Step 1: Understand auto-scaling concept
Auto-scaling means adjusting resources automatically without manual intervention.
Step 2: Apply to Kafka context
Kafka auto-scaling adjusts brokers or partitions based on workload changes.
Final Answer:
To automatically adjust resources based on workload changes -> Option C
Quick Check:
Auto-scaling = automatic resource adjustment [OK]
Hint: Auto-scaling means automatic resource changes, not manual [OK]
Common Mistakes:
Confusing auto-scaling with manual scaling
Thinking auto-scaling is for data backup
Assuming auto-scaling handles security
2. Which of the following is a correct way to trigger auto-scaling in Kafka using metrics?
easy
A. Increase partition count without checking load
B. Manually restart brokers every hour
C. Disable monitoring to save resources
D. Monitor CPU usage and add brokers when usage exceeds threshold
Solution
Step 1: Identify correct auto-scaling trigger
Auto-scaling triggers on metrics like CPU usage crossing a threshold.
Step 2: Evaluate options
Only Monitor CPU usage and add brokers when usage exceeds threshold uses monitoring metrics to trigger scaling automatically.
Final Answer:
Monitor CPU usage and add brokers when usage exceeds threshold -> Option D
Quick Check:
Auto-scale triggers = metric thresholds [OK]
Hint: Auto-scaling triggers on metrics, not manual actions [OK]
Common Mistakes:
Confusing manual restarts with auto-scaling
Ignoring monitoring importance
Scaling without checking load
3. Given this pseudo-code for auto-scaling Kafka brokers:
if (cpu_usage > 80%) {
add_broker()
} else if (cpu_usage < 30%) {
remove_broker()
} else {
do_nothing()
}
What happens if CPU usage is 85%?
medium
A. A broker is added
B. No change in brokers
C. A broker is removed
D. Error occurs due to syntax
Solution
Step 1: Check CPU usage condition
CPU usage is 85%, which is greater than 80%.
Step 2: Determine action based on condition
Since cpu_usage > 80%, the code calls add_broker() to add a broker.
Final Answer:
A broker is added -> Option A
Quick Check:
CPU > 80% triggers add_broker() [OK]
Hint: CPU > 80% means add broker, CPU < 30% means remove [OK]
Common Mistakes:
Confusing add and remove actions
Ignoring else conditions
Assuming syntax error without cause
4. This auto-scaling script snippet has an error:
if cpu_usage > 70%:
add_broker()
elif cpu_usage < 20%:
remove_broker()
What is the error?
medium
A. Incorrect percentage symbol usage in condition
B. add_broker() function is undefined
C. Missing colon after if statement
D. No error, code is correct
Solution
Step 1: Analyze condition syntax
Using '%' directly in conditions like 'cpu_usage > 70%' is invalid syntax in most languages.
Step 2: Identify correct syntax
Percent values should be numeric (e.g., 0.7 or 70) without '%' symbol in code.
Final Answer:
Incorrect percentage symbol usage in condition -> Option A
Quick Check:
Conditions must use numbers, not '%' symbol [OK]
Hint: Don't use % symbol in code conditions, use numbers only [OK]
Common Mistakes:
Assuming missing colon is the error
Thinking functions are undefined without context
Believing code is correct as is
5. You want to auto-scale Kafka partitions based on message lag. Which strategy best fits this goal?
hard
A. Add brokers randomly without monitoring lag
B. Increase partitions when lag exceeds threshold; decrease when lag is low
C. Scale partitions only based on CPU usage
D. Manually change partitions daily regardless of lag
Solution
Step 1: Understand message lag as scaling metric
Message lag indicates how many messages are waiting to be processed, a key metric for scaling partitions.
Step 2: Choose strategy matching lag metric
Increasing partitions when lag is high and decreasing when low optimizes processing capacity.
Final Answer:
Increase partitions when lag exceeds threshold; decrease when lag is low -> Option B
Quick Check:
Lag-based scaling = adjust partitions by lag [OK]
Hint: Scale partitions based on lag, not random or CPU only [OK]
Common Mistakes:
Ignoring lag metric importance
Scaling without monitoring
Manual scaling instead of auto
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.