SlideShare a Scribd company logo
1 of 89
From Message to
Cluster
A Realworld Introduction to Kafka Capacity Planning.
Jason “Jase” Bell - @jasonbelldata
https://digitalis.io
MeetupCat is my spirit animal.
Flight Mode is ON! You may……
• Heckle.
• Ask Questions.
• Heckle More.
• Talk about steak.
• Heckle again.
What I’m Going To
Cover
What I’m Going To
Cover
• The Old Days.
• The Now Times.
• The Stuff We Don’t Talk About
• The Message
• What I Usually Ask For
• Retention
• Estimated Capacity
• Compression
• Stress Testing
• Network and Disk Throughput
• Topic Partitions
• Kafka Connect
• KSQL
• Replicator
• Parting Thoughts…..
• ———————————————————
• Rapturous Applause
• Encore (Probably Eye of the Tiger……)
The Old Days
The Now Times
The Stuff We Don’t
Talk About
We think we know what
we need from our Kafka
Cluster
The Message
{
"text": "RT @PostGradProblem: In preparation for the NFL lockout, I will be spending twice as much time analyzing my fantasy baseball
team during ...",
"truncated": true,
"in_reply_to_user_id": null,
"in_reply_to_status_id": null,
"favorited": false,
"source": "<a href="http://twitter.com/" rel="nofollow">Twitter for iPhone</a>",
"in_reply_to_screen_name": null,
"in_reply_to_status_id_str": null,
"id_str": "54691802283900928",
"entities": {
"user_mentions": [
{
"indices": [
3,
19
],
"screen_name": "PostGradProblem",
"id_str": "271572434",
"name": "PostGradProblems",
"id": 271572434
}
],
"urls": [ ],
"hashtags": [ ]
},
"contributors": null,
"retweeted": false,
"in_reply_to_user_id_str": null,
"place": null,
"retweet_count": 4,
"created_at": "Sun Apr 03 23:48:36 +0000 2011",
"retweeted_status": {
"text": "In preparation for the NFL lockout, I will be spending twice as much time analyzing my fantasy baseball team during
company time. #PGP",
"truncated": false,
"in_reply_to_user_id": null,
"in_reply_to_status_id": null,
"favorited": false,
"source": "<a href="http://www.hootsuite.com" rel="nofollow">HootSuite</a>",
"in_reply_to_screen_name": null,
"in_reply_to_status_id_str": null,
"id_str": "54640519019642881",
"entities": {
"user_mentions": [ ],
"urls": [ ],
"hashtags": [
Twitter JSON Payload ~6kb
What I Usually Ask
For
•Average Message Size
What I’ll Ask Team For…
•Average Message Size
•Estimated Daily Quantity
What I’ll Ask Team For…
•Average Message Size
•Estimated Daily Quantity
•Any Peak Per Hour Quantity
What I’ll Ask Team For…
•Average Message Size
•Estimated Daily Quantity
•Any Peak Per Hour Quantity
•Desired Replication Factor
What I’ll Ask Team For…
•Average Message Size
•Estimated Daily Quantity
•Any Peak Per Hour Quantity
•Desired Replication Factor
•Desired Partitions
What I’ll Ask Team For…
•Average Message Size
•Estimated Daily Quantity
•Any Peak Per Hour Quantity
•Desired Replication Factor
•Desired Partitions
•Minimum In-sync Replicas
What I’ll Ask Team For…
•Average Message Size - (6 KB)
•Estimated Daily Quantity - (10,000,000/d)
•Any Peak Per Hour Quantity - (1,250,000)
•Desired Replication Factor - (4)
•Desired Partitions - (10)
•Minimum In-sync Replicas - (2)
What I’ll Ask Team For…
Estimated Capacity
Estimated Capacity
(Message size x 3) x Daily Qty
x 1.4 (add 40%)
= Volume per replicated broker.
Estimated Capacity
(6KB x 3) x 10,0000,000 = 184,320,000 KB
x 1.4 (add 40%)
= 258,048,000 KB
= 248.09 GB
Roughly translates to 2.940 MB/sec
Estimated Capacity
The x3 gives me a payload size with key,
header, timestamp and the value. It’s just a
rough calculation.
Estimated Capacity
The x3 gives me a payload size with key,
header, timestamp and the value. It’s just a
rough calculation.
Adding 40% overhead will give you some
breathing space when someone does a
stress test and doesn’t tell you…..
Retention
(6KB x 3) x 10,0000,000 = 184,320,000 KB
x 1.4 (add 40%)
= 258,048,000 KB
= 248.09 GB
248.09 GB/day x 14 days retention
= 3.4 TB per broker.
Estimated Capacity
df -hIs your friend…..
Estimated Capacity
du -H .Is also your friend…..
Compression
Producer configuration compression.type defaults to “none”.
Options are gzip, snappy, lz4 and zstd.
Expect ~20%-40% message compression depending on the algorithm used.
Stress Testing
kafka-producer-perf-test --topic TOPIC --record-size SIZE_IN_BYTES
$ bin/kafka-producer-perf-test --topic testtopic --record-size 1000 --num-
records 10000  --throughput 1000 --producer-props
bootstrap.servers=localhost:9092
5003 records sent, 1000.4 records/sec (0.95 MB/sec), 1.6 ms avg latency,
182.0 ms max latency.
10000 records sent, 998.801438 records/sec (0.95 MB/sec), 1.12 ms avg
latency, 182.00 ms max latency, 1 ms 50th, 2 ms 95th, 19 ms 99th, 23 ms
99.9th.
kafka-consumer-perf-test --broker-list host1:port1,host2:port2 --topic
TOPIC
Network and Disk
Throughput
• D - Data to be written (MB/sec)
• R - Replication Factor
• C - Number of Consumer Groups (readers for each write)
The Volume of Writes: (D * R)
The Volume of Reads within Replication: ((R-1) * D)
Reads happen internally by the replicas, this gives us:
The Volume of Reads within Replication: ((R - 1) * D)
Reads happen internally by the replicas, this gives us:
Adding the consumers we end up with:
The Volume of Reads within Replication: (((R + C) - 1) * D)
We have memory! We have Caching!
M/(D * R) = seconds of writes cached.
We have memory! We have Caching!
M/(D * R) = seconds of writes cached.
We have to assume that consumers might drop from the cache, consumers are running
slower than expected or even that replicas might restart due to failure, patching or
rolling restarts.
Lagging Readers L = R + C - 1
Disk Throughput: D * R + L * D
Network (reads) Throughput: ((R + C -1) * D)
Network (writes) Throughput: D * R
Topic Partitions
You can set partitions either creating
the topic (—partitions n) or afterwards.
Having a large number of partitions will have effects on Zookeeper znodes.
• More network requests
• If leader or broker goes down it may affect startup
time as the broker returns to the cluster.
If you need to reduce partitions create a new topic and reduce the partition count.
Kafka Connect
The latency trap…..
Think about second and third order
consequences if a connector would fail.
What is the impact?
The latency trap…..
KSQL
ksqlDB
•4 CPU Cores
•32GB RAM
•100GB SSD Disk
•1Gbit Network
Baseline Server Requirements
ksqlDB
•Partition Count of 4
•Replication Factor of 1
Default Outbound Topic Assumptions
(These settings can be modified within your CREATE query)
ksqlDB
Some queries will require repartitioning
and intermediate topics for certain
operations, taking all available records.
Default Outbound Topic Assumptions
ksqlDB
Processing Small Message/Many Columns
= CPU Saturation
Default Outbound Topic Assumptions
ksqlDB
Processing Large Message/Small Columns
= Network Saturation
Default Outbound Topic Assumptions
Replicator
Data Centre to Data Centre is going to lead to increased network latency.
On producers and consumers, use send.buffer.bytes and receive.buffer.bytes.
On brokers, use socket.send.buffer.bytes and socket.receive.buffer.bytes. 
Parting Thoughts
Consumer Group Lag Reports are your guiding light.
(If you have Rundeck setup a scheduled job to email
you the log output)
1
kafka-consumer-groups --bootstrap-server BROKER_ADDRESS --describe
—group CONSUMER_GROUP --new-consumer
Kafka is about trade offs, from the producer right the
way through to the consumer (and beyond).
There’s no right or wrong answer, just
experimentation, monitoring and learning.
2
While securing Kafka is important there is also a
cost as certificates are verified and take up CPU
resources.
Your throughput will be affected.
3
The Kafka Ecosystem has increased in features over
the last few years. This has lead to increased topic
and disk space usages that need to be factored in to
capacity planning calculations.
4
"Can you create me a topic please?”
Thank you.
Many thanks to Shay and David for organising, everyone who attended and sent
kind wishes. Lastly, a huge thank you to MeetupCat.
Photo supplied by @jbfletch_

More Related Content

What's hot

What's hot (20)

Apache Kafka
Apache KafkaApache Kafka
Apache Kafka
 
Apache Kafka - Martin Podval
Apache Kafka - Martin PodvalApache Kafka - Martin Podval
Apache Kafka - Martin Podval
 
Fundamentals of Apache Kafka
Fundamentals of Apache KafkaFundamentals of Apache Kafka
Fundamentals of Apache Kafka
 
Apache Kafka
Apache KafkaApache Kafka
Apache Kafka
 
Hello, kafka! (an introduction to apache kafka)
Hello, kafka! (an introduction to apache kafka)Hello, kafka! (an introduction to apache kafka)
Hello, kafka! (an introduction to apache kafka)
 
Introduction to Apache Kafka
Introduction to Apache KafkaIntroduction to Apache Kafka
Introduction to Apache Kafka
 
Apache kafka
Apache kafkaApache kafka
Apache kafka
 
Apache Kafka
Apache KafkaApache Kafka
Apache Kafka
 
Kafka 101
Kafka 101Kafka 101
Kafka 101
 
A Deep Dive into Kafka Controller
A Deep Dive into Kafka ControllerA Deep Dive into Kafka Controller
A Deep Dive into Kafka Controller
 
Benefits of Stream Processing and Apache Kafka Use Cases
Benefits of Stream Processing and Apache Kafka Use CasesBenefits of Stream Processing and Apache Kafka Use Cases
Benefits of Stream Processing and Apache Kafka Use Cases
 
ksqlDB: A Stream-Relational Database System
ksqlDB: A Stream-Relational Database SystemksqlDB: A Stream-Relational Database System
ksqlDB: A Stream-Relational Database System
 
Introduction to apache kafka, confluent and why they matter
Introduction to apache kafka, confluent and why they matterIntroduction to apache kafka, confluent and why they matter
Introduction to apache kafka, confluent and why they matter
 
Apache Kafka at LinkedIn
Apache Kafka at LinkedInApache Kafka at LinkedIn
Apache Kafka at LinkedIn
 
Citi Tech Talk Disaster Recovery Solutions Deep Dive
Citi Tech Talk  Disaster Recovery Solutions Deep DiveCiti Tech Talk  Disaster Recovery Solutions Deep Dive
Citi Tech Talk Disaster Recovery Solutions Deep Dive
 
Netflix Data Pipeline With Kafka
Netflix Data Pipeline With KafkaNetflix Data Pipeline With Kafka
Netflix Data Pipeline With Kafka
 
Apache Kafka Architecture & Fundamentals Explained
Apache Kafka Architecture & Fundamentals ExplainedApache Kafka Architecture & Fundamentals Explained
Apache Kafka Architecture & Fundamentals Explained
 
Capacity Planning Your Kafka Cluster | Jason Bell, Digitalis
Capacity Planning Your Kafka Cluster | Jason Bell, DigitalisCapacity Planning Your Kafka Cluster | Jason Bell, Digitalis
Capacity Planning Your Kafka Cluster | Jason Bell, Digitalis
 
Confluent REST Proxy and Schema Registry (Concepts, Architecture, Features)
Confluent REST Proxy and Schema Registry (Concepts, Architecture, Features)Confluent REST Proxy and Schema Registry (Concepts, Architecture, Features)
Confluent REST Proxy and Schema Registry (Concepts, Architecture, Features)
 
Apache kafka
Apache kafkaApache kafka
Apache kafka
 

Similar to From Message to Cluster: A Realworld Introduction to Kafka Capacity Planning

M6d cassandrapresentation
M6d cassandrapresentationM6d cassandrapresentation
M6d cassandrapresentation
Edward Capriolo
 
Memory: The New Disk
Memory: The New DiskMemory: The New Disk
Memory: The New Disk
Tim Lossen
 
SF Big Analytics & SF Machine Learning Meetup: Machine Learning at the Limit ...
SF Big Analytics & SF Machine Learning Meetup: Machine Learning at the Limit ...SF Big Analytics & SF Machine Learning Meetup: Machine Learning at the Limit ...
SF Big Analytics & SF Machine Learning Meetup: Machine Learning at the Limit ...
Chester Chen
 

Similar to From Message to Cluster: A Realworld Introduction to Kafka Capacity Planning (20)

Scylla Summit 2016: Outbrain Case Study - Lowering Latency While Doing 20X IO...
Scylla Summit 2016: Outbrain Case Study - Lowering Latency While Doing 20X IO...Scylla Summit 2016: Outbrain Case Study - Lowering Latency While Doing 20X IO...
Scylla Summit 2016: Outbrain Case Study - Lowering Latency While Doing 20X IO...
 
Flink Forward Berlin 2017: Robert Metzger - Keep it going - How to reliably a...
Flink Forward Berlin 2017: Robert Metzger - Keep it going - How to reliably a...Flink Forward Berlin 2017: Robert Metzger - Keep it going - How to reliably a...
Flink Forward Berlin 2017: Robert Metzger - Keep it going - How to reliably a...
 
Building Scalable and Extendable Data Pipeline for Call of Duty Games: Lesson...
Building Scalable and Extendable Data Pipeline for Call of Duty Games: Lesson...Building Scalable and Extendable Data Pipeline for Call of Duty Games: Lesson...
Building Scalable and Extendable Data Pipeline for Call of Duty Games: Lesson...
 
M6d cassandrapresentation
M6d cassandrapresentationM6d cassandrapresentation
M6d cassandrapresentation
 
Micro-batching: High-performance writes
Micro-batching: High-performance writesMicro-batching: High-performance writes
Micro-batching: High-performance writes
 
Micro-batching: High-performance Writes (Adam Zegelin, Instaclustr) | Cassand...
Micro-batching: High-performance Writes (Adam Zegelin, Instaclustr) | Cassand...Micro-batching: High-performance Writes (Adam Zegelin, Instaclustr) | Cassand...
Micro-batching: High-performance Writes (Adam Zegelin, Instaclustr) | Cassand...
 
High Frequency Trading and NoSQL database
High Frequency Trading and NoSQL databaseHigh Frequency Trading and NoSQL database
High Frequency Trading and NoSQL database
 
Designs, Lessons and Advice from Building Large Distributed Systems
Designs, Lessons and Advice from Building Large Distributed SystemsDesigns, Lessons and Advice from Building Large Distributed Systems
Designs, Lessons and Advice from Building Large Distributed Systems
 
Optimizing MongoDB: Lessons Learned at Localytics
Optimizing MongoDB: Lessons Learned at LocalyticsOptimizing MongoDB: Lessons Learned at Localytics
Optimizing MongoDB: Lessons Learned at Localytics
 
Cassandra @ Sony: The good, the bad, and the ugly part 2
Cassandra @ Sony: The good, the bad, and the ugly part 2Cassandra @ Sony: The good, the bad, and the ugly part 2
Cassandra @ Sony: The good, the bad, and the ugly part 2
 
MongoDB for Time Series Data: Sharding
MongoDB for Time Series Data: ShardingMongoDB for Time Series Data: Sharding
MongoDB for Time Series Data: Sharding
 
«Scrapy internals» Александр Сибиряков, Scrapinghub
«Scrapy internals» Александр Сибиряков, Scrapinghub«Scrapy internals» Александр Сибиряков, Scrapinghub
«Scrapy internals» Александр Сибиряков, Scrapinghub
 
Memory: The New Disk
Memory: The New DiskMemory: The New Disk
Memory: The New Disk
 
Scylla Summit 2018: In-Memory Scylla - When Fast Storage is Not Fast Enough
Scylla Summit 2018: In-Memory Scylla - When Fast Storage is Not Fast EnoughScylla Summit 2018: In-Memory Scylla - When Fast Storage is Not Fast Enough
Scylla Summit 2018: In-Memory Scylla - When Fast Storage is Not Fast Enough
 
IAP09 CUDA@MIT 6.963 - Guest Lecture: Out-of-Core Programming with NVIDIA's C...
IAP09 CUDA@MIT 6.963 - Guest Lecture: Out-of-Core Programming with NVIDIA's C...IAP09 CUDA@MIT 6.963 - Guest Lecture: Out-of-Core Programming with NVIDIA's C...
IAP09 CUDA@MIT 6.963 - Guest Lecture: Out-of-Core Programming with NVIDIA's C...
 
Top 5 mistakes when writing Spark applications
Top 5 mistakes when writing Spark applicationsTop 5 mistakes when writing Spark applications
Top 5 mistakes when writing Spark applications
 
Kafka overview v0.1
Kafka overview v0.1Kafka overview v0.1
Kafka overview v0.1
 
SF Big Analytics & SF Machine Learning Meetup: Machine Learning at the Limit ...
SF Big Analytics & SF Machine Learning Meetup: Machine Learning at the Limit ...SF Big Analytics & SF Machine Learning Meetup: Machine Learning at the Limit ...
SF Big Analytics & SF Machine Learning Meetup: Machine Learning at the Limit ...
 
Kafka to the Maxka - (Kafka Performance Tuning)
Kafka to the Maxka - (Kafka Performance Tuning)Kafka to the Maxka - (Kafka Performance Tuning)
Kafka to the Maxka - (Kafka Performance Tuning)
 
Call me maybe: Jepsen and flaky networks
Call me maybe: Jepsen and flaky networksCall me maybe: Jepsen and flaky networks
Call me maybe: Jepsen and flaky networks
 

More from confluent

More from confluent (20)

Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
 
Santander Stream Processing with Apache Flink
Santander Stream Processing with Apache FlinkSantander Stream Processing with Apache Flink
Santander Stream Processing with Apache Flink
 
Unlocking the Power of IoT: A comprehensive approach to real-time insights
Unlocking the Power of IoT: A comprehensive approach to real-time insightsUnlocking the Power of IoT: A comprehensive approach to real-time insights
Unlocking the Power of IoT: A comprehensive approach to real-time insights
 
Workshop híbrido: Stream Processing con Flink
Workshop híbrido: Stream Processing con FlinkWorkshop híbrido: Stream Processing con Flink
Workshop híbrido: Stream Processing con Flink
 
Industry 4.0: Building the Unified Namespace with Confluent, HiveMQ and Spark...
Industry 4.0: Building the Unified Namespace with Confluent, HiveMQ and Spark...Industry 4.0: Building the Unified Namespace with Confluent, HiveMQ and Spark...
Industry 4.0: Building the Unified Namespace with Confluent, HiveMQ and Spark...
 
AWS Immersion Day Mapfre - Confluent
AWS Immersion Day Mapfre   -   ConfluentAWS Immersion Day Mapfre   -   Confluent
AWS Immersion Day Mapfre - Confluent
 
Eventos y Microservicios - Santander TechTalk
Eventos y Microservicios - Santander TechTalkEventos y Microservicios - Santander TechTalk
Eventos y Microservicios - Santander TechTalk
 
Q&A with Confluent Experts: Navigating Networking in Confluent Cloud
Q&A with Confluent Experts: Navigating Networking in Confluent CloudQ&A with Confluent Experts: Navigating Networking in Confluent Cloud
Q&A with Confluent Experts: Navigating Networking in Confluent Cloud
 
Citi TechTalk Session 2: Kafka Deep Dive
Citi TechTalk Session 2: Kafka Deep DiveCiti TechTalk Session 2: Kafka Deep Dive
Citi TechTalk Session 2: Kafka Deep Dive
 
Build real-time streaming data pipelines to AWS with Confluent
Build real-time streaming data pipelines to AWS with ConfluentBuild real-time streaming data pipelines to AWS with Confluent
Build real-time streaming data pipelines to AWS with Confluent
 
Q&A with Confluent Professional Services: Confluent Service Mesh
Q&A with Confluent Professional Services: Confluent Service MeshQ&A with Confluent Professional Services: Confluent Service Mesh
Q&A with Confluent Professional Services: Confluent Service Mesh
 
Citi Tech Talk: Event Driven Kafka Microservices
Citi Tech Talk: Event Driven Kafka MicroservicesCiti Tech Talk: Event Driven Kafka Microservices
Citi Tech Talk: Event Driven Kafka Microservices
 
Confluent & GSI Webinars series - Session 3
Confluent & GSI Webinars series - Session 3Confluent & GSI Webinars series - Session 3
Confluent & GSI Webinars series - Session 3
 
Citi Tech Talk: Messaging Modernization
Citi Tech Talk: Messaging ModernizationCiti Tech Talk: Messaging Modernization
Citi Tech Talk: Messaging Modernization
 
Citi Tech Talk: Data Governance for streaming and real time data
Citi Tech Talk: Data Governance for streaming and real time dataCiti Tech Talk: Data Governance for streaming and real time data
Citi Tech Talk: Data Governance for streaming and real time data
 
Confluent & GSI Webinars series: Session 2
Confluent & GSI Webinars series: Session 2Confluent & GSI Webinars series: Session 2
Confluent & GSI Webinars series: Session 2
 
Data In Motion Paris 2023
Data In Motion Paris 2023Data In Motion Paris 2023
Data In Motion Paris 2023
 
Confluent Partner Tech Talk with Synthesis
Confluent Partner Tech Talk with SynthesisConfluent Partner Tech Talk with Synthesis
Confluent Partner Tech Talk with Synthesis
 
The Future of Application Development - API Days - Melbourne 2023
The Future of Application Development - API Days - Melbourne 2023The Future of Application Development - API Days - Melbourne 2023
The Future of Application Development - API Days - Melbourne 2023
 
The Playful Bond Between REST And Data Streams
The Playful Bond Between REST And Data StreamsThe Playful Bond Between REST And Data Streams
The Playful Bond Between REST And Data Streams
 

Recently uploaded

Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 

Recently uploaded (20)

Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 

From Message to Cluster: A Realworld Introduction to Kafka Capacity Planning

  • 1. From Message to Cluster A Realworld Introduction to Kafka Capacity Planning. Jason “Jase” Bell - @jasonbelldata
  • 3.
  • 4. MeetupCat is my spirit animal.
  • 5. Flight Mode is ON! You may…… • Heckle. • Ask Questions. • Heckle More. • Talk about steak. • Heckle again.
  • 6. What I’m Going To Cover
  • 7. What I’m Going To Cover
  • 8. • The Old Days. • The Now Times. • The Stuff We Don’t Talk About • The Message • What I Usually Ask For • Retention • Estimated Capacity • Compression • Stress Testing • Network and Disk Throughput • Topic Partitions • Kafka Connect • KSQL • Replicator • Parting Thoughts….. • ——————————————————— • Rapturous Applause • Encore (Probably Eye of the Tiger……)
  • 10.
  • 12.
  • 13. The Stuff We Don’t Talk About
  • 14. We think we know what we need from our Kafka Cluster
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 23.
  • 24. { "text": "RT @PostGradProblem: In preparation for the NFL lockout, I will be spending twice as much time analyzing my fantasy baseball team during ...", "truncated": true, "in_reply_to_user_id": null, "in_reply_to_status_id": null, "favorited": false, "source": "<a href="http://twitter.com/" rel="nofollow">Twitter for iPhone</a>", "in_reply_to_screen_name": null, "in_reply_to_status_id_str": null, "id_str": "54691802283900928", "entities": { "user_mentions": [ { "indices": [ 3, 19 ], "screen_name": "PostGradProblem", "id_str": "271572434", "name": "PostGradProblems", "id": 271572434 } ], "urls": [ ], "hashtags": [ ] }, "contributors": null, "retweeted": false, "in_reply_to_user_id_str": null, "place": null, "retweet_count": 4, "created_at": "Sun Apr 03 23:48:36 +0000 2011", "retweeted_status": { "text": "In preparation for the NFL lockout, I will be spending twice as much time analyzing my fantasy baseball team during company time. #PGP", "truncated": false, "in_reply_to_user_id": null, "in_reply_to_status_id": null, "favorited": false, "source": "<a href="http://www.hootsuite.com" rel="nofollow">HootSuite</a>", "in_reply_to_screen_name": null, "in_reply_to_status_id_str": null, "id_str": "54640519019642881", "entities": { "user_mentions": [ ], "urls": [ ], "hashtags": [ Twitter JSON Payload ~6kb
  • 25. What I Usually Ask For
  • 26. •Average Message Size What I’ll Ask Team For…
  • 27. •Average Message Size •Estimated Daily Quantity What I’ll Ask Team For…
  • 28. •Average Message Size •Estimated Daily Quantity •Any Peak Per Hour Quantity What I’ll Ask Team For…
  • 29. •Average Message Size •Estimated Daily Quantity •Any Peak Per Hour Quantity •Desired Replication Factor What I’ll Ask Team For…
  • 30. •Average Message Size •Estimated Daily Quantity •Any Peak Per Hour Quantity •Desired Replication Factor •Desired Partitions What I’ll Ask Team For…
  • 31. •Average Message Size •Estimated Daily Quantity •Any Peak Per Hour Quantity •Desired Replication Factor •Desired Partitions •Minimum In-sync Replicas What I’ll Ask Team For…
  • 32. •Average Message Size - (6 KB) •Estimated Daily Quantity - (10,000,000/d) •Any Peak Per Hour Quantity - (1,250,000) •Desired Replication Factor - (4) •Desired Partitions - (10) •Minimum In-sync Replicas - (2) What I’ll Ask Team For…
  • 34. Estimated Capacity (Message size x 3) x Daily Qty x 1.4 (add 40%) = Volume per replicated broker.
  • 35. Estimated Capacity (6KB x 3) x 10,0000,000 = 184,320,000 KB x 1.4 (add 40%) = 258,048,000 KB = 248.09 GB Roughly translates to 2.940 MB/sec
  • 36. Estimated Capacity The x3 gives me a payload size with key, header, timestamp and the value. It’s just a rough calculation.
  • 37. Estimated Capacity The x3 gives me a payload size with key, header, timestamp and the value. It’s just a rough calculation. Adding 40% overhead will give you some breathing space when someone does a stress test and doesn’t tell you…..
  • 38. Retention (6KB x 3) x 10,0000,000 = 184,320,000 KB x 1.4 (add 40%) = 258,048,000 KB = 248.09 GB 248.09 GB/day x 14 days retention = 3.4 TB per broker.
  • 39. Estimated Capacity df -hIs your friend…..
  • 40. Estimated Capacity du -H .Is also your friend…..
  • 41.
  • 43. Producer configuration compression.type defaults to “none”. Options are gzip, snappy, lz4 and zstd. Expect ~20%-40% message compression depending on the algorithm used.
  • 45. kafka-producer-perf-test --topic TOPIC --record-size SIZE_IN_BYTES
  • 46. $ bin/kafka-producer-perf-test --topic testtopic --record-size 1000 --num- records 10000  --throughput 1000 --producer-props bootstrap.servers=localhost:9092 5003 records sent, 1000.4 records/sec (0.95 MB/sec), 1.6 ms avg latency, 182.0 ms max latency. 10000 records sent, 998.801438 records/sec (0.95 MB/sec), 1.12 ms avg latency, 182.00 ms max latency, 1 ms 50th, 2 ms 95th, 19 ms 99th, 23 ms 99.9th.
  • 48.
  • 50. • D - Data to be written (MB/sec) • R - Replication Factor • C - Number of Consumer Groups (readers for each write)
  • 51. The Volume of Writes: (D * R)
  • 52. The Volume of Reads within Replication: ((R-1) * D) Reads happen internally by the replicas, this gives us:
  • 53. The Volume of Reads within Replication: ((R - 1) * D) Reads happen internally by the replicas, this gives us: Adding the consumers we end up with: The Volume of Reads within Replication: (((R + C) - 1) * D)
  • 54. We have memory! We have Caching! M/(D * R) = seconds of writes cached.
  • 55. We have memory! We have Caching! M/(D * R) = seconds of writes cached. We have to assume that consumers might drop from the cache, consumers are running slower than expected or even that replicas might restart due to failure, patching or rolling restarts. Lagging Readers L = R + C - 1
  • 56. Disk Throughput: D * R + L * D Network (reads) Throughput: ((R + C -1) * D) Network (writes) Throughput: D * R
  • 58.
  • 59.
  • 60.
  • 61.
  • 62. You can set partitions either creating the topic (—partitions n) or afterwards.
  • 63. Having a large number of partitions will have effects on Zookeeper znodes. • More network requests • If leader or broker goes down it may affect startup time as the broker returns to the cluster.
  • 64.
  • 65. If you need to reduce partitions create a new topic and reduce the partition count.
  • 68.
  • 69. Think about second and third order consequences if a connector would fail. What is the impact?
  • 71. KSQL
  • 72. ksqlDB •4 CPU Cores •32GB RAM •100GB SSD Disk •1Gbit Network Baseline Server Requirements
  • 73. ksqlDB •Partition Count of 4 •Replication Factor of 1 Default Outbound Topic Assumptions (These settings can be modified within your CREATE query)
  • 74. ksqlDB Some queries will require repartitioning and intermediate topics for certain operations, taking all available records. Default Outbound Topic Assumptions
  • 75. ksqlDB Processing Small Message/Many Columns = CPU Saturation Default Outbound Topic Assumptions
  • 76. ksqlDB Processing Large Message/Small Columns = Network Saturation Default Outbound Topic Assumptions
  • 78. Data Centre to Data Centre is going to lead to increased network latency.
  • 79. On producers and consumers, use send.buffer.bytes and receive.buffer.bytes. On brokers, use socket.send.buffer.bytes and socket.receive.buffer.bytes. 
  • 80.
  • 82. Consumer Group Lag Reports are your guiding light. (If you have Rundeck setup a scheduled job to email you the log output) 1
  • 83. kafka-consumer-groups --bootstrap-server BROKER_ADDRESS --describe —group CONSUMER_GROUP --new-consumer
  • 84. Kafka is about trade offs, from the producer right the way through to the consumer (and beyond). There’s no right or wrong answer, just experimentation, monitoring and learning. 2
  • 85. While securing Kafka is important there is also a cost as certificates are verified and take up CPU resources. Your throughput will be affected. 3
  • 86. The Kafka Ecosystem has increased in features over the last few years. This has lead to increased topic and disk space usages that need to be factored in to capacity planning calculations. 4
  • 87. "Can you create me a topic please?”
  • 88.
  • 89. Thank you. Many thanks to Shay and David for organising, everyone who attended and sent kind wishes. Lastly, a huge thank you to MeetupCat. Photo supplied by @jbfletch_