SlideShare uma empresa Scribd logo
1 de 33
State-of-the-Art Patterns for
Efficient, Resilient, and
Highly Available Global
Kafka
Sanjana Kaundinya, Luke Knepper, and Nikhil Bhatia
2
Nikhil Bhatia
Engineering Leader, Kafka
Global, Confluent
About Myself
• Previous project at Confluent -
Infinite Storage for Kafka
• Principal Engineer at Microsoft
@nikhilbhatia
linkedin.com/in/nikhil-bhatia-a2a8115
Agenda
3
1. Kafka Replication Overview
2. Kafka Global Replication Overview
3. Kafka Stretched Clusters + demo
4. Kafka Connected Clusters + demo
5. Q&A
Kafka Overview
4
● Broker - Stores messages in partitions
● Topic - Virtual Group of one or more partitions
● Partitions - Log files on disk with sequential write only. Kafka
guarantees message ordering in a partition.
Broker
T1
P
P2
P1
C
C
C
P
CG1
Kafka Log Offsets
5
P1
C1
P
C2
4 5 6 7 8 9
0 1 2 3
CG2
C1
C2
P2
P3
P4
Partition 1
__consumer
_offset
startOffset CG1 CG2 HW endOffset
Produce
● The log end offset is the offset of
the last message written to a log.
● The high watermark offset is the
offset of the last message that
was successfully copied to all of
the log’s replicas.
● The consumer offset is a way of
tracking the sequential order in
which messages are received by
Kafka topics.
Why do we Need Replication ?
6
Broker can do down
● Controlled - software/config update
● Uncontrolled - compute/disk fault, bugs
When broker goes down - durability and availability impact
● Data loss
● Some Partition on the cluster not available
From a major cloud provided
“For any Single Instance Virtual Machine using Standard HDD Managed Disks for Operating System Disks and Data Disks,
we guarantee you will have Virtual Machine Connectivity of at least 95%.”
Kafka Replication
7
● Partition replicas are evenly distributed (e.g. Replication Factor = 3)
● Strongly Consistent - Byte wise identical , Ordering guarantee
P1
(L)
P2
(L)
P4
(L)
P1
P2
P3
P4
P3
P1
P3
(L)
P4
P2
How are messages committed ?
8
● Leader maintains In Sync Replicas (ISR)
● Leader waits for followers to sync replicas
● If follower fails it will shrink the ISR, continue being available
● Leader and Follower failure cases are handled by having leader epoch be part
of producer message and log truncation in the follower (refer KIP-101)
●
R1
(L)
R2
(L)
R4
(L)
R2
R1
R3
R4
R3
R3
R3
(L)
R4
R2
P1
(L)
Salient points for Replication
9
● Intra cluster Replication helps improve durability and availability for
node level failures.
● Offsets are core piece of Kafka producer and consumer ecosystem.
● Kafka Replication protocol ensures strong consistency through byte
by byte replication and providing message ordering guarantees.
Multi Zone(MZ) HA Kafka Cluster
10
B B
zk zk
P C
B
zk
AZ1 AZ2 AZ3
Inter Zone Latency <10 ms
Typical ~3 ms
Why Globally Replicate ?
11
● Disaster Recovery
○ DC can go down, regional failures do happen even in major
clouds
■ AWS (US-EAST-1) Region failure in last Nov
■ Microsoft's last March 3 Azure East US outage
○ Planned failovers (expected hurricane, prepare and prevent
outage)
○ Passing DR audits are a requirement
● Fan-out - Topic sharing - Data needs to get near to the consumer
● Fan-in - Aggregate Clusters e.g. IOT use cases
● Cluster/Cloud Migration
Disaster Recovery - Metrics
12
Recovery Point Objective(RPO):
Maximum amount of data – as
measured by time – that can be lost
after a recovery
Recovery Time Objective (RTO):
Targeted duration of time and a
service level within which a business
process must be restored after a
disaster
*Source: Wikipedia
Differences Among Multi-DC Solutions
Multi-Region
Clusters
(Stretched)
Cluster
Linking
(Connected)
Replicator
Replicator/MM2
(Connected
Externally)
14
Luke Knepper
Product Manager for
Global Kafka
About Myself
● Stanford CS ⇒
● Lead Software Engineer ⇒
● Stanford MBA ⇒
● Product Manager
@knep
linkedin.com/in/knepper
Stretch Clusters
Stretched Clusters
● Fast Disaster Recovery
● Offset Preserving
● Automated Client Failover
with No Custom Code
● Sync or Async Replication per
Topic with Confluent’s
Multi-Region Clusters
16
Replica Placement
● Ensure your partition’s
replicas are spread
throughout your data centers
17
placement.json
"replicas": [ {
"count": 2,
"constraints": { "rack": "east" }
}, {
"count": 2,
"constraints": { "rack": "west" }
} ],
kafka-topics --create
--bootstrap-server localhost:9091
--topic annas_topic
--partitions 1
--config min.insync.replicas=3
--replica-placement placement.json
Follower
Fetching
● Your consumers can
read from a nearby
replica -- to save on
networking costs &
latency
18
Observers: Asynchronous Replicas
19
● Replicate partitions from the leader like followers.
● Not considered when we increment the high watermark
● Improved durability without sacrificing write throughput
● Replicates across slower/higher-latency links without falling in and
out of sync (also known as ISR thrashing)
● Available in Confluent Server
Example: Datacenter Failover for 2.5 DCs
2.5 datacenters 4 Replicas (“R”) + 2 Observers (“O”) Min ISR: 3 acks=all
20
R R
O
ISR
DC A DC B
Zk Zk
R R
O
Zk Zk
DC 0.5
Zk
Steady State
Observers stay out of the ISR.
Min ISR of 3 forces writes go to
both datacenters.
Note: This “half-DC” is
needed to prevent a “split
brain” between the two
datacenters
Example: Datacenter Failover for 2.5 DCs
2.5 datacenters 4 Replicas (“R”) + 2 Observers (“O”) Min ISR: 3 acks=all
21
R R
O
ISR
DC A DC B - offline
Zk Zk
R R
O
Zk Zk
DC 0.5
Zk
DC Failure
In-sync replica count falls below min ISR.
Observer automatically joins ISR.
Min ISR is satisfied, writes can go to remaining datacenter.
Availability is automatically maintained.
22
Sanjana Kaundinya
Software Engineer, Global
Kafka
About Myself
- Working at Confluent for the past 1.5
years supporting and developing
global replication technologies
@skaundinya15
linkedin.com/in/sanjanakaundinya
Connected Clusters
Clusters can
replicate using
Kafka Connect
● Disaster Recovery
● Active-Active Replication
● Offset Translation
● MM2 and Confluent
Replicator
Connect based
Replication
24
R
Fundamentals of Kafka Connect
25
● Offset management
● Elastic scalability
● Parallelization
● Task distribution
● Metrics
● Failure & Retries
● Configuration
Management
● REST API
● Schemas & Data Types
Multi-Geo Replication Through Connect
26
Source
Connector
Offset Translation in MirrorMaker 2.0
27
offset_sync
topic,
partition,
src offset,
matching dest offset
checkpoints
topic,
partition,
group name,
consumer group src offset,
matching dest offset
Consumer
translateOffsets
Destination Cluster
Active-Active Replication in MirrorMaker 2.0
28
● Two clusters can be configured to replicate to each other
○ Known as an “Active-Active” replication scenario
● Records are produced to both clusters and can be seen by clients in
both clusters
○ Problem that comes from this is cyclic replication
● MirrorMaker 2.0 uses alias detection
○ Example: Topics containing “us-west” in prefix won’t be
replicated to “us-west” cluster
● Holds true regardless of cluster topology
● Cluster can be replicated to several downstream clusters
Offset Translation in Replicator
29
Active-Active Replication in Replicator
30
● Replicator adds a provenance header to each record with the
following information
ID of the origin cluster where this message was first produced
Name of the topic to which this message was first produced
Timestamp when Replicator first copied the record
● Replicator (by default) will skip over any records where the
destination cluster id is the same as the origin cluster id in the
provenance header
● By adding a bit of overhead to the record, cyclic replication is
prevented
● Works with more than two clusters
Connecting Clusters
Sans Kafka Connect
● Multi continent replication
without the need for an
external system
● Offset preserving, thereby
eliminating the need for
offset translation
● Use cases include data
sharing, cluster migration,
and hybrid cloud
architectures
Cluster Linking
31
Cluster Linking Architecture Overview
32
● Extends the existing replica fetching protocol
○ Uses protocol to fetch across clusters
● Link has information necessary for destination to talk to source
● Destination cluster can create mirror topics
○ Topics fetch from source and have same configs as source topic
● Mirror topics are immutable
○ Recognizes partition is a mirror and fetches over cluster link
● Allows for mirror topic to be byte for byte replica of source topic
○ Maintains offset consistency across clusters, eliminates need for
offset translation
Questions?
skaundinya@confluent.io
nikhil@confluent.io
lknepper@confluent.io
We are hiring! :)

