natans@wix.com twitter @NSilnitsky linkedin/natansilnitsky github.com/natansil
Exactly Once Delivery
is a harsh mistress
Natan Silnitsky
Backend Infra Developer, Wix.com
As it happens,
we have a distributed system at Wix.
~1400 micro-services
@NSilnitsky
As it happens,
we have a distributed system at Wix.
Edit MySite
~1400 micro-services
~850M messages every day
@NSilnitsky
PurchaseCompleted
Classic ecommerce flow
UpdateInventory(ItemN)
updates
UpdateInventory(Item1)
UpdateInventory(Item2)
@NSilnitsky
Classic ecommerce flow - hard to achieve
PurchaseCompleted
UpdateInventory(ItemN)
updates
UpdateInventory(Item1)
UpdateInventory(Item2)
😳 But... how do we update all items exactly once? on failures/restarts too...
PurchaseCompleted
updates
UpdateInventory(Item1)
UpdateInventory(Item2)
Classic ecommerce flow - hard to achieve
Inventory:
Item1 9 → 8
Item2 5 → 4
@NSilnitsky
PurchaseCompleted
updates
UpdateInventory(Item1)
UpdateInventory(Item2)
Classic ecommerce flow - hard to achieve
Inventory:
Item1 9 → 8
Item2 5 → 3
@NSilnitsky
Achieving Exactly-Once delivery in
distributed systems is NOT easy.
Message delivery over the network
is unreliable.
@NSilnitsky
Message delivery over the network
is unreliable.
Message
Consumer
Message
Producer
Broker
@NSilnitsky
Kafka Broker
Topic-1
0 1 2 3 45
0 1 2 3 45
0 1 2 3 45
0 1 2 3 45
0 1 2 3 4
Topic-2
0 1 2 3 45
0 1 2 3 45
0 1 2 3 45
0 1 2 3 45
0 1 2 3 4
0 1 2 3 4 5
0 1 2 3 4 5
0 1 2 3 4 5
0 1 2 3 4 5
0 1 2 3 4 5
(append-only logs)
Partitions
@NSilnitsky
Kafka
Consumer
Kafka
Producer
Kafka Broker
Topic-1
0 1 2 3 45
0 1 2 3 45
0 1 2 3 45
0 1 2 3 45
0 1 2 3 4
0 1 2 3 4 5
0 1 2 3 4 5
0 1 2 3 4 5
0 1 2 3 4 5
0 1 2 3 4 5
@NSilnitsky
The options for
message delivery
Why Exactly-Once
is difficult
Kafka’s solution for
Exactly-Once
delivery
Kafka Broker
Kafka
Producer
0 1 2 3 4 5
😕 Services need to address message duplicates
at-most-onceat-least-once exactly-once
Producer retries on
every failure
Kafka Broker
0 1 2 3 4 5
😕 Services need to handle messages exactly once
consumerRecords = Consumer.poll
process(consumerRecords)
consumer.commit
at-most-onceat-least-once exactly-once
Consumer retries
on every failure
Kafka
Consumer
Kafka Broker
0 1 2 3 4 5
😕 Messages may be lost
Consumer commits
before processing
consumerRecords = Consumer.poll
Consumer.commit
process(consumerRecords)
at-most-onceat-least-once exactly-once
Kafka
Consumer
Kafka Broker
0 1 2 3 4 5
Kafka
Consumer
😕 Really really really hard to do
Messages are read and processed
exactly once by the consumer
?
at-least-once exactly-onceat-most-once
The options for
message delivery
Why Exactly-Once
is difficult
Kafka’s solution for
Exactly-Once
delivery
The “Two Generals Problem"
thought experiment
Alice Bob
Tomorrow
7 AM
The “Two Generals Problem"
thought experiment
Alice Bob
The “Two Generals Problem"
thought experiment
Alice Bob
The “Two Generals Problem"
thought experiment
Alice Bob
Tomorrow
7 AM
OK!
Tomorrow
7 AM
The “Two Generals Problem"
thought experiment
Alice Bob
?
The “Two Generals Problem"
thought experiment
Alice Bob
OK!
The “Two Generals Problem"
thought experiment
AliceService BobService
The options for
message delivery
Why Exactly-Once
is difficult
Kafka’s solution for
Exactly-Once
delivery
Kafka Broker
Processor Observer
Consumer
-Producer
Consumer
Topic A Topic B
@NSilnitsky
Kafka Broker
Processor Observer
Consumer
-Producer
Consumer
Topic A Topic B
@NSilnitsky
Kafka Broker
Kafka
Idempotent
Producer
0 1 2 3 4 5
0 1
1
Attaches offset to
message
Enable.idempotence = true
@NSilnitsky
Kafka Broker
Kafka
Idempotent
Producer
0 1 2 3 4 5
0 1
1
Attaches offset to
message
Enable.idempotence = true
duplicate!
@NSilnitsky
Kafka Broker
Topic A Topic B
Processor Observer
Consumer
-Producer
Consumer
@NSilnitsky
Kafka Broker
consumer.poll
Attaches offset to message +
marks transaction
ABCDEF
Processor Observer
AB
01
Topic A Topic B
@NSilnitsky
Kafka Broker
consumer.poll
producer.beginTransaction
Producer.send
Attaches offset to message +
marks transaction
ABCDEF
Processor Observer
ABC
01
Topic A Topic B
@NSilnitsky
Kafka Broker
consumer.poll
producer.beginTransaction
Producer.send
producer.sendOffsets
Attaches offset to message +
marks transaction
ABCDEF
Processor Observer
ABC
012
Topic A Topic B
@NSilnitsky
Kafka Broker
consumer.poll
producer.beginTransaction
Producer.send
producer.sendOffsets
producer.commitTransaction
Attaches offset to message +
marks transaction
ABCDEF
Processor Observer
ABC
012
Topic A Topic B
@NSilnitsky
Kafka Broker
consumer.poll
producer.beginTransaction
Producer.send
producer.sendOffsets
Attaches offset to message +
marks transaction
ABCDEF
Processor Observer
ABC
01
Topic A Topic B
@NSilnitsky
Kafka Broker
The bigger the batch the longer the latency.
Processor Observer
@NSilnitsky
Kafka Broker
Processor Observer
No end-to-end exactly-once guarantees
out of the box.
@NSilnitsky
In reality, this is more complex
than how I describe it.
Out of scope:
▪ Two-phase-commit with transaction coordinator
▪ Transaction log
▪ Additional “fencing” data
▪ 1 processor-producer - 1 partition
@NSilnitsky
Purchase
Completed
UpdateInventory(Item1)
Exactly Once (Classic ecommerce) flow at Wix
UpdateInventory(Item2)
UpdateInventory(ItemN)
ABCDEF
1
iNB
1
I3I8
I1I2I5I5
01
updates
@NSilnitsky
Exactly-Once delivery is...
like the holy grail of message delivery over the network.
It’s a tough nut to crack.
Exactly-Once delivery is...
complex to implement, to use, and it requires fine-tuning.
Exactly-Once delivery is...
crucial for achieving atomic actions in distributed systems.
Thank You
natans@wix.com twitter @NSilnitsky linkedin/natansilnitsky github.com/natansil
Resources
EoS in Kafka talk by Jason Gustafson
Exactly-once Semantics are Possible by Neha Narkhede
Transactions in Apache Kafka
Revisiting Exactly One Semantics by Jason Gustafson, Confluent
Proposal to improve EOS Produce scalability
How akka works with exactly once message delivery by Hugh McKee
Slides & More
slideshare.net/NatanSilnitsky
medium.com/@natansil
twitter.com/NSilnitsky

