SlideShare a Scribd company logo
1 of 27
Backends of the Future
• Information systems for business (of any kind)
• Reflects entities of the real world
• Keep and update state
• Data aggregation and reporting
• Bookkeepers managed business data
• Bookkeepers used tables
• Tables are good for keeping state!
• Meat brains love tables
• State is stored in database in tables
• Read-change-write on each request
• Caches for performance
• Works OK: for low loads or 99,9% reads
• States get more complex
• States are updated more often
• ...concurrently!
• There are more and more states
• Stream changes of states
• DDD (since 2003)
• Bounded contexts
• Aggregate roots
• Ubiquitous language
{
"id": "1234",
"name": "Grocery List",
"items": [
{
"id": "5678",
"name": "Apples",
"completed": false
},
{
"id": "9012",
"name": "Milk",
"completed": true
},
{
"id": "3456",
"name": "Bread",
"completed": false
}
],
"created_at": "2023-04-25T10:00:00Z",
"updated_at": "2023-04-25T13:30:00Z"
}
• Modelled with DDD
• But... how to store them?
• Normalise to many tables?
• Put all in single blob key-value?
• Split in chunks?
• Strong consistency - at storage level
• Single master is SPoF and contention pain
• ..master-master is complex and fragile
• Locks to linearise updates
• Unrelated entities still share (indices)
• Master single write + replicas for read
• ... poor man's CQRS
• Caches
• ... and how to invalidate them?
• Overhead of (de)serialisation
• For logging, audits, read-only views...
• CDC - on top of existing models
• How to guarantee reliable delivery?
• ...out of sequence?
• No locks - no integrity
• ... but locks kill performance
• (De)serialisation overhead
• ORM hell, toxic magic of lazy loading
• Cache consistency hell
• Downstream changes - ugly CDC
• DDD aggregate roots
• in-memory when active
• recovered on demand
• Guaranteed durability and integrity
• Immediate downstream of updates
• 1973 - Actor model
• 2007 - Pat Helland (Amazon)
Life beyond
Distributed Transactions:
an Apostate’s Opinion
• 2009 - Akka by TypeSafe/LightBend
• 2023+ used in gaming, fintech, logistics...
• Actor guards the aggregate root
• strongly consistent
• transactional boundary
• Message box
• updates one-at-a time
• implemented without locking
• Stateful actors reside on multiple cluster
nodes
• Sharding/routing map
• Event-sourced persistence
• 1 Actor receives one message (one by one - from mailbox)
• 2 Message is validated against state
• 3 Valid message produces event
• 4 Event is written to durable storage
• 5 Event is applied to state
• 6 Side effects are triggered
• Sequence of immutable records
• Primary source of truth
• Append-only non-blocking writes
• SSTable-based storages:
Cassandra/Scylla, AWS Dynamo,
Google BigTable, Azure Cosmos
• Actors get deactivated...
• ...and then need to resurrect
• State recovered from the event journal
• Optionally, snapshots every N events
• ... for high-traffic and/or large states
• Exact copy of the state - wherever you want it
• ...CQRS - as it is meant to be
• Full or partial
• Which state do you need?
• Latest - need it fast, past not relevant
• Exact - can wait, need all of the events
• Relational or quasi-relational database
• ...Postgres, MySQL, ... Clickhouse
• States are vastly different
• Journal performance read vs. write
• Risk of split-brain
• Complexity of custom implementation
• Data lifecycle
• Lack of experienced engineers
• No single platform covering everything
• State size - 100's of bytes to some MBytes
• State event flows - 1/hour to 1000/sec
• Downstream latency SLA - minutes to
milliseconds
• Can happen in any multi-node cluster
• Two instances of single stateful actor
- two versions of reality
• Mitigation by automatic detection/recovery
• Downstream latency is critical for CQRS
• ... p99 <100ms (better <10ms)
• Append-only storages do have their limits
• ...excellent at writes, poor at reads
• CDC with guarantees, single source of truth
• Solution:
• stream to indexed storage
• hybrid recovery with marker
• Look ma, no ORM!
• Good fit for functional programming
• (State, Message) => Seq[Event]
• (State, Event) => State
• (StateOld, StateNew, Event) =>
Seq[SideEffect]
• Projections/lenses
• Already optimised
• Processing in memory
• Read side separated from primary states
• Scale by adding nodes to running cluster
• size of one state must fit one process...
• ...or proceed to splitting of aggregate roots
• Reducing codec overhead (JSON -> binary)
• Scalable stateful high-load with guarantees
• ...fintech, logistics, gaming
• multi-billion cap companies
• Stack: Akka/Cassandra/Kafka (Java or
Scala)
• Open-source Kafka Journal (Evolution)
Backends of the Future

More Related Content

Similar to Backends of the Future

