SlideShare a Scribd company logo
Iago Borges
Maintaining Consistency for a Financial Event-Driven Architecture (Iago Borges, Nubank) Kafka Summit NYC 2019
Who are we?
Active credit card customers Active digital checking accounts
Employees Engineers
Maintaining Consistency for a Financial Event-Driven Architecture (Iago Borges, Nubank) Kafka Summit NYC 2019
Why is it so important?
That's why
Auditing
How to define
consistency?
Whenever an event happens, the entire
world must be eventually in a state where
the event happened exactly once.
Not zero times, not more than once,
exactly once.
Good eventual consistency is good
enough
Anti-corruption
layer
Brazilian
payment
system
Payments
manager
Line ItemsBalance sheet
Financing
HTTP
S3
Kafka
AWS S3FTP
Payment file arrived
NEW PAYMENT
Writes payments
file
Fetches payments file
Gets purchases, payments
and etc
Posts requesting a
financing
Gets
balance
Anti-corruption
layer
Brazilian
payment
system
Payments
manager
Line ItemsBalance sheet
Financing
HTTP
S3
Kafka
AWS S3FTP
Payment file arrived
NEW PAYMENT
Writes payments
file
Fetches payments file
Gets purchases, payments
and etc
Posts requesting a
financing
Gets
balance
Impact of performance on
consistency of asynchronous
data flows
Whenever an event happens, the entire
world must eventually be in a state where
the event happened exactly once.
Not zero times, not more than once,
exactly once.
"Anything that can go wrong
will go wrong"
Anti-corruption
layer
Brazilian
payment
system
Payments
manager
Line ItemsBalance sheet
Financing
HTTP
S3
Kafka
AWS S3FTP
Payment file arrived
NEW PAYMENT
Writes payments
file
Fetches payments file
Gets purchases, payments
and etc
Posts requesting a
financing
Gets
balance
Anti-corruption
layer
Brazilian
payment
system
Payments
manager
Line ItemsBalance sheet
Financing
HTTP
S3
Kafka
AWS S3FTP
Payment file arrived
NEW PAYMENT
Writes payments
file
Fetches payments file
Gets purchases, payments
and etc
Posts requesting a
financing
Gets
balance
Impact of availability on
consistency of asynchronous
data flows
Maybe we just retry it until it works?
● Processing will be stuck.
● Hard to configure properly.
● Very hard observability.
Anti-corruption
layer
Brazilian
payment
system
Payments
manager
Line ItemsBalance sheet
Financing
HTTP
S3
Kafka
AWS S3FTP
Payment file arrived
NEW PAYMENT
Writes payments
file
Fetches payments file
Gets purchases, payments
and etc
Posts requesting a
financing
Gets
balance
Dead letter
queue
Anti-corruption layer
Brazilian payment
system
Payments manager
Line ItemsBalance sheet
Financing
HTTP
S3
Kafka
AWS S3
FTP
PAYMENT FILE
ARRIVED
NEW PAYMENT
Writes payments file
Fetches payments file
Gets purchases,
payments and etc
Posts requesting a financing
Gets balance
How about this?
Dead letter queue
Dead letters queue!!
● Fluid processing, regardless of
failures.
● Great observability.
● Simpler configuration.
● One solution to rule them all.
How do we dead letter?
How do we dead letter?
Random Service 2
Random Service 1
RANDOM
EVENT TOPIC
Mortician
Produces to
deadletter topic
when an error is
encountered
AWS S3
Database
DB references S3
Original message
is replayed after
problem is fixed
HTTP
The event is successfully
propagated downstream
No events lost
How do we make a good
experience out of it?
How do we make a good
experience out of it?
How do we make a good
experience out of it?
So, would we keep killing letters non stop?
Random Service 1
Random Service 2 Dead letter queue
Service is failing
multiple times
Overloaded DB
Doing a bunch of
requests, overloading
the database even
more
Producing a bunch of
dead letters
Circuit breakers
● Protects your systems from DDOSing
each other
● Once a lot of errors start happening it
realises something is wrong and stop
processing requests
● Probes eventually to know if things
got back
● Self recovery
Circuit breakers
Random Service 1
Failing service Dead letter queue
Start throwing errors without even
processing after multiple errors
Overloaded DB
Give some rest for
the database to
recover
Stop sending
unnecessary dead
letters
Circuit breaker
Circuit breakers
Random Service 1
Failing service Dead letter queue
Start working normally
again once errors stop
happening
Overloaded DB
Give some rest for
the database to
recover
No need for
deadletters nowCircuit
breaker
Whenever an event happens, the world
must be eventually in a state where the
event happened exactly once.
Not zero times, not more than once,
exactly once.
"The night is dark and full of retries"
As it should
Idempotence
"Every event shall be idempotent"
Nubank Engineers, circa 2014
Datomic
● Serial writes
● Immutable
● Fact based. No fact is deleted or changed
● You can force to be in a specific state in time
Idempotence
Random Service 1 Random Service 2
Sends event X Processes and
persists event X
Query: does it exists?
No
DB
Writes
Idempotence
Random Service 1 Random Service 2
Sends the same event X
again
Processes the same
event X again
Query: does it exists?
Yes, it has just been
written, right??
DB
Doesn't write, because
the query returned it
already exists, right??
Idempotence
Random Service 1 Random Service 2
Sends the same event X
again
Processes the same
event X again
Query: does it exists?
Yes, it has just been
written, right??
DB
Doesn't write, because
the query returned it
already exists, right??
Well… Maybe...
Idempotence
Random Service 1 Random Service 2
Publishes duplicated
events with uniquely
identifiable ID
Processes duplicated
event
DB
Attempts to write
duplicate record,
encounters unique ID
conflict and throws
exception
Because it's serial!
Finagle
● Response classification
● Retry behavior
● Timeouts
● Load balancing
● Circuit breakers (fail accrual, fail fast, threshold fail
detector)
● Connection pooling
What we have learned
about consistency
● Clients expect companies to consistently take care
of their money
● Errors will happen and they're not so bad, embrace
and treat them well.
● Everything should be idempotent.
● Keeping things working well is awesome! (ORLY??)