Mais conteúdo relacionado

Mais de confluent

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 Diveconfluent
 
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 Confluentconfluent
 
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 Meshconfluent
 
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 Microservicesconfluent
 
Confluent & GSI Webinars series - Session 3
Confluent & GSI Webinars series - Session 3Confluent & GSI Webinars series - Session 3
Confluent & GSI Webinars series - Session 3confluent
 
Citi Tech Talk: Messaging Modernization
Citi Tech Talk: Messaging ModernizationCiti Tech Talk: Messaging Modernization
Citi Tech Talk: Messaging Modernizationconfluent
 
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 dataconfluent
 
Confluent & GSI Webinars series: Session 2
Confluent & GSI Webinars series: Session 2Confluent & GSI Webinars series: Session 2
Confluent & GSI Webinars series: Session 2confluent
 
Data In Motion Paris 2023
Data In Motion Paris 2023Data In Motion Paris 2023
Data In Motion Paris 2023confluent
 
Confluent Partner Tech Talk with Synthesis
Confluent Partner Tech Talk with SynthesisConfluent Partner Tech Talk with Synthesis
Confluent Partner Tech Talk with Synthesisconfluent
 
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 2023confluent
 
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 Streamsconfluent
 
The Journey to Data Mesh with Confluent
The Journey to Data Mesh with ConfluentThe Journey to Data Mesh with Confluent
The Journey to Data Mesh with Confluentconfluent
 