VoltDB and Erlang - Tech planet 2012
VoltDB and Erlang - Tech planet 2012VoltDB and Erlang - Tech planet 2012
VoltDB and Erlang - Tech planet 2012Eonblast
 
Development of concurrent services using In-Memory Data Grids
Development of concurrent services using In-Memory Data GridsDevelopment of concurrent services using In-Memory Data Grids
Development of concurrent services using In-Memory Data Gridsjlorenzocima
 
Spark and cassandra (Hulu Talk)
Spark and cassandra (Hulu Talk)Spark and cassandra (Hulu Talk)
Spark and cassandra (Hulu Talk)Jon Haddad
 
London devops logging
London devops loggingLondon devops logging
London devops loggingTomas Doran
 
M6d cassandrapresentation
M6d cassandrapresentationM6d cassandrapresentation
M6d cassandrapresentationEdward Capriolo
 
Intro to Cassandra
Intro to CassandraIntro to Cassandra
Intro to CassandraJon Haddad
 
Select Stars: A SQL DBA's Introduction to Azure Cosmos DB (SQL Saturday Orego...
Select Stars: A SQL DBA's Introduction to Azure Cosmos DB (SQL Saturday Orego...Select Stars: A SQL DBA's Introduction to Azure Cosmos DB (SQL Saturday Orego...
Select Stars: A SQL DBA's Introduction to Azure Cosmos DB (SQL Saturday Orego...Bob Pusateri
 
CQRS + Event Sourcing
CQRS + Event SourcingCQRS + Event Sourcing
CQRS + Event SourcingMike Bild
 
Hacktive Directory Forensics - HackCon18, Oslo
Hacktive Directory Forensics - HackCon18, OsloHacktive Directory Forensics - HackCon18, Oslo
Hacktive Directory Forensics - HackCon18, OsloYossi Sassi
 
AWS basics
AWS basicsAWS basics
AWS basicsmbaric
 
Buytaert kris my_sql-pacemaker
Buytaert kris my_sql-pacemakerBuytaert kris my_sql-pacemaker
Buytaert kris my_sql-pacemakerkuchinskaya
 
Select Stars: A DBA's Guide to Azure Cosmos DB (SQL Saturday Oslo 2018)
Select Stars: A DBA's Guide to Azure Cosmos DB (SQL Saturday Oslo 2018)Select Stars: A DBA's Guide to Azure Cosmos DB (SQL Saturday Oslo 2018)
Select Stars: A DBA's Guide to Azure Cosmos DB (SQL Saturday Oslo 2018)Bob Pusateri
 
Webinar: Diagnosing Apache Cassandra Problems in Production
Webinar: Diagnosing Apache Cassandra Problems in ProductionWebinar: Diagnosing Apache Cassandra Problems in Production
Webinar: Diagnosing Apache Cassandra Problems in ProductionDataStax Academy
 
Webinar: Diagnosing Apache Cassandra Problems in Production
Webinar: Diagnosing Apache Cassandra Problems in ProductionWebinar: Diagnosing Apache Cassandra Problems in Production
Webinar: Diagnosing Apache Cassandra Problems in ProductionDataStax Academy
 
Select Stars: A DBA's Guide to Azure Cosmos DB (Chicago Suburban SQL Server U...
Select Stars: A DBA's Guide to Azure Cosmos DB (Chicago Suburban SQL Server U...Select Stars: A DBA's Guide to Azure Cosmos DB (Chicago Suburban SQL Server U...
Select Stars: A DBA's Guide to Azure Cosmos DB (Chicago Suburban SQL Server U...Bob Pusateri
 
C* Summit 2013: Cassandra at eBay Scale by Feng Qu and Anurag Jambhekar
C* Summit 2013: Cassandra at eBay Scale by Feng Qu and Anurag JambhekarC* Summit 2013: Cassandra at eBay Scale by Feng Qu and Anurag Jambhekar
C* Summit 2013: Cassandra at eBay Scale by Feng Qu and Anurag JambhekarDataStax Academy
 
Agility and Scalability with MongoDB
Agility and Scalability with MongoDBAgility and Scalability with MongoDB
Agility and Scalability with MongoDBMongoDB
 
How to Make Norikra Perfect
How to Make Norikra PerfectHow to Make Norikra Perfect
How to Make Norikra PerfectSATOSHI TAGOMORI
 
RedisConf18 - Redis at LINE - 25 Billion Messages Per Day
RedisConf18 - Redis at LINE - 25 Billion Messages Per DayRedisConf18 - Redis at LINE - 25 Billion Messages Per Day
RedisConf18 - Redis at LINE - 25 Billion Messages Per DayRedis Labs
 

Similar to Backends of the Future (20)

VoltDB and Erlang - Tech planet 2012
VoltDB and Erlang - Tech planet 2012VoltDB and Erlang - Tech planet 2012
VoltDB and Erlang - Tech planet 2012
 
Development of concurrent services using In-Memory Data Grids
Development of concurrent services using In-Memory Data GridsDevelopment of concurrent services using In-Memory Data Grids
Development of concurrent services using In-Memory Data Grids
 
Spark and cassandra (Hulu Talk)
Spark and cassandra (Hulu Talk)Spark and cassandra (Hulu Talk)
Spark and cassandra (Hulu Talk)
 
London devops logging
London devops loggingLondon devops logging
London devops logging
 
M6d cassandrapresentation
M6d cassandrapresentationM6d cassandrapresentation
M6d cassandrapresentation
 
Intro to Cassandra
Intro to CassandraIntro to Cassandra
Intro to Cassandra
 
Select Stars: A SQL DBA's Introduction to Azure Cosmos DB (SQL Saturday Orego...
Select Stars: A SQL DBA's Introduction to Azure Cosmos DB (SQL Saturday Orego...Select Stars: A SQL DBA's Introduction to Azure Cosmos DB (SQL Saturday Orego...
Select Stars: A SQL DBA's Introduction to Azure Cosmos DB (SQL Saturday Orego...
 
CQRS + Event Sourcing
CQRS + Event SourcingCQRS + Event Sourcing
CQRS + Event Sourcing
 
Hacktive Directory Forensics - HackCon18, Oslo
Hacktive Directory Forensics - HackCon18, OsloHacktive Directory Forensics - HackCon18, Oslo
Hacktive Directory Forensics - HackCon18, Oslo
 
AWS basics
AWS basicsAWS basics
AWS basics
 
Buytaert kris my_sql-pacemaker
Buytaert kris my_sql-pacemakerBuytaert kris my_sql-pacemaker
Buytaert kris my_sql-pacemaker
 
Select Stars: A DBA's Guide to Azure Cosmos DB (SQL Saturday Oslo 2018)
Select Stars: A DBA's Guide to Azure Cosmos DB (SQL Saturday Oslo 2018)Select Stars: A DBA's Guide to Azure Cosmos DB (SQL Saturday Oslo 2018)
Select Stars: A DBA's Guide to Azure Cosmos DB (SQL Saturday Oslo 2018)
 
Webinar: Diagnosing Apache Cassandra Problems in Production
Webinar: Diagnosing Apache Cassandra Problems in ProductionWebinar: Diagnosing Apache Cassandra Problems in Production
Webinar: Diagnosing Apache Cassandra Problems in Production
 
Webinar: Diagnosing Apache Cassandra Problems in Production
Webinar: Diagnosing Apache Cassandra Problems in ProductionWebinar: Diagnosing Apache Cassandra Problems in Production
Webinar: Diagnosing Apache Cassandra Problems in Production
 
Select Stars: A DBA's Guide to Azure Cosmos DB (Chicago Suburban SQL Server U...
Select Stars: A DBA's Guide to Azure Cosmos DB (Chicago Suburban SQL Server U...Select Stars: A DBA's Guide to Azure Cosmos DB (Chicago Suburban SQL Server U...
Select Stars: A DBA's Guide to Azure Cosmos DB (Chicago Suburban SQL Server U...
 
C* Summit 2013: Cassandra at eBay Scale by Feng Qu and Anurag Jambhekar
C* Summit 2013: Cassandra at eBay Scale by Feng Qu and Anurag JambhekarC* Summit 2013: Cassandra at eBay Scale by Feng Qu and Anurag Jambhekar
C* Summit 2013: Cassandra at eBay Scale by Feng Qu and Anurag Jambhekar
 
Agility and Scalability with MongoDB
Agility and Scalability with MongoDBAgility and Scalability with MongoDB
Agility and Scalability with MongoDB
 
How to Make Norikra Perfect
How to Make Norikra PerfectHow to Make Norikra Perfect
How to Make Norikra Perfect
 
RedisConf18 - Redis at LINE - 25 Billion Messages Per Day
RedisConf18 - Redis at LINE - 25 Billion Messages Per DayRedisConf18 - Redis at LINE - 25 Billion Messages Per Day
RedisConf18 - Redis at LINE - 25 Billion Messages Per Day
 
Cosmos db
Cosmos dbCosmos db
Cosmos db
 

Recently uploaded

Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️anilsa9823
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...panagenda
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerThousandEyes
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
Clustering techniques data mining book ....
Clustering techniques data mining book ....Clustering techniques data mining book ....
Clustering techniques data mining book ....ShaimaaMohamedGalal
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about usDynamic Netsoft
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfjoe51371421
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Steffen Staab
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 

Recently uploaded (20)

Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
Clustering techniques data mining book ....
Clustering techniques data mining book ....Clustering techniques data mining book ....
Clustering techniques data mining book ....
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about us
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdf
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 

Backends of the Future

  • 2. • Information systems for business (of any kind) • Reflects entities of the real world • Keep and update state • Data aggregation and reporting
  • 3. • Bookkeepers managed business data • Bookkeepers used tables • Tables are good for keeping state! • Meat brains love tables
  • 4. • State is stored in database in tables • Read-change-write on each request • Caches for performance • Works OK: for low loads or 99,9% reads
  • 5. • States get more complex • States are updated more often • ...concurrently! • There are more and more states • Stream changes of states
  • 6. • DDD (since 2003) • Bounded contexts • Aggregate roots • Ubiquitous language { "id": "1234", "name": "Grocery List", "items": [ { "id": "5678", "name": "Apples", "completed": false }, { "id": "9012", "name": "Milk", "completed": true }, { "id": "3456", "name": "Bread", "completed": false } ], "created_at": "2023-04-25T10:00:00Z", "updated_at": "2023-04-25T13:30:00Z" }
  • 7. • Modelled with DDD • But... how to store them? • Normalise to many tables? • Put all in single blob key-value? • Split in chunks?
  • 8. • Strong consistency - at storage level • Single master is SPoF and contention pain • ..master-master is complex and fragile • Locks to linearise updates
  • 9. • Unrelated entities still share (indices) • Master single write + replicas for read • ... poor man's CQRS • Caches • ... and how to invalidate them? • Overhead of (de)serialisation
  • 10. • For logging, audits, read-only views... • CDC - on top of existing models • How to guarantee reliable delivery? • ...out of sequence?
  • 11. • No locks - no integrity • ... but locks kill performance • (De)serialisation overhead • ORM hell, toxic magic of lazy loading • Cache consistency hell • Downstream changes - ugly CDC
  • 12. • DDD aggregate roots • in-memory when active • recovered on demand • Guaranteed durability and integrity • Immediate downstream of updates
  • 13. • 1973 - Actor model • 2007 - Pat Helland (Amazon) Life beyond Distributed Transactions: an Apostate’s Opinion • 2009 - Akka by TypeSafe/LightBend • 2023+ used in gaming, fintech, logistics...
  • 14. • Actor guards the aggregate root • strongly consistent • transactional boundary • Message box • updates one-at-a time • implemented without locking
  • 15. • Stateful actors reside on multiple cluster nodes • Sharding/routing map • Event-sourced persistence
  • 16. • 1 Actor receives one message (one by one - from mailbox) • 2 Message is validated against state • 3 Valid message produces event • 4 Event is written to durable storage • 5 Event is applied to state • 6 Side effects are triggered
  • 17. • Sequence of immutable records • Primary source of truth • Append-only non-blocking writes • SSTable-based storages: Cassandra/Scylla, AWS Dynamo, Google BigTable, Azure Cosmos
  • 18. • Actors get deactivated... • ...and then need to resurrect • State recovered from the event journal • Optionally, snapshots every N events • ... for high-traffic and/or large states
  • 19. • Exact copy of the state - wherever you want it • ...CQRS - as it is meant to be • Full or partial • Which state do you need? • Latest - need it fast, past not relevant • Exact - can wait, need all of the events • Relational or quasi-relational database • ...Postgres, MySQL, ... Clickhouse
  • 20. • States are vastly different • Journal performance read vs. write • Risk of split-brain • Complexity of custom implementation • Data lifecycle • Lack of experienced engineers • No single platform covering everything
  • 21. • State size - 100's of bytes to some MBytes • State event flows - 1/hour to 1000/sec • Downstream latency SLA - minutes to milliseconds
  • 22. • Can happen in any multi-node cluster • Two instances of single stateful actor - two versions of reality • Mitigation by automatic detection/recovery
  • 23. • Downstream latency is critical for CQRS • ... p99 <100ms (better <10ms) • Append-only storages do have their limits • ...excellent at writes, poor at reads • CDC with guarantees, single source of truth • Solution: • stream to indexed storage • hybrid recovery with marker
  • 24. • Look ma, no ORM! • Good fit for functional programming • (State, Message) => Seq[Event] • (State, Event) => State • (StateOld, StateNew, Event) => Seq[SideEffect] • Projections/lenses
  • 25. • Already optimised • Processing in memory • Read side separated from primary states • Scale by adding nodes to running cluster • size of one state must fit one process... • ...or proceed to splitting of aggregate roots • Reducing codec overhead (JSON -> binary)
  • 26. • Scalable stateful high-load with guarantees • ...fintech, logistics, gaming • multi-billion cap companies • Stack: Akka/Cassandra/Kafka (Java or Scala) • Open-source Kafka Journal (Evolution)