More Related Content

DOC
Qtp quiz for you
PDF
Pratical eff
PDF
Pratical eff monad at Scaladays Chicago
PPTX
Pratical eff-scalaitaly-2017
KEY
Ruby 1.9 Fibers
PPTX
Cassandra Summit 2015 - A State of Xen - Chaos Monkey & Cassandra
PDF
PDF
BASICS OF VERT.X - A toolkit for building asynchronous and reactive app
Qtp quiz for you
Pratical eff
Pratical eff monad at Scaladays Chicago
Pratical eff-scalaitaly-2017
Ruby 1.9 Fibers
Cassandra Summit 2015 - A State of Xen - Chaos Monkey & Cassandra
BASICS OF VERT.X - A toolkit for building asynchronous and reactive app

What's hot (20)

KEY
Why I Love TorqueBox (And Why You Will Too)
PDF
Frontend infrastructure (EmberConf 2015)
PDF
Route service-pcf-techmeetup
PDF
Dumb Services in Smart Nets - istio
PDF
Keep your projects up-to-date
PDF
Background processes and tasks in an async world
PDF
Make your Rails console AWESOME (Ruby SG meetup 2016-03-29)
PDF
Converting LotusScript Agents to Java Agents
PDF
Intro to elixir and phoenix
PDF
Building Real-Time Applications in Ember.js
PDF
2021laravelconftwslides6
PDF
WASM! WASI! WAGI! WAT?
PDF
CI/CD Using Ansible and Jenkins for Infrastructure
PDF
Npm Shrinkwrap
PPTX
AWS CodeDeploy - basic intro
PDF
Progressively enhance your Symfony 4 app using Vue, API Platform, Mercure and...
PDF
Willian Martins - Back to the future of JS: the next features and amazing pro...
PDF
Test Failed, Then...
PDF
Puppet Camp Tokyo 2014: Why we stopped using Puppet Agent Daemon
PDF
Distributed and concurrent programming with RabbitMQ and EventMachine Rails U...
Why I Love TorqueBox (And Why You Will Too)
Frontend infrastructure (EmberConf 2015)
Route service-pcf-techmeetup
Dumb Services in Smart Nets - istio
Keep your projects up-to-date
Background processes and tasks in an async world
Make your Rails console AWESOME (Ruby SG meetup 2016-03-29)
Converting LotusScript Agents to Java Agents
Intro to elixir and phoenix
Building Real-Time Applications in Ember.js
2021laravelconftwslides6
WASM! WASI! WAGI! WAT?
CI/CD Using Ansible and Jenkins for Infrastructure
Npm Shrinkwrap
AWS CodeDeploy - basic intro
Progressively enhance your Symfony 4 app using Vue, API Platform, Mercure and...
Willian Martins - Back to the future of JS: the next features and amazing pro...
Test Failed, Then...
Puppet Camp Tokyo 2014: Why we stopped using Puppet Agent Daemon
Distributed and concurrent programming with RabbitMQ and EventMachine Rails U...
Ad