Citi Tech Talk: Monitoring and Performance
Citi Tech Talk: Monitoring and PerformanceCiti Tech Talk: Monitoring and Performance
Citi Tech Talk: Monitoring and Performanceconfluent
 
Confluent Partner Tech Talk with Reply
Confluent Partner Tech Talk with ReplyConfluent Partner Tech Talk with Reply
Confluent Partner Tech Talk with Replyconfluent
 
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 Diveconfluent
 
Citi Tech Talk: Hybrid Cloud
Citi Tech Talk: Hybrid CloudCiti Tech Talk: Hybrid Cloud
Citi Tech Talk: Hybrid Cloudconfluent
 
Partner Tech Talk Q3: Q&A with PS - Migration and Upgrade
Partner Tech Talk Q3: Q&A with PS - Migration and UpgradePartner Tech Talk Q3: Q&A with PS - Migration and Upgrade
Partner Tech Talk Q3: Q&A with PS - Migration and Upgradeconfluent
 
Confluent Partner Tech Talk with QLIK
Confluent Partner Tech Talk with QLIKConfluent Partner Tech Talk with QLIK
Confluent Partner Tech Talk with QLIKconfluent
 
Real-time Streaming for Government and the Public Sector
Real-time Streaming for Government and the Public SectorReal-time Streaming for Government and the Public Sector
Real-time Streaming for Government and the Public Sectorconfluent
 

Mais de confluent (20)

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
 
The Journey to Data Mesh with Confluent
The Journey to Data Mesh with ConfluentThe Journey to Data Mesh with Confluent
The Journey to Data Mesh with Confluent
 
Citi Tech Talk: Monitoring and Performance
Citi Tech Talk: Monitoring and PerformanceCiti Tech Talk: Monitoring and Performance
Citi Tech Talk: Monitoring and Performance
 
Confluent Partner Tech Talk with Reply
Confluent Partner Tech Talk with ReplyConfluent Partner Tech Talk with Reply
Confluent Partner Tech Talk with Reply
 
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
 
Citi Tech Talk: Hybrid Cloud
Citi Tech Talk: Hybrid CloudCiti Tech Talk: Hybrid Cloud
Citi Tech Talk: Hybrid Cloud
 
Partner Tech Talk Q3: Q&A with PS - Migration and Upgrade
Partner Tech Talk Q3: Q&A with PS - Migration and UpgradePartner Tech Talk Q3: Q&A with PS - Migration and Upgrade
Partner Tech Talk Q3: Q&A with PS - Migration and Upgrade
 
Confluent Partner Tech Talk with QLIK
Confluent Partner Tech Talk with QLIKConfluent Partner Tech Talk with QLIK
Confluent Partner Tech Talk with QLIK
 
Real-time Streaming for Government and the Public Sector
Real-time Streaming for Government and the Public SectorReal-time Streaming for Government and the Public Sector
Real-time Streaming for Government and the Public Sector
 

Último

Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 