More Related Content

PDF
Scaling a Core Banking Engine Using Apache Kafka | Peter Dudbridge, Thought M...
PPTX
OpenStack Introduction
PPTX
Relational databases vs Non-relational databases
PPTX
A Deep Dive Into Understanding Apache Cassandra
PDF
Introduction to Machine Learning with Spark
PPTX
Introduction to HiveQL
PDF
Best Practices for ETL with Apache NiFi on Kubernetes - Albert Lewandowski, G...
Scaling a Core Banking Engine Using Apache Kafka | Peter Dudbridge, Thought M...
OpenStack Introduction
Relational databases vs Non-relational databases
A Deep Dive Into Understanding Apache Cassandra
Introduction to Machine Learning with Spark
Introduction to HiveQL
Best Practices for ETL with Apache NiFi on Kubernetes - Albert Lewandowski, G...

What's hot (20)

PDF
DBaaS- Database as a Service in a DBAs World
PDF
Using ClickHouse for Experimentation
PPT
Evolution of the cloud
PDF
Cassandra Introduction & Features
PDF
Apache Kafka Architecture & Fundamentals Explained
PPT
Distributed computing
PPTX
Serverless computing
PPTX
From cache to in-memory data grid. Introduction to Hazelcast.
PDF
Opentracing jaeger
PDF
[Meetup] a successful migration from elastic search to clickhouse
PPTX
Sprinting with Anypoint Runtime Fabric
PPTX
Introducing Azure SQL Database
PPTX
Introduction to data warehousing
PPTX
Application Timeline Server - Past, Present and Future
PPTX
Query Optimization in MongoDB
PPTX
Virtualization & cloud computing
PDF
Best Practices in the Use of Columnar Databases
PPTX
Caching
PPT
Ch3 5 v1
PDF
Big Data Ecosystem
DBaaS- Database as a Service in a DBAs World
Using ClickHouse for Experimentation
Evolution of the cloud
Cassandra Introduction & Features
Apache Kafka Architecture & Fundamentals Explained
Distributed computing
Serverless computing
From cache to in-memory data grid. Introduction to Hazelcast.
Opentracing jaeger
[Meetup] a successful migration from elastic search to clickhouse
Sprinting with Anypoint Runtime Fabric
Introducing Azure SQL Database
Introduction to data warehousing
Application Timeline Server - Past, Present and Future
Query Optimization in MongoDB
Virtualization & cloud computing
Best Practices in the Use of Columnar Databases
Caching
Ch3 5 v1
Big Data Ecosystem
Ad

