SlideShare a Scribd company logo
Distributed Data Systems 1©2016 LinkedIn Corporation. All Rights Reserved.
Introduction to Kafka Cruise Control
Jiangjie (Becket) Qin
Efe Gencer
Distributed Data Systems 2©2016 LinkedIn Corporation. All Rights Reserved.
Agenda
▪ The operation challenges for Kafka
▪ What is Kafka Cruise Control?
▪ Complexity of dynamic workload balancing
▪ Goals for workload balancing
▪ System design and architecture
▪ Q&A
Distributed Data Systems 3©2016 LinkedIn Corporation. All Rights Reserved.
Agenda
▪ The operation challenges for Kafka
▪ What is Kafka Cruise Control?
▪ Complexity of dynamic workload balancing
▪ Goals for workload balancing
▪ System design and architecture
▪ Q&A
Distributed Data Systems 4©2016 LinkedIn Corporation. All Rights Reserved.
The operation challenges for Kafka
▪ The scale of Kafka’s deployment @ LinkedIn
– ~1,800 brokers
– ~80,000 Topics
– > 1.3 Trillion messages / day
Distributed Data Systems 5©2016 LinkedIn Corporation. All Rights Reserved.
The operation challenges for Kafka
▪ Almost everyday
– Broker dies
– new topics creation
– Partition reassignment to balance the workload
▪ Huge operation load
Distributed Data Systems 6©2016 LinkedIn Corporation. All Rights Reserved.
Agenda
▪ The operation challenges for Kafka
▪ What is Kafka Cruise Control?
▪ Complexity of dynamic workload balancing
▪ Goals for workload balancing
▪ System design and architecture
▪ Q&A
Distributed Data Systems 7©2016 LinkedIn Corporation. All Rights Reserved.
What is Kafka Cruise Control
▪ Dynamic workload balancing for resources
– CPU
– Disk Utilization
– Network Inbound
– Network Outbound
▪A predecessor (kafka-assigner) with only disk balancing
–https://github.com/linkedin/kafka-tools
Distributed Data Systems 8©2016 LinkedIn Corporation. All Rights Reserved.
What is Kafka Cruise Control
▪ Failure detection and self-healing
– Reassign the replicas on the dead brokers
– Reduce the window of under replication
▪ Add / decommission a broker
Distributed Data Systems 9©2016 LinkedIn Corporation. All Rights Reserved.
Agenda
▪ The operation challenges for Kafka
▪ What is Kafka Cruise Control?
▪ Complexity of dynamic workload balancing
▪ Goals for workload balancing
▪ System design and architecture
▪ Q&A
Distributed Data Systems 10©2016 LinkedIn Corporation. All Rights Reserved.
Complexity of Dynamic Workload Balancing
▪ Consider a Kafka cluster with
– 2000 Topics
– 16,000 partitions
– 32,000 replicas (assume RF=2)
Distributed Data Systems 11©2016 LinkedIn Corporation. All Rights Reserved.
Complexity of Dynamic Workload Balancing
▪ Each replica has various workload profile
– CPU (Leader > Follower)
– Disk utilization (Leader = Follower)
– Network Inbound (Leader = Follower)
– Network Outbound (Follower = 0)
Leader
Follower
Decompression
Re-compression (Optional)
Append
ConsumerProducer
Distributed Data Systems 12©2016 LinkedIn Corporation. All Rights Reserved.
Complexity of Dynamic Workload Balancing
▪ Multiple values should be analyzed for each metric
– traffic patterns vary
– A long enough observation period is necessary
t
Throughput
Distributed Data Systems 13©2016 LinkedIn Corporation. All Rights Reserved.
▪ Some more things to consider
– Even distribution of all partitions among the brokers
– Rack awareness
– The load of each broker after one of the brokers failed
Complexity of Dynamic Workload Balancing
Distributed Data Systems 14©2016 LinkedIn Corporation. All Rights Reserved.
Complexity of Dynamic Workload Balancing
▪ Partition reassignment is tricky
– Should not affect the normal traffic (KIP-73)
– May need to be interrupted
▪ e.g. A failed broker recovered
Distributed Data Systems 15©2016 LinkedIn Corporation. All Rights Reserved.
▪ Large number of replicas
▪ Workload on multiple resources
▪ Additional restrictions
▪ Two ways to balance
– Leadership movement (cheap)
– Replica movement (expensive)
Complexity of Dynamic Workload Balancing
Distributed Data Systems 16©2016 LinkedIn Corporation. All Rights Reserved.
Agenda
▪ The operation challenges for Kafka
▪ What is Kafka Cruise Control?
▪ Complexity of dynamic workload balancing
▪ Goals for workload balancing
▪ System design and architecture
▪ Q&A
Distributed Data Systems 17©2016 LinkedIn Corporation. All Rights Reserved.
Goals of workload balancing
1. Rack Awareness Goal (Hard Goal)
– The replicas of the same partition has to be in different
racks
Rack0
p0r0
p1r1
Rack1
p0r1
p2r0
Rack2
p1r0
p2r1
Distributed Data Systems 18©2016 LinkedIn Corporation. All Rights Reserved.
Goals of workload balancing
2. Resource Utilization Threshold Goal (Hard Goal)
– The utilization of each resource on a broker has to be
below a defined threshold
Distributed Data Systems 19©2016 LinkedIn Corporation. All Rights Reserved.
Goals of workload balancing
3. Resource Utilization During Failure Goal (Soft Goal)
– Utilization of each resource on a broker cannot exceed
the broker’s capacity when there are broker failures.
Distributed Data Systems 20©2016 LinkedIn Corporation. All Rights Reserved.
Goals of workload balancing
4. Resource Utilization Balance Goal (Soft Goal)
– The utilization of each resource of a broker should not
differ for more than X% of the average utilization.
Distributed Data Systems 21©2016 LinkedIn Corporation. All Rights Reserved.
Goals of workload balancing
5. Topic Partition Distribution Goal (Soft Goal)
– The partitions of each topic should be distributed among
the brokers as evenly as possible
Rack0 Rack1
Broker0 Broker1 Broker2
T0_P0_R1 T0_P1_R0 T0_P0_R0
Rack2
Broker3
T0_P1_R1
Distributed Data Systems 22©2016 LinkedIn Corporation. All Rights Reserved.
Goals of workload balancing
6. Global Partition Distribution Goal (Soft Goal)
– Partitions of all the topics in the Kafka cluster should be
distributed among the brokers as evenly as possible
Rack0 Rack1
Broker0 Broker1 Broker2
T0_P0_R1 T0_P1_R0 T0_P0_R0
Rack2
Broker3
T0_P1_R1
T1_P0_R0 T1_P1_R1 T1_P0_R1 T1_P1_R0
Distributed Data Systems 23©2016 LinkedIn Corporation. All Rights Reserved.
Goals of workload balancing
▪ Each goal has a priority
– Represented by a unique integer
– Determines the satisfying order
Distributed Data Systems 24©2016 LinkedIn Corporation. All Rights Reserved.
Agenda
▪ The operation challenges for Kafka
▪ What is Kafka Cruise Control?
▪ Complexity of dynamic workload balancing
▪ Goals for workload balancing
▪ System design and architecture
▪ Q&A
Distributed Data Systems 25©2016 LinkedIn Corporation. All Rights Reserved.
Kafka Cruise Control
Architecture of Kafka Cruise Control
Workload Monitor
Executor
Kafka
Cluster
Failure Detector
User
Analyzer
Metric Sampler
REST
API
Goal0
Goal1
…
Distributed Data Systems 26©2016 LinkedIn Corporation. All Rights Reserved.
REST API
./rebalance_cluster [balance_percentage]
./add_brokers <broker-info>
./decommission_brokers <broker-info>
./assignment_history [option]
./restore_assignment [option]
./cancel_all
./list_assignment [option]
Distributed Data Systems 27©2016 LinkedIn Corporation. All Rights Reserved.
Many Interesting Challenges
▪ Trustworthy Workload Modeling (Workload Monitor)
▪ Fast Optimization Resolution (Analyzer)
▪ False Alarm in Failure (Failure Detector)
▪ Controlled Balancing Execution (Executor)
▪ And so on…
Distributed Data Systems 28©2016 LinkedIn Corporation. All Rights Reserved.
Trustworthy Workload Modeling
▪ Garbage in, garbage out
▪ A good workload model is critical
– Robust workload sampling
▪ Workload sampling may fail intermittently
– Only take action when we are confident
Distributed Data Systems 29©2016 LinkedIn Corporation. All Rights Reserved.
Robust Workload Sampling
▪ Replica workload model (Workload Sample)
– CPU Utilization: Derived from total CPU usage
▪(Partition_Bytes_In / Total_Bytes_In) * CPU_UTIL
– Disk Utilization: Partition size (latest size)
– Network Inbound: Kafka metrics
– Network Outbound: Kafka metrics
▪ Followers’ loads are derived from leaders’ loads
Distributed Data Systems 30©2016 LinkedIn Corporation. All Rights Reserved.
Robust Workload Sampling
▪ Workload Monitor
– Periodically sample the Kafka cluster
▪ E.g. Every 5 min.
▪ Many metrics if the cluster is big
–Multiple customizable metric samplers
▪Parallel metric sampling
– Each Workload Sample is for one partition
Distributed Data Systems 31©2016 LinkedIn Corporation. All Rights Reserved.
▪ Workload Snapshot
– Represents the average workload in a defined window
– Keep most recent N snapshots for each partition
– Multiple workload samples in each workload snapshot
– Insufficient samples leads to invalid Workload Snapshots
▪ E.g. 4 samples per snapshot window, at least 3 samples required
Only take confident action
Snapshot 0 Snapshot 1 Snapshot 2
S0 S1 S2 S3 S0 S1 S2 S3 S0 S1 S2 S3
Distributed Data Systems 32©2016 LinkedIn Corporation. All Rights Reserved.
Only take confident action
▪ Never take action when we are not confident
– Exclude a partition without enough valid snapshots
– Exclude a topic if one of its partitions is excluded
– Stop the analysis if too many topics are excluded
▪ E.g. < 98% topics are included
Distributed Data Systems 33©2016 LinkedIn Corporation. All Rights Reserved.
Many Interesting Challenges
▪ Trustworthy Workload Modeling (Workload Monitor)
▪ Fast Optimization Resolution (Analyzer)
▪ False Alarm in Failure (Failure Detector)
▪ Controlled Balancing Execution (Executor)
▪ And so on…
Distributed Data Systems 34©2016 LinkedIn Corporation. All Rights Reserved.
Fast Optimization Resolution
▪ A reminder: dynamic workload balancing is not easy
– Tens of thousands of replicas
– Multiple resources (CPU, DISK, Network)
– 6 Goals
▪ We need to get a solution quickly
– Otherwise the workload model may be outdated
Distributed Data Systems 35©2016 LinkedIn Corporation. All Rights Reserved.
An attempt of using Microsoft Z3
▪ Microsoft z3
– An open source theorem prover (optimizer)
▪ https://github.com/Z3Prover/z3
– Optimization by minimize a set of cost functions
▪ In our case it is a bunch of first order formula.
Distributed Data Systems 36©2016 LinkedIn Corporation. All Rights Reserved.
An attempt of using Microsoft Z3
▪ Microsoft z3
– An open source theorem prover (optimizer)
▪ https://github.com/Z3Prover/z3
– Optimization by minimize a set of cost functions
▪ In our case it is a bunch of first order formula.
▪ It takes a couple of weeks to get a solution assuming
everything goes perfectly well
Distributed Data Systems 37©2016 LinkedIn Corporation. All Rights Reserved.
Heuristic Analyzer
▪ Simple procedure
Move a partition to other brokers
Get an unchecked broker
Y
Y
Have unchecked
broker?
Can move a
partition to other
brokers?
Y
N
N
Done
Failed
N
Start
All goals met?
Hard
goal?
Y
N N
Distributed Data Systems 38©2016 LinkedIn Corporation. All Rights Reserved.
Heuristic Analyzer
▪ From weeks to lower seconds
– Not globally optimal solution
– But good enough
▪ Pluggable goals
– Each goal implements an interface
– Easy to add new goals
Distributed Data Systems 39©2016 LinkedIn Corporation. All Rights Reserved.
Many Interesting Challenges
▪ Trustworthy Workload Modeling (Workload Monitor)
▪ Fast Optimization Resolution (Analyzer)
▪ False Alarm in Failure (Failure Detector)
▪ Controlled Balancing Execution (Executor)
▪ And so on…
Distributed Data Systems 40©2016 LinkedIn Corporation. All Rights Reserved.
Avoid false alarm in failure detection
▪ Broker may appear to be failed in a few cases
– Rolling bounce
– Machine reboot
– Hard kill testing
▪ Heal a cluster is expensive
– Data movement
Distributed Data Systems 41©2016 LinkedIn Corporation. All Rights Reserved.
Avoid false alarm in failure detection
▪ Trade off between detection time and false alarm
– A grace period for a broker to come back
▪ E.g. 30 min.
– Asking for human intervention
▪ E.g. a broker will be back with a reboot.
Distributed Data Systems 42©2016 LinkedIn Corporation. All Rights Reserved.
Many Interesting Challenges
▪ Trustworthy Workload Modeling
▪ Fast Optimization Resolution
▪ False Alarm in Failure
▪ Controlled Balancing Execution
▪ And so on…
Distributed Data Systems 43©2016 LinkedIn Corporation. All Rights Reserved.
Controlled Balancing Execution
▪ Leader movement is cheap
▪ Partition reassignment is expensive
– A long lasting job
– Data movements
– Difficult to interrupt
▪ When and how to interrupt
Distributed Data Systems 44©2016 LinkedIn Corporation. All Rights Reserved.
Controlled Balancing Execution
▪ KIP-73
– replication quotas to throttle the replication traffic during
partition reassignment
– Avoid impact on normal traffic
▪ Executor in Kafka Cruise Control
– Batched replica reassignment
– Allow easy and safe interruption between batches
Distributed Data Systems 45©2016 LinkedIn Corporation. All Rights Reserved.
Future Works
▪ Integration with cloud infrastructure
– E.g. RAIN, Kubernetes
▪ GUI for Cruise Control
▪ Time machine for partition assignments
– Allows restoring a previous partition assignment
▪ Optimize performance and reduce overheads
Distributed Data Systems 46©2016 LinkedIn Corporation. All Rights Reserved.
Acknowledgements
Aditya Auradkar
Dong Lin
Joel Koshy
Kartik Paramasivam
Kafka team@LinkedIn
Distributed Data Systems 47©2016 LinkedIn Corporation. All Rights Reserved.
Q&A