Similar to Exactly once delivery is a harsh mistress - DevOps Days TLV (20)

PDF
Exactly Once Delivery with Kafka - JOTB2020 Mini Session
PDF
Exactly Once Delivery with Kafka - Kafka Tel-Aviv Meetup
PPTX
Exactly Once Delivery - Natan Silnitsky
PDF
Polyglot, Fault Tolerant Event-Driven Programming with Kafka, Kubernetes and ...
PDF
Polyglot, fault-tolerant event-driven programming with kafka, kubernetes and ...
PDF
Polyglot, fault-tolerant event-driven programming with kafka, kubernetes and ...
PDF
10 Lessons Learned from using Kafka with 1000 microservices - java global summit
PDF
8 Lessons Learned from Using Kafka in 1000 Scala microservices - Scale by the...
PDF
8 Lessons Learned from Using Kafka in 1500 microservices - confluent streamin...
PDF
10 Lessons Learned from using Kafka in 1000 microservices - ScalaUA
PDF
How to build 1000 microservices with Kafka and thrive
PDF
Migrating to Multi Cluster Managed Kafka - ApacheKafkaIL
PPT
Apache Kafka Reliability Guarantees StrataHadoop NYC 2015
PPT
Kafka Reliability - When it absolutely, positively has to be there
PDF
Apache Kafka – (Pattern and) Anti-Pattern
PDF
Battle Tested Event-Driven Patterns for your Microservices Architecture
PDF
Battle Tested Event-Driven Patterns for your Microservices Architecture - Ris...
PPTX
Matt Franklin - Apache Software (Geekfest)
PDF
Battle Tested Event-Driven Patterns for your Microservices Architecture - Dev...
PDF
Your Goat Antifragiled My Snowflake!: Demystifying DevOps Jargon - ChefConf 2015
Exactly Once Delivery with Kafka - JOTB2020 Mini Session
Exactly Once Delivery with Kafka - Kafka Tel-Aviv Meetup
Exactly Once Delivery - Natan Silnitsky
Polyglot, Fault Tolerant Event-Driven Programming with Kafka, Kubernetes and ...
Polyglot, fault-tolerant event-driven programming with kafka, kubernetes and ...
Polyglot, fault-tolerant event-driven programming with kafka, kubernetes and ...
10 Lessons Learned from using Kafka with 1000 microservices - java global summit
8 Lessons Learned from Using Kafka in 1000 Scala microservices - Scale by the...
8 Lessons Learned from Using Kafka in 1500 microservices - confluent streamin...
10 Lessons Learned from using Kafka in 1000 microservices - ScalaUA
How to build 1000 microservices with Kafka and thrive
Migrating to Multi Cluster Managed Kafka - ApacheKafkaIL
Apache Kafka Reliability Guarantees StrataHadoop NYC 2015
Kafka Reliability - When it absolutely, positively has to be there
Apache Kafka – (Pattern and) Anti-Pattern
Battle Tested Event-Driven Patterns for your Microservices Architecture
Battle Tested Event-Driven Patterns for your Microservices Architecture - Ris...
Matt Franklin - Apache Software (Geekfest)
Battle Tested Event-Driven Patterns for your Microservices Architecture - Dev...
Your Goat Antifragiled My Snowflake!: Demystifying DevOps Jargon - ChefConf 2015
Ad