Similar to Maintaining Consistency for a Financial Event-Driven Architecture (Iago Borges, Nubank) Kafka Summit NYC 2019 (20)

PPTX
Spring I_O 2024 - Flexible Spring with Event Sourcing.pptx
PDF
Teach Your Sites to Call for Help: Automated Problem Reporting for Online Ser...
PDF
mri-bp2015
PDF
Building Microservices with Event Sourcing and CQRS
PDF
[Meetup ms] Kafka Streams
PDF
TLV Data Plumbers: Exactly once processing
PPTX
"Final fsFighting Complex Application State Management with Finite-State Mach...
PDF
Event Sourcing, Stream Processing and Serverless (Benjamin Stopford, Confluen...
PDF
No estimates
KEY
Rate Limiting at Scale, from SANS AppSec Las Vegas 2012
PDF
PlayStation and Lucene - Indexing 1M documents per second: Presented by Alexa...
PDF
Server-Sent Events (real-time HTTP push for HTML5 browsers)
PDF
PPTX
Social Analytics on MongoDB at MongoNYC
PDF
Event Sourcing: Introduction & Challenges
PDF
Moved to https://slidr.io/azzazzel/web-application-performance-tuning-beyond-xmx
PDF
Event Sourcing, Stream Processing and Serverless (Ben Stopford, Confluent) K...
PDF
Erlang as a Cloud Citizen
PDF
Erlang and the Cloud: A Fractal Approach to Throughput
PDF
Erlang as a cloud citizen, a fractal approach to throughput
Spring I_O 2024 - Flexible Spring with Event Sourcing.pptx
Teach Your Sites to Call for Help: Automated Problem Reporting for Online Ser...
mri-bp2015
Building Microservices with Event Sourcing and CQRS
[Meetup ms] Kafka Streams
TLV Data Plumbers: Exactly once processing
"Final fsFighting Complex Application State Management with Finite-State Mach...
Event Sourcing, Stream Processing and Serverless (Benjamin Stopford, Confluen...
No estimates
Rate Limiting at Scale, from SANS AppSec Las Vegas 2012
PlayStation and Lucene - Indexing 1M documents per second: Presented by Alexa...
Server-Sent Events (real-time HTTP push for HTML5 browsers)
Social Analytics on MongoDB at MongoNYC
Event Sourcing: Introduction & Challenges
Moved to https://slidr.io/azzazzel/web-application-performance-tuning-beyond-xmx
Event Sourcing, Stream Processing and Serverless (Ben Stopford, Confluent) K...
Erlang as a Cloud Citizen
Erlang and the Cloud: A Fractal Approach to Throughput
Erlang as a cloud citizen, a fractal approach to throughput
Ad

More from confluent (20)

PDF
Stream Processing Handson Workshop - Flink SQL Hands-on Workshop (Korean)
PPTX
Webinar Think Right - Shift Left - 19-03-2025.pptx
PDF
Migration, backup and restore made easy using Kannika
PDF
Five Things You Need to Know About Data Streaming in 2025
PDF
Data in Motion Tour Seoul 2024 - Keynote
PDF
Data in Motion Tour Seoul 2024 - Roadmap Demo
PDF
From Stream to Screen: Real-Time Data Streaming to Web Frontends with Conflue...
PDF
Confluent per il settore FSI: Accelerare l'Innovazione con il Data Streaming...
PDF
Data in Motion Tour 2024 Riyadh, Saudi Arabia
PDF
Build a Real-Time Decision Support Application for Financial Market Traders w...
PDF
Strumenti e Strategie di Stream Governance con Confluent Platform
PDF
Compose Gen-AI Apps With Real-Time Data - In Minutes, Not Weeks
PDF
Building Real-Time Gen AI Applications with SingleStore and Confluent
PDF
Unlocking value with event-driven architecture by Confluent
PDF
Il Data Streaming per un’AI real-time di nuova generazione
PDF
Unleashing the Future: Building a Scalable and Up-to-Date GenAI Chatbot with ...
PDF
Break data silos with real-time connectivity using Confluent Cloud Connectors
PDF
Building API data products on top of your real-time data infrastructure
PDF
Speed Wins: From Kafka to APIs in Minutes
PDF
Evolving Data Governance for the Real-time Streaming and AI Era
Stream Processing Handson Workshop - Flink SQL Hands-on Workshop (Korean)
Webinar Think Right - Shift Left - 19-03-2025.pptx
Migration, backup and restore made easy using Kannika
Five Things You Need to Know About Data Streaming in 2025
Data in Motion Tour Seoul 2024 - Keynote
Data in Motion Tour Seoul 2024 - Roadmap Demo
From Stream to Screen: Real-Time Data Streaming to Web Frontends with Conflue...
Confluent per il settore FSI: Accelerare l'Innovazione con il Data Streaming...
Data in Motion Tour 2024 Riyadh, Saudi Arabia
Build a Real-Time Decision Support Application for Financial Market Traders w...
Strumenti e Strategie di Stream Governance con Confluent Platform
Compose Gen-AI Apps With Real-Time Data - In Minutes, Not Weeks
Building Real-Time Gen AI Applications with SingleStore and Confluent
Unlocking value with event-driven architecture by Confluent
Il Data Streaming per un’AI real-time di nuova generazione
Unleashing the Future: Building a Scalable and Up-to-Date GenAI Chatbot with ...
Break data silos with real-time connectivity using Confluent Cloud Connectors
Building API data products on top of your real-time data infrastructure
Speed Wins: From Kafka to APIs in Minutes
Evolving Data Governance for the Real-time Streaming and AI Era

Recently uploaded (20)

PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
CIFDAQ's Market Insight: SEC Turns Pro Crypto
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Electronic commerce courselecture one. Pdf
PPT
Teaching material agriculture food technology
PDF
cuic standard and advanced reporting.pdf
PDF
Spectral efficient network and resource selection model in 5G networks
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
NewMind AI Monthly Chronicles - July 2025
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Encapsulation theory and applications.pdf
PDF
KodekX | Application Modernization Development
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
CIFDAQ's Market Insight: SEC Turns Pro Crypto
“AI and Expert System Decision Support & Business Intelligence Systems”
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Electronic commerce courselecture one. Pdf
Teaching material agriculture food technology
cuic standard and advanced reporting.pdf
Spectral efficient network and resource selection model in 5G networks
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Reach Out and Touch Someone: Haptics and Empathic Computing
Encapsulation_ Review paper, used for researhc scholars
NewMind AI Monthly Chronicles - July 2025
Per capita expenditure prediction using model stacking based on satellite ima...
Understanding_Digital_Forensics_Presentation.pptx
Digital-Transformation-Roadmap-for-Companies.pptx
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Encapsulation theory and applications.pdf
KodekX | Application Modernization Development
Dropbox Q2 2025 Financial Results & Investor Presentation

Maintaining Consistency for a Financial Event-Driven Architecture (Iago Borges, Nubank) Kafka Summit NYC 2019