SlideShare a Scribd company logo
© 2019 Bloomberg Finance L.P. All rights reserved.
© 2019 Bloomberg Finance L.P. All rights reserved.
The Power of Event-Driven
Caches
Why caching is hard, and what you can do about it.
Kafka Summit London
May 13, 2019
Brendan Powers
Software Engineer
@brendan0powers
© 2019 Bloomberg Finance L.P. All rights reserved.
© 2019 Bloomberg Finance L.P. All rights reserved.
Who am I?
© 2019 Bloomberg Finance L.P. All rights reserved.
© 2019 Bloomberg Finance L.P. All rights reserved.
There are only two hard things in Computer Science:
cache invalidation and naming things.
-- Phil Karlton
© 2019 Bloomberg Finance L.P. All rights reserved.
© 2019 Bloomberg Finance L.P. All rights reserved.
Database Access
App DB
© 2019 Bloomberg Finance L.P. All rights reserved.
© 2019 Bloomberg Finance L.P. All rights reserved.
Cache Access Patterns
App
Cache
DB
© 2019 Bloomberg Finance L.P. All rights reserved.
© 2019 Bloomberg Finance L.P. All rights reserved.
“Thundering Herd” Problem
DBApp
Cache
© 2019 Bloomberg Finance L.P. All rights reserved.
© 2019 Bloomberg Finance L.P. All rights reserved.
“Thundering Herd” Problem
DB
© 2019 Bloomberg Finance L.P. All rights reserved.
© 2019 Bloomberg Finance L.P. All rights reserved.
“Thundering Herd” Problem
© 2019 Bloomberg Finance L.P. All rights reserved.
© 2019 Bloomberg Finance L.P. All rights reserved.
Concurrency
App App
?
Cache
© 2019 Bloomberg Finance L.P. All rights reserved.
© 2019 Bloomberg Finance L.P. All rights reserved.
Is the Data in My Cache Valid?
DBApp
Cache
???
© 2019 Bloomberg Finance L.P. All rights reserved.
© 2019 Bloomberg Finance L.P. All rights reserved.
Is the Data in My Cache Valid?
?? ?
© 2019 Bloomberg Finance L.P. All rights reserved.
© 2019 Bloomberg Finance L.P. All rights reserved.
Your Database is the Source of Truth
DB
© 2019 Bloomberg Finance L.P. All rights reserved.
© 2019 Bloomberg Finance L.P. All rights reserved.
Push Writes to the DB into the Cache
Cache
DB
© 2019 Bloomberg Finance L.P. All rights reserved.
© 2019 Bloomberg Finance L.P. All rights reserved.
Revised Architecture Diagram
Cache
App DB
© 2019 Bloomberg Finance L.P. All rights reserved.
© 2019 Bloomberg Finance L.P. All rights reserved.
Cache Instances are Consistent
DB
Cache
Cache
Cache
© 2019 Bloomberg Finance L.P. All rights reserved.
© 2019 Bloomberg Finance L.P. All rights reserved.
How do I get Change Notification from my DB?
Cach
e DB
© 2019 Bloomberg Finance L.P. All rights reserved.
© 2019 Bloomberg Finance L.P. All rights reserved.
Dual Writes
App
DB
Cache Kafka
© 2019 Bloomberg Finance L.P. All rights reserved.
© 2019 Bloomberg Finance L.P. All rights reserved.
Keep the Number of Write Paths Small
!
DB
Cache Kafka
© 2019 Bloomberg Finance L.P. All rights reserved.
© 2019 Bloomberg Finance L.P. All rights reserved.
Dealing With Partial Write Failure
DB
App
Cache Kafka
© 2019 Bloomberg Finance L.P. All rights reserved.
© 2019 Bloomberg Finance L.P. All rights reserved.
Change Data Capture (CDC)
DB App
Write Log
© 2019 Bloomberg Finance L.P. All rights reserved.
© 2019 Bloomberg Finance L.P. All rights reserved.
Change Data Capture (CDC)
DB
Write LogCache Kafka
App
© 2019 Bloomberg Finance L.P. All rights reserved.
© 2019 Bloomberg Finance L.P. All rights reserved.
Why Kafka?
● Durable
● Scalable
● Debuggable
© 2019 Bloomberg Finance L.P. All rights reserved.
© 2019 Bloomberg Finance L.P. All rights reserved.
Kafka’s Topic Offset Tracking
98765
DB
Cache
4321
© 2019 Bloomberg Finance L.P. All rights reserved.
© 2019 Bloomberg Finance L.P. All rights reserved.
Too Complicated?
Cache
App DB
© 2019 Bloomberg Finance L.P. All rights reserved.
© 2019 Bloomberg Finance L.P. All rights reserved.
Too Complicated?
DB
Cache
App
© 2019 Bloomberg Finance L.P. All rights reserved.
© 2019 Bloomberg Finance L.P. All rights reserved.
Recent Writes
User 1User 2User 1User 3User 2
© 2019 Bloomberg Finance L.P. All rights reserved.
© 2019 Bloomberg Finance L.P. All rights reserved.
Kafka Never Forgets...
. . . User 1User 2User 1User 3User 2
© 2019 Bloomberg Finance L.P. All rights reserved.
© 2019 Bloomberg Finance L.P. All rights reserved.
Kafka Never Forgets...
User 1User 2User 1User 3User 2
© 2019 Bloomberg Finance L.P. All rights reserved.
© 2019 Bloomberg Finance L.P. All rights reserved.
Kafka Never Forgets...
User 1
User 2
User 1
User 3User 2
© 2019 Bloomberg Finance L.P. All rights reserved.
© 2019 Bloomberg Finance L.P. All rights reserved.
Kafka Never Forgets...
User 1
User 2
User 1
User 3
User 2
© 2019 Bloomberg Finance L.P. All rights reserved.
© 2019 Bloomberg Finance L.P. All rights reserved.
Kafka Never Forgets...
User 2
User 1
User 3
User 2
© 2019 Bloomberg Finance L.P. All rights reserved.
© 2019 Bloomberg Finance L.P. All rights reserved.
Kafka Never Forgets...
User 1
User 3
User 2
© 2019 Bloomberg Finance L.P. All rights reserved.
© 2019 Bloomberg Finance L.P. All rights reserved.
Kafka Never Forgets...
User 1User 3User 2
© 2019 Bloomberg Finance L.P. All rights reserved.
© 2019 Bloomberg Finance L.P. All rights reserved.
Full Records
User 1{
“Id”: 492343,
“name”: “User 1”,
“Date_joined”, “05/05/1995”,
…...
}
User 2
© 2019 Bloomberg Finance L.P. All rights reserved.
© 2019 Bloomberg Finance L.P. All rights reserved.
DB
© 2019 Bloomberg Finance L.P. All rights reserved.
© 2019 Bloomberg Finance L.P. All rights reserved.
Cache
© 2019 Bloomberg Finance L.P. All rights reserved.
© 2019 Bloomberg Finance L.P. All rights reserved.
Cache
DB
© 2019 Bloomberg Finance L.P. All rights reserved.
© 2019 Bloomberg Finance L.P. All rights reserved.
Simplifying Our Design
DB
Cache
App
© 2019 Bloomberg Finance L.P. All rights reserved.
© 2019 Bloomberg Finance L.P. All rights reserved.
Simplifying Our Design
Cache
App DB
© 2019 Bloomberg Finance L.P. All rights reserved.
© 2019 Bloomberg Finance L.P. All rights reserved.
Fault Tolerant
Cache
App
© 2019 Bloomberg Finance L.P. All rights reserved.
© 2019 Bloomberg Finance L.P. All rights reserved.
“Thundering Herd” Problem
© 2019 Bloomberg Finance L.P. All rights reserved.
© 2019 Bloomberg Finance L.P. All rights reserved.
“Thundering Herd” Problem
DB
© 2019 Bloomberg Finance L.P. All rights reserved.
© 2019 Bloomberg Finance L.P. All rights reserved.
Scale Independence
DB
Cache
Cache
Cache Cache
Cache
© 2019 Bloomberg Finance L.P. All rights reserved.
© 2019 Bloomberg Finance L.P. All rights reserved.
More Sleep, Less Phone Calls
App
Cache
DB
© 2019 Bloomberg Finance L.P. All rights reserved.
© 2019 Bloomberg Finance L.P. All rights reserved.
When to Use This Technique
● When your cache needs to be up to date
● When latency is very important
● When you need to give clients flexibility in their caching strategy
© 2019 Bloomberg Finance L.P. All rights reserved.
© 2019 Bloomberg Finance L.P. All rights reserved.
When NOT to Use This Technique
● When your data rarely changes
● When you data size is very large (100s of GB or TB)
© 2019 Bloomberg Finance L.P. All rights reserved.
© 2019 Bloomberg Finance L.P. All rights reserved.
How?
Cache
?
© 2019 Bloomberg Finance L.P. All rights reserved.
© 2019 Bloomberg Finance L.P. All rights reserved.
Store the Kafka Topic in a Hash Table
[ ]Cache
© 2019 Bloomberg Finance L.P. All rights reserved.
© 2019 Bloomberg Finance L.P. All rights reserved.
In RAM Inside Your Application
[ ]Cache
© 2019 Bloomberg Finance L.P. All rights reserved.
© 2019 Bloomberg Finance L.P. All rights reserved.
Too Big for RAM? Store it on Disk
App
[ ]Cache
© 2019 Bloomberg Finance L.P. All rights reserved.
© 2019 Bloomberg Finance L.P. All rights reserved.
A Cache in Every Instance
[ ]Cache
[ ]Cache
[ ]Cache
© 2019 Bloomberg Finance L.P. All rights reserved.
© 2019 Bloomberg Finance L.P. All rights reserved.
Out of Process Cache
App App App
[ ]Cache
© 2019 Bloomberg Finance L.P. All rights reserved.
© 2019 Bloomberg Finance L.P. All rights reserved.
[ ]Cache
© 2019 Bloomberg Finance L.P. All rights reserved.
© 2019 Bloomberg Finance L.P. All rights reserved.
CACHE!
© 2019 Bloomberg Finance L.P. All rights reserved.
Shard Your Data
A-I J-R S-Z
[ ]Cache
[ ]Cache
[ ]Cache
© 2019 Bloomberg Finance L.P. All rights reserved.
© 2019 Bloomberg Finance L.P. All rights reserved.
How Does the Application Find its Data?
App
[ ]Cache
[ ]Cache
[ ]Cache
© 2019 Bloomberg Finance L.P. All rights reserved.
© 2019 Bloomberg Finance L.P. All rights reserved.
There are only two hard things in Computer Science:
cache invalidation and naming things.
-- Phil Karlton
© 2019 Bloomberg Finance L.P. All rights reserved.
© 2019 Bloomberg Finance L.P. All rights reserved.
Questions?
© 2019 Bloomberg Finance L.P. All rights reserved.
© 2019 Bloomberg Finance L.P. All rights reserved.
Kafka Connectors
● Debezium
● JDBC
● Dedicated connectors for MS SQL, Oracle, etc.
© 2019 Bloomberg Finance L.P. All rights reserved.
© 2019 Bloomberg Finance L.P. All rights reserved.
Will My Data Fit in RAM?
● How much RAM do you have?
● How big are your records?
● Do you have to cache the entire record?
© 2019 Bloomberg Finance L.P. All rights reserved.
© 2019 Bloomberg Finance L.P. All rights reserved.
Caches can Forward Requests
[ ]Cache
[ ]Cache
[ ]Cache
App
© 2019 Bloomberg Finance L.P. All rights reserved.
© 2019 Bloomberg Finance L.P. All rights reserved.
Use a Proxy
AppProxy
[ ]Cache
[ ]Cache
[ ]Cache
© 2019 Bloomberg Finance L.P. All rights reserved.
© 2019 Bloomberg Finance L.P. All rights reserved.
© 2019 Bloomberg Finance L.P. All rights reserved.
© 2019 Bloomberg Finance L.P. All rights reserved.
[ ]
© 2019 Bloomberg Finance L.P. All rights reserved.
© 2019 Bloomberg Finance L.P. All rights reserved.
[ ]
[ ] [ ]
© 2019 Bloomberg Finance L.P. All rights reserved.
© 2019 Bloomberg Finance L.P. All rights reserved.
[ ]
[ ] [ ]
?
© 2019 Bloomberg Finance L.P. All rights reserved.
© 2019 Bloomberg Finance L.P. All rights reserved.
[ ]
© 2019 Bloomberg Finance L.P. All rights reserved.
© 2019 Bloomberg Finance L.P. All rights reserved.
[ ]
[ ]
[ ]