More Related Content

PPTX
Kafka Tutorial: Advanced Producers
PPTX
Envoy and Kafka
PPTX
Kafka connect 101
PDF
ksqlDB: A Stream-Relational Database System
PDF
Producer Performance Tuning for Apache Kafka
PPTX
Apache Kafka 0.8 basic training - Verisign
PDF
An Introduction to Apache Kafka
PDF
Uber: Kafka Consumer Proxy
Kafka Tutorial: Advanced Producers
Envoy and Kafka
Kafka connect 101
ksqlDB: A Stream-Relational Database System
Producer Performance Tuning for Apache Kafka
Apache Kafka 0.8 basic training - Verisign
An Introduction to Apache Kafka
Uber: Kafka Consumer Proxy

What's hot (20)

PDF
A Deep Dive into Kafka Controller
PDF
Cruise Control: Effortless management of Kafka clusters
PDF
Container Performance Analysis
PPTX
Apache Kafka Best Practices
PDF
Apache kafka 모니터링을 위한 Metrics 이해 및 최적화 방안
PDF
Fundamentals of Apache Kafka
PPTX
Kafka 101
PPTX
Exactly-Once Financial Data Processing at Scale with Flink and Pinot
PPTX
Prometheus - Intro, CNCF, TSDB,PromQL,Grafana
PPTX
A visual introduction to Apache Kafka
PDF
Kafka Streams: What it is, and how to use it?
PDF
[NDC 2018] Spark, Flintrock, Airflow 로 구현하는 탄력적이고 유연한 데이터 분산처리 자동화 인프라 구축
PDF
Kafka Streams State Stores Being Persistent
PDF
Optimizing Kubernetes Resource Requests/Limits for Cost-Efficiency and Latenc...
PDF
Kernel Recipes 2017: Using Linux perf at Netflix
PDF
Linux Performance Analysis: New Tools and Old Secrets
PPTX
Evening out the uneven: dealing with skew in Flink
PDF
[NDC18] 야생의 땅 듀랑고의 데이터 엔지니어링 이야기: 로그 시스템 구축 경험 공유
PDF
Show Me Kafka Tools That Will Increase My Productivity! (Stephane Maarek, Dat...
PDF
BPF: Tracing and more
A Deep Dive into Kafka Controller
Cruise Control: Effortless management of Kafka clusters
Container Performance Analysis
Apache Kafka Best Practices
Apache kafka 모니터링을 위한 Metrics 이해 및 최적화 방안
Fundamentals of Apache Kafka
Kafka 101
Exactly-Once Financial Data Processing at Scale with Flink and Pinot
Prometheus - Intro, CNCF, TSDB,PromQL,Grafana
A visual introduction to Apache Kafka
Kafka Streams: What it is, and how to use it?
[NDC 2018] Spark, Flintrock, Airflow 로 구현하는 탄력적이고 유연한 데이터 분산처리 자동화 인프라 구축
Kafka Streams State Stores Being Persistent
Optimizing Kubernetes Resource Requests/Limits for Cost-Efficiency and Latenc...
Kernel Recipes 2017: Using Linux perf at Netflix
Linux Performance Analysis: New Tools and Old Secrets
Evening out the uneven: dealing with skew in Flink
[NDC18] 야생의 땅 듀랑고의 데이터 엔지니어링 이야기: 로그 시스템 구축 경험 공유
Show Me Kafka Tools That Will Increase My Productivity! (Stephane Maarek, Dat...
BPF: Tracing and more
Ad

Similar to Introduction to Kafka Cruise Control (20)

PDF
Data stream with cruise control
PPTX
Putting Kafka Into Overdrive
PDF
Auto load rebalancing with Cruise Control
PPTX
Curing the Kafka Blindness
PPTX
A load balancing model based on cloud partitioning for the public cloud. ppt
PPTX
Architecting for Massive Scalability - St. Louis Day of .NET 2011 - Aug 6, 2011
PDF
Netflix Keystone Pipeline at Big Data Bootcamp, Santa Clara, Nov 2015
PPTX
Взгляд на облака с точки зрения HPC
PDF
A Survey on Task Scheduling and Load Balanced Algorithms in Cloud Computing
PDF
Self-adaptive container monitoring with performance-aware Load-Shedding policies
PDF
Hard Truths About Streaming and Eventing (Dan Rosanova, Microsoft) Kafka Summ...
PDF
Let’s Make Your CFO Happy; A Practical Guide for Kafka Cost Reduction with El...
PDF
YOW! Data Keynote (2021)
PDF
Kafka used at scale to deliver real-time notifications
PDF
Capital One Delivers Risk Insights in Real Time with Stream Processing
PDF
Dynamic Cloud Partitioning and Load Balancing in Cloud
PDF
Hybrid Scheduling Algorithm for Efficient Load Balancing In Cloud Computing
PPTX
Cloud computing
PDF
Learnings From Shipping 1000+ Streaming Data Pipelines To Production with Hak...
PDF
The Netflix Way to deal with Big Data Problems
Data stream with cruise control
Putting Kafka Into Overdrive
Auto load rebalancing with Cruise Control
Curing the Kafka Blindness
A load balancing model based on cloud partitioning for the public cloud. ppt
Architecting for Massive Scalability - St. Louis Day of .NET 2011 - Aug 6, 2011
Netflix Keystone Pipeline at Big Data Bootcamp, Santa Clara, Nov 2015
Взгляд на облака с точки зрения HPC
A Survey on Task Scheduling and Load Balanced Algorithms in Cloud Computing
Self-adaptive container monitoring with performance-aware Load-Shedding policies
Hard Truths About Streaming and Eventing (Dan Rosanova, Microsoft) Kafka Summ...
Let’s Make Your CFO Happy; A Practical Guide for Kafka Cost Reduction with El...
YOW! Data Keynote (2021)
Kafka used at scale to deliver real-time notifications
Capital One Delivers Risk Insights in Real Time with Stream Processing
Dynamic Cloud Partitioning and Load Balancing in Cloud
Hybrid Scheduling Algorithm for Efficient Load Balancing In Cloud Computing
Cloud computing
Learnings From Shipping 1000+ Streaming Data Pipelines To Production with Hak...
The Netflix Way to deal with Big Data Problems
Ad

Recently uploaded (20)

PDF
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
PPTX
Fundamentals of safety and accident prevention -final (1).pptx
PPTX
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
PPTX
Internet of Things (IOT) - A guide to understanding
PPTX
Construction Project Organization Group 2.pptx
PDF
PPT on Performance Review to get promotions
PDF
Unit I ESSENTIAL OF DIGITAL MARKETING.pdf
PDF
A SYSTEMATIC REVIEW OF APPLICATIONS IN FRAUD DETECTION
PDF
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf
PPTX
Sustainable Sites - Green Building Construction
PPTX
UNIT 4 Total Quality Management .pptx
PDF
R24 SURVEYING LAB MANUAL for civil enggi
PDF
Automation-in-Manufacturing-Chapter-Introduction.pdf
PPTX
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
PPTX
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
PPT
Total quality management ppt for engineering students
PPTX
Foundation to blockchain - A guide to Blockchain Tech
DOCX
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
PPTX
UNIT-1 - COAL BASED THERMAL POWER PLANTS
PPTX
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
Fundamentals of safety and accident prevention -final (1).pptx
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
Internet of Things (IOT) - A guide to understanding
Construction Project Organization Group 2.pptx
PPT on Performance Review to get promotions
Unit I ESSENTIAL OF DIGITAL MARKETING.pdf
A SYSTEMATIC REVIEW OF APPLICATIONS IN FRAUD DETECTION
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf
Sustainable Sites - Green Building Construction
UNIT 4 Total Quality Management .pptx
R24 SURVEYING LAB MANUAL for civil enggi
Automation-in-Manufacturing-Chapter-Introduction.pdf
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
Total quality management ppt for engineering students
Foundation to blockchain - A guide to Blockchain Tech
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
UNIT-1 - COAL BASED THERMAL POWER PLANTS
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx

Introduction to Kafka Cruise Control

  • 1. Distributed Data Systems 1©2016 LinkedIn Corporation. All Rights Reserved. Introduction to Kafka Cruise Control Jiangjie (Becket) Qin Efe Gencer
  • 2. Distributed Data Systems 2©2016 LinkedIn Corporation. All Rights Reserved. Agenda ▪ The operation challenges for Kafka ▪ What is Kafka Cruise Control? ▪ Complexity of dynamic workload balancing ▪ Goals for workload balancing ▪ System design and architecture ▪ Q&A
  • 3. Distributed Data Systems 3©2016 LinkedIn Corporation. All Rights Reserved. Agenda ▪ The operation challenges for Kafka ▪ What is Kafka Cruise Control? ▪ Complexity of dynamic workload balancing ▪ Goals for workload balancing ▪ System design and architecture ▪ Q&A
  • 4. Distributed Data Systems 4©2016 LinkedIn Corporation. All Rights Reserved. The operation challenges for Kafka ▪ The scale of Kafka’s deployment @ LinkedIn – ~1,800 brokers – ~80,000 Topics – > 1.3 Trillion messages / day
  • 5. Distributed Data Systems 5©2016 LinkedIn Corporation. All Rights Reserved. The operation challenges for Kafka ▪ Almost everyday – Broker dies – new topics creation – Partition reassignment to balance the workload ▪ Huge operation load
  • 6. Distributed Data Systems 6©2016 LinkedIn Corporation. All Rights Reserved. Agenda ▪ The operation challenges for Kafka ▪ What is Kafka Cruise Control? ▪ Complexity of dynamic workload balancing ▪ Goals for workload balancing ▪ System design and architecture ▪ Q&A
  • 7. Distributed Data Systems 7©2016 LinkedIn Corporation. All Rights Reserved. What is Kafka Cruise Control ▪ Dynamic workload balancing for resources – CPU – Disk Utilization – Network Inbound – Network Outbound ▪A predecessor (kafka-assigner) with only disk balancing –https://github.com/linkedin/kafka-tools
  • 8. Distributed Data Systems 8©2016 LinkedIn Corporation. All Rights Reserved. What is Kafka Cruise Control ▪ Failure detection and self-healing – Reassign the replicas on the dead brokers – Reduce the window of under replication ▪ Add / decommission a broker
  • 9. Distributed Data Systems 9©2016 LinkedIn Corporation. All Rights Reserved. Agenda ▪ The operation challenges for Kafka ▪ What is Kafka Cruise Control? ▪ Complexity of dynamic workload balancing ▪ Goals for workload balancing ▪ System design and architecture ▪ Q&A
  • 10. Distributed Data Systems 10©2016 LinkedIn Corporation. All Rights Reserved. Complexity of Dynamic Workload Balancing ▪ Consider a Kafka cluster with – 2000 Topics – 16,000 partitions – 32,000 replicas (assume RF=2)
  • 11. Distributed Data Systems 11©2016 LinkedIn Corporation. All Rights Reserved. Complexity of Dynamic Workload Balancing ▪ Each replica has various workload profile – CPU (Leader > Follower) – Disk utilization (Leader = Follower) – Network Inbound (Leader = Follower) – Network Outbound (Follower = 0) Leader Follower Decompression Re-compression (Optional) Append ConsumerProducer
  • 12. Distributed Data Systems 12©2016 LinkedIn Corporation. All Rights Reserved. Complexity of Dynamic Workload Balancing ▪ Multiple values should be analyzed for each metric – traffic patterns vary – A long enough observation period is necessary t Throughput
  • 13. Distributed Data Systems 13©2016 LinkedIn Corporation. All Rights Reserved. ▪ Some more things to consider – Even distribution of all partitions among the brokers – Rack awareness – The load of each broker after one of the brokers failed Complexity of Dynamic Workload Balancing
  • 14. Distributed Data Systems 14©2016 LinkedIn Corporation. All Rights Reserved. Complexity of Dynamic Workload Balancing ▪ Partition reassignment is tricky – Should not affect the normal traffic (KIP-73) – May need to be interrupted ▪ e.g. A failed broker recovered
  • 15. Distributed Data Systems 15©2016 LinkedIn Corporation. All Rights Reserved. ▪ Large number of replicas ▪ Workload on multiple resources ▪ Additional restrictions ▪ Two ways to balance – Leadership movement (cheap) – Replica movement (expensive) Complexity of Dynamic Workload Balancing
  • 16. Distributed Data Systems 16©2016 LinkedIn Corporation. All Rights Reserved. Agenda ▪ The operation challenges for Kafka ▪ What is Kafka Cruise Control? ▪ Complexity of dynamic workload balancing ▪ Goals for workload balancing ▪ System design and architecture ▪ Q&A
  • 17. Distributed Data Systems 17©2016 LinkedIn Corporation. All Rights Reserved. Goals of workload balancing 1. Rack Awareness Goal (Hard Goal) – The replicas of the same partition has to be in different racks Rack0 p0r0 p1r1 Rack1 p0r1 p2r0 Rack2 p1r0 p2r1
  • 18. Distributed Data Systems 18©2016 LinkedIn Corporation. All Rights Reserved. Goals of workload balancing 2. Resource Utilization Threshold Goal (Hard Goal) – The utilization of each resource on a broker has to be below a defined threshold
  • 19. Distributed Data Systems 19©2016 LinkedIn Corporation. All Rights Reserved. Goals of workload balancing 3. Resource Utilization During Failure Goal (Soft Goal) – Utilization of each resource on a broker cannot exceed the broker’s capacity when there are broker failures.
  • 20. Distributed Data Systems 20©2016 LinkedIn Corporation. All Rights Reserved. Goals of workload balancing 4. Resource Utilization Balance Goal (Soft Goal) – The utilization of each resource of a broker should not differ for more than X% of the average utilization.
  • 21. Distributed Data Systems 21©2016 LinkedIn Corporation. All Rights Reserved. Goals of workload balancing 5. Topic Partition Distribution Goal (Soft Goal) – The partitions of each topic should be distributed among the brokers as evenly as possible Rack0 Rack1 Broker0 Broker1 Broker2 T0_P0_R1 T0_P1_R0 T0_P0_R0 Rack2 Broker3 T0_P1_R1
  • 22. Distributed Data Systems 22©2016 LinkedIn Corporation. All Rights Reserved. Goals of workload balancing 6. Global Partition Distribution Goal (Soft Goal) – Partitions of all the topics in the Kafka cluster should be distributed among the brokers as evenly as possible Rack0 Rack1 Broker0 Broker1 Broker2 T0_P0_R1 T0_P1_R0 T0_P0_R0 Rack2 Broker3 T0_P1_R1 T1_P0_R0 T1_P1_R1 T1_P0_R1 T1_P1_R0
  • 23. Distributed Data Systems 23©2016 LinkedIn Corporation. All Rights Reserved. Goals of workload balancing ▪ Each goal has a priority – Represented by a unique integer – Determines the satisfying order
  • 24. Distributed Data Systems 24©2016 LinkedIn Corporation. All Rights Reserved. Agenda ▪ The operation challenges for Kafka ▪ What is Kafka Cruise Control? ▪ Complexity of dynamic workload balancing ▪ Goals for workload balancing ▪ System design and architecture ▪ Q&A
  • 25. Distributed Data Systems 25©2016 LinkedIn Corporation. All Rights Reserved. Kafka Cruise Control Architecture of Kafka Cruise Control Workload Monitor Executor Kafka Cluster Failure Detector User Analyzer Metric Sampler REST API Goal0 Goal1 …
  • 26. Distributed Data Systems 26©2016 LinkedIn Corporation. All Rights Reserved. REST API ./rebalance_cluster [balance_percentage] ./add_brokers <broker-info> ./decommission_brokers <broker-info> ./assignment_history [option] ./restore_assignment [option] ./cancel_all ./list_assignment [option]
  • 27. Distributed Data Systems 27©2016 LinkedIn Corporation. All Rights Reserved. Many Interesting Challenges ▪ Trustworthy Workload Modeling (Workload Monitor) ▪ Fast Optimization Resolution (Analyzer) ▪ False Alarm in Failure (Failure Detector) ▪ Controlled Balancing Execution (Executor) ▪ And so on…
  • 28. Distributed Data Systems 28©2016 LinkedIn Corporation. All Rights Reserved. Trustworthy Workload Modeling ▪ Garbage in, garbage out ▪ A good workload model is critical – Robust workload sampling ▪ Workload sampling may fail intermittently – Only take action when we are confident
  • 29. Distributed Data Systems 29©2016 LinkedIn Corporation. All Rights Reserved. Robust Workload Sampling ▪ Replica workload model (Workload Sample) – CPU Utilization: Derived from total CPU usage ▪(Partition_Bytes_In / Total_Bytes_In) * CPU_UTIL – Disk Utilization: Partition size (latest size) – Network Inbound: Kafka metrics – Network Outbound: Kafka metrics ▪ Followers’ loads are derived from leaders’ loads
  • 30. Distributed Data Systems 30©2016 LinkedIn Corporation. All Rights Reserved. Robust Workload Sampling ▪ Workload Monitor – Periodically sample the Kafka cluster ▪ E.g. Every 5 min. ▪ Many metrics if the cluster is big –Multiple customizable metric samplers ▪Parallel metric sampling – Each Workload Sample is for one partition
  • 31. Distributed Data Systems 31©2016 LinkedIn Corporation. All Rights Reserved. ▪ Workload Snapshot – Represents the average workload in a defined window – Keep most recent N snapshots for each partition – Multiple workload samples in each workload snapshot – Insufficient samples leads to invalid Workload Snapshots ▪ E.g. 4 samples per snapshot window, at least 3 samples required Only take confident action Snapshot 0 Snapshot 1 Snapshot 2 S0 S1 S2 S3 S0 S1 S2 S3 S0 S1 S2 S3
  • 32. Distributed Data Systems 32©2016 LinkedIn Corporation. All Rights Reserved. Only take confident action ▪ Never take action when we are not confident – Exclude a partition without enough valid snapshots – Exclude a topic if one of its partitions is excluded – Stop the analysis if too many topics are excluded ▪ E.g. < 98% topics are included
  • 33. Distributed Data Systems 33©2016 LinkedIn Corporation. All Rights Reserved. Many Interesting Challenges ▪ Trustworthy Workload Modeling (Workload Monitor) ▪ Fast Optimization Resolution (Analyzer) ▪ False Alarm in Failure (Failure Detector) ▪ Controlled Balancing Execution (Executor) ▪ And so on…
  • 34. Distributed Data Systems 34©2016 LinkedIn Corporation. All Rights Reserved. Fast Optimization Resolution ▪ A reminder: dynamic workload balancing is not easy – Tens of thousands of replicas – Multiple resources (CPU, DISK, Network) – 6 Goals ▪ We need to get a solution quickly – Otherwise the workload model may be outdated
  • 35. Distributed Data Systems 35©2016 LinkedIn Corporation. All Rights Reserved. An attempt of using Microsoft Z3 ▪ Microsoft z3 – An open source theorem prover (optimizer) ▪ https://github.com/Z3Prover/z3 – Optimization by minimize a set of cost functions ▪ In our case it is a bunch of first order formula.
  • 36. Distributed Data Systems 36©2016 LinkedIn Corporation. All Rights Reserved. An attempt of using Microsoft Z3 ▪ Microsoft z3 – An open source theorem prover (optimizer) ▪ https://github.com/Z3Prover/z3 – Optimization by minimize a set of cost functions ▪ In our case it is a bunch of first order formula. ▪ It takes a couple of weeks to get a solution assuming everything goes perfectly well
  • 37. Distributed Data Systems 37©2016 LinkedIn Corporation. All Rights Reserved. Heuristic Analyzer ▪ Simple procedure Move a partition to other brokers Get an unchecked broker Y Y Have unchecked broker? Can move a partition to other brokers? Y N N Done Failed N Start All goals met? Hard goal? Y N N
  • 38. Distributed Data Systems 38©2016 LinkedIn Corporation. All Rights Reserved. Heuristic Analyzer ▪ From weeks to lower seconds – Not globally optimal solution – But good enough ▪ Pluggable goals – Each goal implements an interface – Easy to add new goals
  • 39. Distributed Data Systems 39©2016 LinkedIn Corporation. All Rights Reserved. Many Interesting Challenges ▪ Trustworthy Workload Modeling (Workload Monitor) ▪ Fast Optimization Resolution (Analyzer) ▪ False Alarm in Failure (Failure Detector) ▪ Controlled Balancing Execution (Executor) ▪ And so on…
  • 40. Distributed Data Systems 40©2016 LinkedIn Corporation. All Rights Reserved. Avoid false alarm in failure detection ▪ Broker may appear to be failed in a few cases – Rolling bounce – Machine reboot – Hard kill testing ▪ Heal a cluster is expensive – Data movement
  • 41. Distributed Data Systems 41©2016 LinkedIn Corporation. All Rights Reserved. Avoid false alarm in failure detection ▪ Trade off between detection time and false alarm – A grace period for a broker to come back ▪ E.g. 30 min. – Asking for human intervention ▪ E.g. a broker will be back with a reboot.
  • 42. Distributed Data Systems 42©2016 LinkedIn Corporation. All Rights Reserved. Many Interesting Challenges ▪ Trustworthy Workload Modeling ▪ Fast Optimization Resolution ▪ False Alarm in Failure ▪ Controlled Balancing Execution ▪ And so on…
  • 43. Distributed Data Systems 43©2016 LinkedIn Corporation. All Rights Reserved. Controlled Balancing Execution ▪ Leader movement is cheap ▪ Partition reassignment is expensive – A long lasting job – Data movements – Difficult to interrupt ▪ When and how to interrupt
  • 44. Distributed Data Systems 44©2016 LinkedIn Corporation. All Rights Reserved. Controlled Balancing Execution ▪ KIP-73 – replication quotas to throttle the replication traffic during partition reassignment – Avoid impact on normal traffic ▪ Executor in Kafka Cruise Control – Batched replica reassignment – Allow easy and safe interruption between batches
  • 45. Distributed Data Systems 45©2016 LinkedIn Corporation. All Rights Reserved. Future Works ▪ Integration with cloud infrastructure – E.g. RAIN, Kubernetes ▪ GUI for Cruise Control ▪ Time machine for partition assignments – Allows restoring a previous partition assignment ▪ Optimize performance and reduce overheads
  • 46. Distributed Data Systems 46©2016 LinkedIn Corporation. All Rights Reserved. Acknowledgements Aditya Auradkar Dong Lin Joel Koshy Kartik Paramasivam Kafka team@LinkedIn
  • 47. Distributed Data Systems 47©2016 LinkedIn Corporation. All Rights Reserved. Q&A