More from Natan Silnitsky (20)

PDF
Async-ronizing Success at Wix - Patterns for Seamless Microservices - Devoxx ...
PDF
Integration Ignited Redefining Event-Driven Architecture at Wix - EventCentric
PDF
Reinventing Microservices Efficiency and Innovation with Single-Runtime
PDF
Async Excellence Unlocking Scalability with Kafka - Devoxx Greece
PDF
Wix Single-Runtime - Conquering the multi-service challenge
PDF
WeAreDevs - Supercharge Your Developer Journey with Tiny Atomic Habits
PDF
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
PDF
Effective Strategies for Wix's Scaling challenges - GeeCon
PDF
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
PDF
Workflow Engines & Event Streaming Brokers - Can they work together? [Current...
PDF
DevSum - Lessons Learned from 2000 microservices
PDF
GeeCon - Lessons Learned from 2000 microservices
PDF
Wix+Confluent Meetup - Lessons Learned from 2000 Event Driven Microservices
PDF
BuildStuff - Lessons Learned from 2000 Event Driven Microservices
PDF
Lessons Learned from 2000 Event Driven Microservices - Reversim
PDF
Devoxx Ukraine - Kafka based Global Data Mesh
PDF
Devoxx UK - Migrating to Multi Cluster Managed Kafka
PDF
Dev Days Europe - Kafka based Global Data Mesh at Wix
PDF
Kafka Summit London - Kafka based Global Data Mesh at Wix
PDF
Migrating to Multi Cluster Managed Kafka - Conf42 - CloudNative
Async-ronizing Success at Wix - Patterns for Seamless Microservices - Devoxx ...
Integration Ignited Redefining Event-Driven Architecture at Wix - EventCentric
Reinventing Microservices Efficiency and Innovation with Single-Runtime
Async Excellence Unlocking Scalability with Kafka - Devoxx Greece
Wix Single-Runtime - Conquering the multi-service challenge
WeAreDevs - Supercharge Your Developer Journey with Tiny Atomic Habits
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Effective Strategies for Wix's Scaling challenges - GeeCon
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Workflow Engines & Event Streaming Brokers - Can they work together? [Current...
DevSum - Lessons Learned from 2000 microservices
GeeCon - Lessons Learned from 2000 microservices
Wix+Confluent Meetup - Lessons Learned from 2000 Event Driven Microservices
BuildStuff - Lessons Learned from 2000 Event Driven Microservices
Lessons Learned from 2000 Event Driven Microservices - Reversim
Devoxx Ukraine - Kafka based Global Data Mesh
Devoxx UK - Migrating to Multi Cluster Managed Kafka
Dev Days Europe - Kafka based Global Data Mesh at Wix
Kafka Summit London - Kafka based Global Data Mesh at Wix
Migrating to Multi Cluster Managed Kafka - Conf42 - CloudNative

Recently uploaded (20)

PPTX
MicrosoftCybserSecurityReferenceArchitecture-April-2025.pptx
PPTX
Benefits of Physical activity for teenagers.pptx
PDF
Convolutional neural network based encoder-decoder for efficient real-time ob...
PDF
From MVP to Full-Scale Product A Startup’s Software Journey.pdf
PDF
A review of recent deep learning applications in wood surface defect identifi...
PDF
NewMind AI Weekly Chronicles – August ’25 Week III
PPTX
2018-HIPAA-Renewal-Training for executives
PDF
Credit Without Borders: AI and Financial Inclusion in Bangladesh
PDF
Two-dimensional Klein-Gordon and Sine-Gordon numerical solutions based on dee...
PDF
Produktkatalog für HOBO Datenlogger, Wetterstationen, Sensoren, Software und ...
PPTX
The various Industrial Revolutions .pptx
PPTX
Custom Battery Pack Design Considerations for Performance and Safety
PDF
TrustArc Webinar - Click, Consent, Trust: Winning the Privacy Game
DOCX
search engine optimization ppt fir known well about this
PDF
Hindi spoken digit analysis for native and non-native speakers
PPTX
Final SEM Unit 1 for mit wpu at pune .pptx
PDF
How ambidextrous entrepreneurial leaders react to the artificial intelligence...
PPTX
Modernising the Digital Integration Hub
PDF
Abstractive summarization using multilingual text-to-text transfer transforme...
PPTX
AI IN MARKETING- PRESENTED BY ANWAR KABIR 1st June 2025.pptx
MicrosoftCybserSecurityReferenceArchitecture-April-2025.pptx
Benefits of Physical activity for teenagers.pptx
Convolutional neural network based encoder-decoder for efficient real-time ob...
From MVP to Full-Scale Product A Startup’s Software Journey.pdf
A review of recent deep learning applications in wood surface defect identifi...
NewMind AI Weekly Chronicles – August ’25 Week III
2018-HIPAA-Renewal-Training for executives
Credit Without Borders: AI and Financial Inclusion in Bangladesh
Two-dimensional Klein-Gordon and Sine-Gordon numerical solutions based on dee...
Produktkatalog für HOBO Datenlogger, Wetterstationen, Sensoren, Software und ...
The various Industrial Revolutions .pptx
Custom Battery Pack Design Considerations for Performance and Safety
TrustArc Webinar - Click, Consent, Trust: Winning the Privacy Game
search engine optimization ppt fir known well about this
Hindi spoken digit analysis for native and non-native speakers
Final SEM Unit 1 for mit wpu at pune .pptx
How ambidextrous entrepreneurial leaders react to the artificial intelligence...
Modernising the Digital Integration Hub
Abstractive summarization using multilingual text-to-text transfer transforme...
AI IN MARKETING- PRESENTED BY ANWAR KABIR 1st June 2025.pptx

Exactly once delivery is a harsh mistress - DevOps Days TLV