More Related Content

PDF
Kubernetes Apache Kafka
PDF
Fast Kafka Apps! (Edoardo Comar and Mickael Maison, IBM) Kafka Summit London ...
PDF
Building Serverless Apps with Kafka (Dale Lane, IBM) Kafka Summit London 2019
PDF
hello-streams :: Introducing the Stream First Mindset (Rene Parra, Homeaway) ...
PDF
Not so FaaS, Streaming ML with Kafka! (Praveen Hirsave, VRBO) Kafka Summit Lo...
PDF
Running Kafka in Kubernetes: A Practical Guide (Katherine Stanley, IBM United...
PDF
Cloud-native Event-driven Data Ecosystem Powered by Kafka and Akka (Masih Der...
PDF
Building and Evolving a Dependency-Graph Based Microservice Architecture (La...
Kubernetes Apache Kafka
Fast Kafka Apps! (Edoardo Comar and Mickael Maison, IBM) Kafka Summit London ...
Building Serverless Apps with Kafka (Dale Lane, IBM) Kafka Summit London 2019
hello-streams :: Introducing the Stream First Mindset (Rene Parra, Homeaway) ...
Not so FaaS, Streaming ML with Kafka! (Praveen Hirsave, VRBO) Kafka Summit Lo...
Running Kafka in Kubernetes: A Practical Guide (Katherine Stanley, IBM United...
Cloud-native Event-driven Data Ecosystem Powered by Kafka and Akka (Masih Der...
Building and Evolving a Dependency-Graph Based Microservice Architecture (La...

What's hot (8)

PDF
Scaling Apache Pulsar to 10 PB/day
PDF
Services are the New Cloud Platform (Services-as-a-Platform)
PPTX
AWS DevDay Cologne - Automating building blocks choices you will face with co...
PPTX
Kafka Summit 2019 Microservice Orchestration
PDF
Amazon Elastic Fabric Adapter: Anatomy, Capabilities, and the Road Ahead
PPTX
AWS DevDay Cologne - Resiliency and availability design patterns for the cloud
PDF
Twelve-Factor App Methodology and Modern Applications | AWS Summit Tel Aviv 2019
PDF
Kafka summit apac session
Scaling Apache Pulsar to 10 PB/day
Services are the New Cloud Platform (Services-as-a-Platform)
AWS DevDay Cologne - Automating building blocks choices you will face with co...
Kafka Summit 2019 Microservice Orchestration
Amazon Elastic Fabric Adapter: Anatomy, Capabilities, and the Road Ahead
AWS DevDay Cologne - Resiliency and availability design patterns for the cloud
Twelve-Factor App Methodology and Modern Applications | AWS Summit Tel Aviv 2019
Kafka summit apac session
Ad

Similar to The Power of Event Driven Caches (Brendan Powers, Bloomberg L.P) Kafka Summit London 2019 (20)

PDF
HBaseConAsia2018 Track3-1: Serving billions of queries in millisecond latencies
PDF
Serving queries at low latency using HBase
PDF
Building a Data Subscription Service with Kafka Connect (Danica Fine & Ajay V...
PPTX
Cache Rules Everything Around Me - Momentum - October 2022.pptx
PDF
Why My Streaming Job is Slow - Profiling and Optimizing Kafka Streams Apps (L...
PDF
Don’t give up, You can... Cache!
PPTX
Cache Rules Everything Around Me - DevIntersection - December 2022
PPTX
CREAM - That Conference Austin - January 2024.pptx
PDF
Jonathan Ellis "Apache Cassandra 2.0 and 2.1". Выступление на Cassandra conf ...
PPTX
Selecting the right cache framework
PPTX
Webinar: How Financial Services Organizations Use MongoDB
PPTX
MongoDB in a Mainframe World
PDF
In-Memory Data Management Goes Mainstream - OpenSlava 2015
PDF
HBase Internals And Operations
PPTX
Data Caching Evolution - the SafePeak deck from webcast 2014-04-24
PPT
Database Systems
PDF
KScope14_MMalandra_200GB_diet
PDF
KScope14 200 GB Diet
PPTX
How data modelling helps serve billions of queries in millisecond latency wit...
KEY
Memcached: What is it and what does it do?
HBaseConAsia2018 Track3-1: Serving billions of queries in millisecond latencies
Serving queries at low latency using HBase
Building a Data Subscription Service with Kafka Connect (Danica Fine & Ajay V...
Cache Rules Everything Around Me - Momentum - October 2022.pptx
Why My Streaming Job is Slow - Profiling and Optimizing Kafka Streams Apps (L...
Don’t give up, You can... Cache!
Cache Rules Everything Around Me - DevIntersection - December 2022
CREAM - That Conference Austin - January 2024.pptx
Jonathan Ellis "Apache Cassandra 2.0 and 2.1". Выступление на Cassandra conf ...
Selecting the right cache framework
Webinar: How Financial Services Organizations Use MongoDB
MongoDB in a Mainframe World
In-Memory Data Management Goes Mainstream - OpenSlava 2015
HBase Internals And Operations
Data Caching Evolution - the SafePeak deck from webcast 2014-04-24
Database Systems
KScope14_MMalandra_200GB_diet
KScope14 200 GB Diet
How data modelling helps serve billions of queries in millisecond latency wit...
Memcached: What is it and what does it do?
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)

PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Spectral efficient network and resource selection model in 5G networks
PPTX
A Presentation on Artificial Intelligence
PDF
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
NewMind AI Monthly Chronicles - July 2025
DOCX
The AUB Centre for AI in Media Proposal.docx
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Electronic commerce courselecture one. Pdf
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
20250228 LYD VKU AI Blended-Learning.pptx
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Spectral efficient network and resource selection model in 5G networks
A Presentation on Artificial Intelligence
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
Understanding_Digital_Forensics_Presentation.pptx
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
The Rise and Fall of 3GPP – Time for a Sabbatical?
NewMind AI Monthly Chronicles - July 2025
The AUB Centre for AI in Media Proposal.docx
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Dropbox Q2 2025 Financial Results & Investor Presentation
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
Per capita expenditure prediction using model stacking based on satellite ima...
Electronic commerce courselecture one. Pdf
Digital-Transformation-Roadmap-for-Companies.pptx
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy

The Power of Event Driven Caches (Brendan Powers, Bloomberg L.P) Kafka Summit London 2019

  • 1. © 2019 Bloomberg Finance L.P. All rights reserved. © 2019 Bloomberg Finance L.P. All rights reserved. The Power of Event-Driven Caches Why caching is hard, and what you can do about it. Kafka Summit London May 13, 2019 Brendan Powers Software Engineer @brendan0powers
  • 2. © 2019 Bloomberg Finance L.P. All rights reserved. © 2019 Bloomberg Finance L.P. All rights reserved. Who am I?
  • 3. © 2019 Bloomberg Finance L.P. All rights reserved. © 2019 Bloomberg Finance L.P. All rights reserved. There are only two hard things in Computer Science: cache invalidation and naming things. -- Phil Karlton
  • 4. © 2019 Bloomberg Finance L.P. All rights reserved. © 2019 Bloomberg Finance L.P. All rights reserved. Database Access App DB
  • 5. © 2019 Bloomberg Finance L.P. All rights reserved. © 2019 Bloomberg Finance L.P. All rights reserved. Cache Access Patterns App Cache DB
  • 6. © 2019 Bloomberg Finance L.P. All rights reserved. © 2019 Bloomberg Finance L.P. All rights reserved. “Thundering Herd” Problem DBApp Cache
  • 7. © 2019 Bloomberg Finance L.P. All rights reserved. © 2019 Bloomberg Finance L.P. All rights reserved. “Thundering Herd” Problem DB
  • 8. © 2019 Bloomberg Finance L.P. All rights reserved. © 2019 Bloomberg Finance L.P. All rights reserved. “Thundering Herd” Problem
  • 9. © 2019 Bloomberg Finance L.P. All rights reserved. © 2019 Bloomberg Finance L.P. All rights reserved. Concurrency App App ? Cache
  • 10. © 2019 Bloomberg Finance L.P. All rights reserved. © 2019 Bloomberg Finance L.P. All rights reserved. Is the Data in My Cache Valid? DBApp Cache ???
  • 11. © 2019 Bloomberg Finance L.P. All rights reserved. © 2019 Bloomberg Finance L.P. All rights reserved. Is the Data in My Cache Valid? ?? ?
  • 12. © 2019 Bloomberg Finance L.P. All rights reserved. © 2019 Bloomberg Finance L.P. All rights reserved. Your Database is the Source of Truth DB
  • 13. © 2019 Bloomberg Finance L.P. All rights reserved. © 2019 Bloomberg Finance L.P. All rights reserved. Push Writes to the DB into the Cache Cache DB
  • 14. © 2019 Bloomberg Finance L.P. All rights reserved. © 2019 Bloomberg Finance L.P. All rights reserved. Revised Architecture Diagram Cache App DB
  • 15. © 2019 Bloomberg Finance L.P. All rights reserved. © 2019 Bloomberg Finance L.P. All rights reserved. Cache Instances are Consistent DB Cache Cache Cache
  • 16. © 2019 Bloomberg Finance L.P. All rights reserved. © 2019 Bloomberg Finance L.P. All rights reserved. How do I get Change Notification from my DB? Cach e DB
  • 17. © 2019 Bloomberg Finance L.P. All rights reserved. © 2019 Bloomberg Finance L.P. All rights reserved. Dual Writes App DB Cache Kafka
  • 18. © 2019 Bloomberg Finance L.P. All rights reserved. © 2019 Bloomberg Finance L.P. All rights reserved. Keep the Number of Write Paths Small ! DB Cache Kafka
  • 19. © 2019 Bloomberg Finance L.P. All rights reserved. © 2019 Bloomberg Finance L.P. All rights reserved. Dealing With Partial Write Failure DB App Cache Kafka
  • 20. © 2019 Bloomberg Finance L.P. All rights reserved. © 2019 Bloomberg Finance L.P. All rights reserved. Change Data Capture (CDC) DB App Write Log
  • 21. © 2019 Bloomberg Finance L.P. All rights reserved. © 2019 Bloomberg Finance L.P. All rights reserved. Change Data Capture (CDC) DB Write LogCache Kafka App
  • 22. © 2019 Bloomberg Finance L.P. All rights reserved. © 2019 Bloomberg Finance L.P. All rights reserved. Why Kafka? ● Durable ● Scalable ● Debuggable
  • 23. © 2019 Bloomberg Finance L.P. All rights reserved. © 2019 Bloomberg Finance L.P. All rights reserved. Kafka’s Topic Offset Tracking 98765 DB Cache 4321
  • 24. © 2019 Bloomberg Finance L.P. All rights reserved. © 2019 Bloomberg Finance L.P. All rights reserved. Too Complicated? Cache App DB
  • 25. © 2019 Bloomberg Finance L.P. All rights reserved. © 2019 Bloomberg Finance L.P. All rights reserved. Too Complicated? DB Cache App
  • 26. © 2019 Bloomberg Finance L.P. All rights reserved. © 2019 Bloomberg Finance L.P. All rights reserved. Recent Writes User 1User 2User 1User 3User 2
  • 27. © 2019 Bloomberg Finance L.P. All rights reserved. © 2019 Bloomberg Finance L.P. All rights reserved. Kafka Never Forgets... . . . User 1User 2User 1User 3User 2
  • 28. © 2019 Bloomberg Finance L.P. All rights reserved. © 2019 Bloomberg Finance L.P. All rights reserved. Kafka Never Forgets... User 1User 2User 1User 3User 2
  • 29. © 2019 Bloomberg Finance L.P. All rights reserved. © 2019 Bloomberg Finance L.P. All rights reserved. Kafka Never Forgets... User 1 User 2 User 1 User 3User 2
  • 30. © 2019 Bloomberg Finance L.P. All rights reserved. © 2019 Bloomberg Finance L.P. All rights reserved. Kafka Never Forgets... User 1 User 2 User 1 User 3 User 2
  • 31. © 2019 Bloomberg Finance L.P. All rights reserved. © 2019 Bloomberg Finance L.P. All rights reserved. Kafka Never Forgets... User 2 User 1 User 3 User 2
  • 32. © 2019 Bloomberg Finance L.P. All rights reserved. © 2019 Bloomberg Finance L.P. All rights reserved. Kafka Never Forgets... User 1 User 3 User 2
  • 33. © 2019 Bloomberg Finance L.P. All rights reserved. © 2019 Bloomberg Finance L.P. All rights reserved. Kafka Never Forgets... User 1User 3User 2
  • 34. © 2019 Bloomberg Finance L.P. All rights reserved. © 2019 Bloomberg Finance L.P. All rights reserved. Full Records User 1{ “Id”: 492343, “name”: “User 1”, “Date_joined”, “05/05/1995”, …... } User 2
  • 35. © 2019 Bloomberg Finance L.P. All rights reserved. © 2019 Bloomberg Finance L.P. All rights reserved. DB
  • 36. © 2019 Bloomberg Finance L.P. All rights reserved. © 2019 Bloomberg Finance L.P. All rights reserved. Cache
  • 37. © 2019 Bloomberg Finance L.P. All rights reserved. © 2019 Bloomberg Finance L.P. All rights reserved. Cache DB
  • 38. © 2019 Bloomberg Finance L.P. All rights reserved. © 2019 Bloomberg Finance L.P. All rights reserved. Simplifying Our Design DB Cache App
  • 39. © 2019 Bloomberg Finance L.P. All rights reserved. © 2019 Bloomberg Finance L.P. All rights reserved. Simplifying Our Design Cache App DB
  • 40. © 2019 Bloomberg Finance L.P. All rights reserved. © 2019 Bloomberg Finance L.P. All rights reserved. Fault Tolerant Cache App
  • 41. © 2019 Bloomberg Finance L.P. All rights reserved. © 2019 Bloomberg Finance L.P. All rights reserved. “Thundering Herd” Problem
  • 42. © 2019 Bloomberg Finance L.P. All rights reserved. © 2019 Bloomberg Finance L.P. All rights reserved. “Thundering Herd” Problem DB
  • 43. © 2019 Bloomberg Finance L.P. All rights reserved. © 2019 Bloomberg Finance L.P. All rights reserved. Scale Independence DB Cache Cache Cache Cache Cache
  • 44. © 2019 Bloomberg Finance L.P. All rights reserved. © 2019 Bloomberg Finance L.P. All rights reserved. More Sleep, Less Phone Calls App Cache DB
  • 45. © 2019 Bloomberg Finance L.P. All rights reserved. © 2019 Bloomberg Finance L.P. All rights reserved. When to Use This Technique ● When your cache needs to be up to date ● When latency is very important ● When you need to give clients flexibility in their caching strategy
  • 46. © 2019 Bloomberg Finance L.P. All rights reserved. © 2019 Bloomberg Finance L.P. All rights reserved. When NOT to Use This Technique ● When your data rarely changes ● When you data size is very large (100s of GB or TB)
  • 47. © 2019 Bloomberg Finance L.P. All rights reserved. © 2019 Bloomberg Finance L.P. All rights reserved. How? Cache ?
  • 48. © 2019 Bloomberg Finance L.P. All rights reserved. © 2019 Bloomberg Finance L.P. All rights reserved. Store the Kafka Topic in a Hash Table [ ]Cache
  • 49. © 2019 Bloomberg Finance L.P. All rights reserved. © 2019 Bloomberg Finance L.P. All rights reserved. In RAM Inside Your Application [ ]Cache
  • 50. © 2019 Bloomberg Finance L.P. All rights reserved. © 2019 Bloomberg Finance L.P. All rights reserved. Too Big for RAM? Store it on Disk App [ ]Cache
  • 51. © 2019 Bloomberg Finance L.P. All rights reserved. © 2019 Bloomberg Finance L.P. All rights reserved. A Cache in Every Instance [ ]Cache [ ]Cache [ ]Cache
  • 52. © 2019 Bloomberg Finance L.P. All rights reserved. © 2019 Bloomberg Finance L.P. All rights reserved. Out of Process Cache App App App [ ]Cache
  • 53. © 2019 Bloomberg Finance L.P. All rights reserved. © 2019 Bloomberg Finance L.P. All rights reserved. [ ]Cache
  • 54. © 2019 Bloomberg Finance L.P. All rights reserved. © 2019 Bloomberg Finance L.P. All rights reserved. CACHE!
  • 55. © 2019 Bloomberg Finance L.P. All rights reserved. Shard Your Data A-I J-R S-Z [ ]Cache [ ]Cache [ ]Cache
  • 56. © 2019 Bloomberg Finance L.P. All rights reserved. © 2019 Bloomberg Finance L.P. All rights reserved. How Does the Application Find its Data? App [ ]Cache [ ]Cache [ ]Cache
  • 57. © 2019 Bloomberg Finance L.P. All rights reserved. © 2019 Bloomberg Finance L.P. All rights reserved. There are only two hard things in Computer Science: cache invalidation and naming things. -- Phil Karlton
  • 58. © 2019 Bloomberg Finance L.P. All rights reserved. © 2019 Bloomberg Finance L.P. All rights reserved. Questions?
  • 59. © 2019 Bloomberg Finance L.P. All rights reserved. © 2019 Bloomberg Finance L.P. All rights reserved. Kafka Connectors ● Debezium ● JDBC ● Dedicated connectors for MS SQL, Oracle, etc.
  • 60. © 2019 Bloomberg Finance L.P. All rights reserved. © 2019 Bloomberg Finance L.P. All rights reserved. Will My Data Fit in RAM? ● How much RAM do you have? ● How big are your records? ● Do you have to cache the entire record?
  • 61. © 2019 Bloomberg Finance L.P. All rights reserved. © 2019 Bloomberg Finance L.P. All rights reserved. Caches can Forward Requests [ ]Cache [ ]Cache [ ]Cache App
  • 62. © 2019 Bloomberg Finance L.P. All rights reserved. © 2019 Bloomberg Finance L.P. All rights reserved. Use a Proxy AppProxy [ ]Cache [ ]Cache [ ]Cache
  • 63. © 2019 Bloomberg Finance L.P. All rights reserved. © 2019 Bloomberg Finance L.P. All rights reserved.
  • 64. © 2019 Bloomberg Finance L.P. All rights reserved. © 2019 Bloomberg Finance L.P. All rights reserved. [ ]
  • 65. © 2019 Bloomberg Finance L.P. All rights reserved. © 2019 Bloomberg Finance L.P. All rights reserved. [ ] [ ] [ ]
  • 66. © 2019 Bloomberg Finance L.P. All rights reserved. © 2019 Bloomberg Finance L.P. All rights reserved. [ ] [ ] [ ] ?
  • 67. © 2019 Bloomberg Finance L.P. All rights reserved. © 2019 Bloomberg Finance L.P. All rights reserved. [ ]
  • 68. © 2019 Bloomberg Finance L.P. All rights reserved. © 2019 Bloomberg Finance L.P. All rights reserved. [ ] [ ] [ ]