Último (20)

Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 

State-of-the-art Patterns for Efficient, Resilient, and Highly Available global kafka

  • 1. State-of-the-Art Patterns for Efficient, Resilient, and Highly Available Global Kafka Sanjana Kaundinya, Luke Knepper, and Nikhil Bhatia
  • 2. 2 Nikhil Bhatia Engineering Leader, Kafka Global, Confluent About Myself • Previous project at Confluent - Infinite Storage for Kafka • Principal Engineer at Microsoft @nikhilbhatia linkedin.com/in/nikhil-bhatia-a2a8115
  • 3. Agenda 3 1. Kafka Replication Overview 2. Kafka Global Replication Overview 3. Kafka Stretched Clusters + demo 4. Kafka Connected Clusters + demo 5. Q&A
  • 4. Kafka Overview 4 ● Broker - Stores messages in partitions ● Topic - Virtual Group of one or more partitions ● Partitions - Log files on disk with sequential write only. Kafka guarantees message ordering in a partition. Broker T1 P P2 P1 C C C P
  • 5. CG1 Kafka Log Offsets 5 P1 C1 P C2 4 5 6 7 8 9 0 1 2 3 CG2 C1 C2 P2 P3 P4 Partition 1 __consumer _offset startOffset CG1 CG2 HW endOffset Produce ● The log end offset is the offset of the last message written to a log. ● The high watermark offset is the offset of the last message that was successfully copied to all of the log’s replicas. ● The consumer offset is a way of tracking the sequential order in which messages are received by Kafka topics.
  • 6. Why do we Need Replication ? 6 Broker can do down ● Controlled - software/config update ● Uncontrolled - compute/disk fault, bugs When broker goes down - durability and availability impact ● Data loss ● Some Partition on the cluster not available From a major cloud provided “For any Single Instance Virtual Machine using Standard HDD Managed Disks for Operating System Disks and Data Disks, we guarantee you will have Virtual Machine Connectivity of at least 95%.”
  • 7. Kafka Replication 7 ● Partition replicas are evenly distributed (e.g. Replication Factor = 3) ● Strongly Consistent - Byte wise identical , Ordering guarantee P1 (L) P2 (L) P4 (L) P1 P2 P3 P4 P3 P1 P3 (L) P4 P2
  • 8. How are messages committed ? 8 ● Leader maintains In Sync Replicas (ISR) ● Leader waits for followers to sync replicas ● If follower fails it will shrink the ISR, continue being available ● Leader and Follower failure cases are handled by having leader epoch be part of producer message and log truncation in the follower (refer KIP-101) ● R1 (L) R2 (L) R4 (L) R2 R1 R3 R4 R3 R3 R3 (L) R4 R2 P1 (L)
  • 9. Salient points for Replication 9 ● Intra cluster Replication helps improve durability and availability for node level failures. ● Offsets are core piece of Kafka producer and consumer ecosystem. ● Kafka Replication protocol ensures strong consistency through byte by byte replication and providing message ordering guarantees.
  • 10. Multi Zone(MZ) HA Kafka Cluster 10 B B zk zk P C B zk AZ1 AZ2 AZ3 Inter Zone Latency <10 ms Typical ~3 ms
  • 11. Why Globally Replicate ? 11 ● Disaster Recovery ○ DC can go down, regional failures do happen even in major clouds ■ AWS (US-EAST-1) Region failure in last Nov ■ Microsoft's last March 3 Azure East US outage ○ Planned failovers (expected hurricane, prepare and prevent outage) ○ Passing DR audits are a requirement ● Fan-out - Topic sharing - Data needs to get near to the consumer ● Fan-in - Aggregate Clusters e.g. IOT use cases ● Cluster/Cloud Migration
  • 12. Disaster Recovery - Metrics 12 Recovery Point Objective(RPO): Maximum amount of data – as measured by time – that can be lost after a recovery Recovery Time Objective (RTO): Targeted duration of time and a service level within which a business process must be restored after a disaster *Source: Wikipedia
  • 13. Differences Among Multi-DC Solutions Multi-Region Clusters (Stretched) Cluster Linking (Connected) Replicator Replicator/MM2 (Connected Externally)
  • 14. 14 Luke Knepper Product Manager for Global Kafka About Myself ● Stanford CS ⇒ ● Lead Software Engineer ⇒ ● Stanford MBA ⇒ ● Product Manager @knep linkedin.com/in/knepper
  • 16. Stretched Clusters ● Fast Disaster Recovery ● Offset Preserving ● Automated Client Failover with No Custom Code ● Sync or Async Replication per Topic with Confluent’s Multi-Region Clusters 16
  • 17. Replica Placement ● Ensure your partition’s replicas are spread throughout your data centers 17 placement.json "replicas": [ { "count": 2, "constraints": { "rack": "east" } }, { "count": 2, "constraints": { "rack": "west" } } ], kafka-topics --create --bootstrap-server localhost:9091 --topic annas_topic --partitions 1 --config min.insync.replicas=3 --replica-placement placement.json
  • 18. Follower Fetching ● Your consumers can read from a nearby replica -- to save on networking costs & latency 18
  • 19. Observers: Asynchronous Replicas 19 ● Replicate partitions from the leader like followers. ● Not considered when we increment the high watermark ● Improved durability without sacrificing write throughput ● Replicates across slower/higher-latency links without falling in and out of sync (also known as ISR thrashing) ● Available in Confluent Server
  • 20. Example: Datacenter Failover for 2.5 DCs 2.5 datacenters 4 Replicas (“R”) + 2 Observers (“O”) Min ISR: 3 acks=all 20 R R O ISR DC A DC B Zk Zk R R O Zk Zk DC 0.5 Zk Steady State Observers stay out of the ISR. Min ISR of 3 forces writes go to both datacenters. Note: This “half-DC” is needed to prevent a “split brain” between the two datacenters
  • 21. Example: Datacenter Failover for 2.5 DCs 2.5 datacenters 4 Replicas (“R”) + 2 Observers (“O”) Min ISR: 3 acks=all 21 R R O ISR DC A DC B - offline Zk Zk R R O Zk Zk DC 0.5 Zk DC Failure In-sync replica count falls below min ISR. Observer automatically joins ISR. Min ISR is satisfied, writes can go to remaining datacenter. Availability is automatically maintained.
  • 22. 22 Sanjana Kaundinya Software Engineer, Global Kafka About Myself - Working at Confluent for the past 1.5 years supporting and developing global replication technologies @skaundinya15 linkedin.com/in/sanjanakaundinya
  • 24. Clusters can replicate using Kafka Connect ● Disaster Recovery ● Active-Active Replication ● Offset Translation ● MM2 and Confluent Replicator Connect based Replication 24 R
  • 25. Fundamentals of Kafka Connect 25 ● Offset management ● Elastic scalability ● Parallelization ● Task distribution ● Metrics ● Failure & Retries ● Configuration Management ● REST API ● Schemas & Data Types
  • 26. Multi-Geo Replication Through Connect 26 Source Connector
  • 27. Offset Translation in MirrorMaker 2.0 27 offset_sync topic, partition, src offset, matching dest offset checkpoints topic, partition, group name, consumer group src offset, matching dest offset Consumer translateOffsets Destination Cluster
  • 28. Active-Active Replication in MirrorMaker 2.0 28 ● Two clusters can be configured to replicate to each other ○ Known as an “Active-Active” replication scenario ● Records are produced to both clusters and can be seen by clients in both clusters ○ Problem that comes from this is cyclic replication ● MirrorMaker 2.0 uses alias detection ○ Example: Topics containing “us-west” in prefix won’t be replicated to “us-west” cluster ● Holds true regardless of cluster topology ● Cluster can be replicated to several downstream clusters
  • 29. Offset Translation in Replicator 29
  • 30. Active-Active Replication in Replicator 30 ● Replicator adds a provenance header to each record with the following information ID of the origin cluster where this message was first produced Name of the topic to which this message was first produced Timestamp when Replicator first copied the record ● Replicator (by default) will skip over any records where the destination cluster id is the same as the origin cluster id in the provenance header ● By adding a bit of overhead to the record, cyclic replication is prevented ● Works with more than two clusters
  • 31. Connecting Clusters Sans Kafka Connect ● Multi continent replication without the need for an external system ● Offset preserving, thereby eliminating the need for offset translation ● Use cases include data sharing, cluster migration, and hybrid cloud architectures Cluster Linking 31
  • 32. Cluster Linking Architecture Overview 32 ● Extends the existing replica fetching protocol ○ Uses protocol to fetch across clusters ● Link has information necessary for destination to talk to source ● Destination cluster can create mirror topics ○ Topics fetch from source and have same configs as source topic ● Mirror topics are immutable ○ Recognizes partition is a mirror and fetches over cluster link ● Allows for mirror topic to be byte for byte replica of source topic ○ Maintains offset consistency across clusters, eliminates need for offset translation