SlideShare a Scribd company logo
1 of 31
Microservices & Streaming Data
Why Microservices need streaming data
About me
Graduation
2006
Founded
AdDynamics
2007
Freedom!
2013
CTO Autheos
2015
Founded
SocialStreams
2018
You are here
What is a microservice?
What is a microservice?
Monolith Microservice
What is a microservice?
Monolith Microservice
What is a microservice ?
What is a microservice ?
What is a microservice ?
What is a microservice ?
Why microservices
• organized around business domains
• decentralized development process
• decentralized data management
• automate everything
• design for failure
There was once a little app…
WEB
Customer
Basket
Product
Order
The app grew…
WEB
SALES
AUTH
Customer
Basket
Product
Order
Disaster!
WEB
SALES
AUTH
migration
crash
crash
upgrade
Customer
Basket
Product
Order
Scaling models
• Scaling large problem domain using one Unified Model
• => very hard!
• Scaling many smaller models
• => not as hard!
• Scaling organizations, not code
Bounded Context
The system scales better
WEB
SALES
AUTH
Bounded Context
Bounded Context
Team A
Team B
Team C
The system scales better
API
SALES
AUTH
WEB
Point-to-Point communication
• Protocols:
• REST
• HTTP(S)
• Leverage existing ecosystems:
• Proxies
• Caching
• Browsers
• Simple and easy
• Testable contract between services
The complexity increases
A.3
A.4
A.2A.1
B.4
C.2
B.1 B.2
B.3
C.4
C.3C.1
What happened?
• Decompose model into components
• Expose components as service
• Components reference each other
• Where are these references in our model?
What happened?
• Design mistakes are easy
• Accidental complexity
• Business processes > 1 service
• Failure scenarios
C.2
C.4
The complexity increases
A.3
A.4
C.1
100% cpu
503 Unavailable
retry!
• Service overloads
• Upstream services retry
• Queue fills up
• “Thundering herd” problemcrash
crash
retry!
retry!
503 Unavailable
503 Unavailable
The complexity increases
A.3
A.4
A.2A.1
C.1
slow!
slow!
slow!
slow!
slow!
crash
crash
crash
crashcrash
Distributed deadlock
Circuit breakers
Gateway Service
Client
Service
Service
Too many 50x errors
Solves “thundering herd”
Bulkheads
Solves distributed deadlock
Pool
Service A
Service B Service C
Pool
Service A
Service B Service C
Pool
slow!
crash
slow!
crash
Is there a better approach?
Yes there is!
Data-centric approach
• Data being communicated is important
• Rather than REST API with interface…
• Use event data with a schema
• Asynchronous
• Loosely coupled
Event sourcing / CQRS
• Append-only event log
• Record things that happen
• Not what they are
• Create aggregates based on this event log
• a.k.a. Materialised Views
• a.k.a. “Aggregate Roots”
• Write and read models differ
• CQRS, “Command & Query Responsibility Segregation”
• Point-In-Time / Projections
Event Sourcing / CQRS
REDIS
BIGQUERY
ACCOUNTING
WEB • Producers
• Event Queue
• Consumers
Event Sourcing / CQRS
Command
Processor
Command Event
Event Store
Stream
Processor
Aggregate
Root
UpdateQuery Batch
Processor
Event
Event
Projection
Event Sourcing / CQRS
User
Aggregate
WEB
Create User User Created
User Exists?
Merge
User Created
Coding challenge
• github.com/solatis/microservices
• existing CQRS demo
• challenge:
• refactor to ecommerce demo
• commands:
• create_account
• add_to_basket
• remove_from_basket
• checkout
• aggregates:
• /accounts/{account_id}
• /baskets/{account_id}

More Related Content

What's hot

Is Your Developer's Head in the Cloud? May 7 Webinar
Is Your Developer's Head in the Cloud? May 7 WebinarIs Your Developer's Head in the Cloud? May 7 Webinar
Is Your Developer's Head in the Cloud? May 7 Webinar
C/D/H Technology Consultants
 
The hardest part of microservices: your data
The hardest part of microservices: your dataThe hardest part of microservices: your data
The hardest part of microservices: your data
Christian Posta
 

What's hot (20)

Serverless CQRS in Azure!
Serverless CQRS in Azure!Serverless CQRS in Azure!
Serverless CQRS in Azure!
 
Meeting Archive: A Simple Step to Gain 33% Performance Improvements in Reques...
Meeting Archive: A Simple Step to Gain 33% Performance Improvements in Reques...Meeting Archive: A Simple Step to Gain 33% Performance Improvements in Reques...
Meeting Archive: A Simple Step to Gain 33% Performance Improvements in Reques...
 
Managing your camels in the cloud with CI/CD
Managing your camels in the cloud with CI/CDManaging your camels in the cloud with CI/CD
Managing your camels in the cloud with CI/CD
 
O365Con19 - Developing Timerjob and Eventhandler Equivalents - Adis Jugo
O365Con19 - Developing Timerjob and Eventhandler Equivalents - Adis JugoO365Con19 - Developing Timerjob and Eventhandler Equivalents - Adis Jugo
O365Con19 - Developing Timerjob and Eventhandler Equivalents - Adis Jugo
 
Rapid Prototyping for Big Data with AWS
Rapid Prototyping for Big Data with AWS Rapid Prototyping for Big Data with AWS
Rapid Prototyping for Big Data with AWS
 
The Hardest Part of Microservices: Your Data - Christian Posta, Red Hat
The Hardest Part of Microservices: Your Data - Christian Posta, Red HatThe Hardest Part of Microservices: Your Data - Christian Posta, Red Hat
The Hardest Part of Microservices: Your Data - Christian Posta, Red Hat
 
Is Your Developer's Head in the Cloud? May 7 Webinar
Is Your Developer's Head in the Cloud? May 7 WebinarIs Your Developer's Head in the Cloud? May 7 Webinar
Is Your Developer's Head in the Cloud? May 7 Webinar
 
Ben Kehoe - Serverless Architecture for the Internet of Things
Ben Kehoe - Serverless Architecture for the Internet of ThingsBen Kehoe - Serverless Architecture for the Internet of Things
Ben Kehoe - Serverless Architecture for the Internet of Things
 
The Hitchhiker’s Guide to Hybrid Connectivity
The Hitchhiker’s Guide to Hybrid ConnectivityThe Hitchhiker’s Guide to Hybrid Connectivity
The Hitchhiker’s Guide to Hybrid Connectivity
 
Grokking microservices in 5 minutes
Grokking microservices in 5 minutesGrokking microservices in 5 minutes
Grokking microservices in 5 minutes
 
The hardest part of microservices: your data
The hardest part of microservices: your dataThe hardest part of microservices: your data
The hardest part of microservices: your data
 
A Microservice Journey
A Microservice JourneyA Microservice Journey
A Microservice Journey
 
Brisbane DevOps Meetup - Reinvent 2015
Brisbane DevOps Meetup - Reinvent 2015Brisbane DevOps Meetup - Reinvent 2015
Brisbane DevOps Meetup - Reinvent 2015
 
Azure Functions Real World Examples
Azure Functions Real World Examples Azure Functions Real World Examples
Azure Functions Real World Examples
 
Have It Your Way! SharePoint Customizations
Have It Your Way! SharePoint CustomizationsHave It Your Way! SharePoint Customizations
Have It Your Way! SharePoint Customizations
 
An evolution of application networking: service mesh
An evolution of application networking: service meshAn evolution of application networking: service mesh
An evolution of application networking: service mesh
 
Tech Talk on Cloud Computing
Tech Talk on Cloud ComputingTech Talk on Cloud Computing
Tech Talk on Cloud Computing
 
How to Grow a Serverless Team
How to Grow a Serverless TeamHow to Grow a Serverless Team
How to Grow a Serverless Team
 
An Azure of Things, a developer’s perspective
An Azure of Things, a developer’s perspectiveAn Azure of Things, a developer’s perspective
An Azure of Things, a developer’s perspective
 
How LEGO.com Accelerates With Serverless
How LEGO.com Accelerates With ServerlessHow LEGO.com Accelerates With Serverless
How LEGO.com Accelerates With Serverless
 

Similar to Microservices & Streaming Data

Five Early Challenges Of Building Streaming Fast Data Applications
Five Early Challenges Of Building Streaming Fast Data ApplicationsFive Early Challenges Of Building Streaming Fast Data Applications
Five Early Challenges Of Building Streaming Fast Data Applications
Lightbend
 

Similar to Microservices & Streaming Data (20)

Cloud-native Data
Cloud-native DataCloud-native Data
Cloud-native Data
 
Cloud-Native-Data with Cornelia Davis
Cloud-Native-Data with Cornelia DavisCloud-Native-Data with Cornelia Davis
Cloud-Native-Data with Cornelia Davis
 
Patterns of Distributed Application Design
Patterns of Distributed Application DesignPatterns of Distributed Application Design
Patterns of Distributed Application Design
 
Concurrency at Scale: Evolution to Micro-Services
Concurrency at Scale:  Evolution to Micro-ServicesConcurrency at Scale:  Evolution to Micro-Services
Concurrency at Scale: Evolution to Micro-Services
 
Design and Develop Serverless Applications as Set-Pieces
Design and Develop Serverless Applications as Set-PiecesDesign and Develop Serverless Applications as Set-Pieces
Design and Develop Serverless Applications as Set-Pieces
 
Pros & Cons of Microservices Architecture
Pros & Cons of Microservices ArchitecturePros & Cons of Microservices Architecture
Pros & Cons of Microservices Architecture
 
Cloud-native Data: Every Microservice Needs a Cache
Cloud-native Data: Every Microservice Needs a CacheCloud-native Data: Every Microservice Needs a Cache
Cloud-native Data: Every Microservice Needs a Cache
 
Joomla! Scalable Enterprise Deployments with AWS
Joomla! Scalable Enterprise Deployments with AWSJoomla! Scalable Enterprise Deployments with AWS
Joomla! Scalable Enterprise Deployments with AWS
 
Patterns of Distributed Application Design
Patterns of Distributed Application DesignPatterns of Distributed Application Design
Patterns of Distributed Application Design
 
Effective Microservices In a Data-centric World
Effective Microservices In a Data-centric WorldEffective Microservices In a Data-centric World
Effective Microservices In a Data-centric World
 
Hybrid Integration with BizTalk Server - ACSUG
Hybrid Integration with BizTalk Server - ACSUGHybrid Integration with BizTalk Server - ACSUG
Hybrid Integration with BizTalk Server - ACSUG
 
Microservices and Serverless for Mega Startups - DevOps IL Meetup
Microservices and Serverless for Mega Startups - DevOps IL MeetupMicroservices and Serverless for Mega Startups - DevOps IL Meetup
Microservices and Serverless for Mega Startups - DevOps IL Meetup
 
Microservices Journey NYC
Microservices Journey NYCMicroservices Journey NYC
Microservices Journey NYC
 
Introducing to serverless computing and AWS lambda - Israel Clouds Meetup
Introducing to serverless computing and AWS lambda - Israel Clouds MeetupIntroducing to serverless computing and AWS lambda - Israel Clouds Meetup
Introducing to serverless computing and AWS lambda - Israel Clouds Meetup
 
Serverless Messaging with Microsoft Azure by Steef-Jan Wiggers
Serverless Messaging with Microsoft Azure by Steef-Jan WiggersServerless Messaging with Microsoft Azure by Steef-Jan Wiggers
Serverless Messaging with Microsoft Azure by Steef-Jan Wiggers
 
Designing microservices part2
Designing microservices part2Designing microservices part2
Designing microservices part2
 
Design patterns for microservice architecture
Design patterns for microservice architectureDesign patterns for microservice architecture
Design patterns for microservice architecture
 
A Mashup with Backbone
A Mashup with BackboneA Mashup with Backbone
A Mashup with Backbone
 
Five Early Challenges Of Building Streaming Fast Data Applications
Five Early Challenges Of Building Streaming Fast Data ApplicationsFive Early Challenges Of Building Streaming Fast Data Applications
Five Early Challenges Of Building Streaming Fast Data Applications
 
Cloud Computing101 Azure, updated june 2017
Cloud Computing101 Azure, updated june 2017Cloud Computing101 Azure, updated june 2017
Cloud Computing101 Azure, updated june 2017
 

Recently uploaded

+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
Health
 

Recently uploaded (20)

The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
 
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdfAzure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
 
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
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
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...
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
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 🔝✔️✔️
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdf
 
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
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 

Microservices & Streaming Data

Editor's Notes

  1. (I believe) data = language of the system -> more common -> data engineering to become more and more important; done right, a data-driven system architecture -> empower other people deep into the data, no bottleneck This talk -> how these things fit. Talk a lot about architecture -> important to lay the foundation. Better understanding => better decisions. End: “good stuff”: event sourcing & cqrs, -> implement yourself!
  2. CTO, lead engineer, systems engineer? I love data. Data as the driving force behind system architecture.
  3. Let’s start with a question. What is a microservice? [questions] It’s like this whole system of cogs and wheels, that runs together smoothly.
  4. Microservices are a modularization approach. Applying microservices means to compose an application out of independent services running in separate processes. Therefore microservices can be independently deployed. Within a service you can use any technology and infrastructure.
  5. But there’s a myth that microservices are there to achieve scalability. But I can scale a monolith just fine. Actually, a monolith is much easier to manage from an operational point of view. So clearly there is more to them. Everybody is doing them. (next slide) What do some real world microservice infrastructures look like? Coined: Death star architecture!
  6. And for the sake of comparison, here we have an actual death star. Notice the resemblance.
  7. So, clearly these things can go out of hand. But it’s important for us to understand why people build microservices. We saw that we can scale monolith applications just fine… wouldn’t a single application then be just easier ? What problems are they actually solving? -> I looked it up! - Organized around business domains - Decentralized development process - Decentralized data management - Automate everything - Design for failure
  8. Disaster! Let’s look at how this can go wrong. Team issues upgrade -> Migration -> Schema changes!
  9. As you try to scale model to larger domain.. .. it becomes difficult to describe it in single model   Rather than scaling single model, scale many smaller models Explicit boundaries make it easier to scale organizations; the code functions as a “contract” between different teams.
  10. So, just to show what that looks like, here we can see how each service wraps a database, they do not share it anymore. They can each do migrations themselves, without risking any conflict. Such a wrapped service, we call a “bounded context”. (Domain Driven Design) Once again, to reiterate, when services can do migrations independently, what this actually means is that different teams can operate independently.
  11. Real world example
  12. How do we let these services talk with each other ? Everybody already uses REST + HTTP   Service boundaries act as a “contract” that teams can have between each other   We can test contracts: http integration testing.   Jeff Bezos was right!
  13. But… remember those death star architectures? Let’s see how things can go wrong.
  14. Our process is as follows: we decompose our model into different components. For example, our overall system can have billing information, but we don’t care about that in our core backend. So billing becomes a standalone component. We expose these components as services, microservices. Our billing service might have its own database that keeps track about balance, and maps it to an account id. These components have to reference each other! The billing API needs the core API to figure out what bill to send. But where are these references in our model? In SQL you have foreign keys… but this information is lost! It is wrapped in logic.
  15. It’s very easy to make design mistakes early that can haunt you later. These things cause a ton of accidental complexity. What starts out as something simple and elegant, suddenly becomes a complete mess of intertwined logic. How do you write business processes than span more than 1 service? There are no distributed transactions. How do you cope with ACID-requirements? Failure scenarios – numerous ways that things can fail.
  16. Service overloads Services backpropagate a “service unavailable” properly Upstream services retry Queue fills up Once the service recovers, all processes are racing to get access to that single resource -> “thundering herd” problem. -> Lots of real-life scenarios, AWS S3 down, etc. -> Can cause counterintuitive behavior
  17. Meanwhile, Silicon Valley was trying to figure out how to handle unprecedented volumes of cat pictures, and were asking: is there a better solution to this? As a matter of fact, yes there is!
  18. Data being communicated is important – “data is the language of the system”. The rest is logic, and just noise. Data is simple, unambiguous, auditable, the rest is noise! Rather than REST API with an interface….. Event data with schema! Async Loosely coupled
  19. Append-only event log – event sourcing ensures that all changes to application state are stored as a sequence of events. Record things that happen, not what they are – record only facts! Example: when creating a new user, do not record that “command” (“create user”), but record the fact (“user with id 1234 created”). -> “User with id X clicked add to basket for product Y at timestamp Z” -> Facts always remain true Create aggregates based on this event log – based on this permanent record of all facts that ever happened, you can rebuild any state you want (e.g. “users” table). Write and read models differ The key insight from CQRS is that the model you use to read data does not have to be the same as the model you use to write it. -> Write facts -> Read shopping cart / users -> Optimize Read models for how they are queried, rather than how they are stored Projections – not only query it, but also reconstruct state at PIT, automatically cope with retroactive changes, audit log
  20. Create User – command coming in from web browser Validation – user exists? With existing user aggregate store Validated – we can create it – user created event, this is now a fact. Merge – the “User” aggregate is constantly streaming from the event log, and merges the new user information into its aggregate. Many more aggregates, all decoupled.
  21. Create User – command coming in from web browser Validation – user exists? With existing user aggregate store Validated – we can create it – user created event, this is now a fact. Merge – the “User” aggregate is constantly streaming from the event log, and merges the new user information into its aggregate. Many more aggregates, all decoupled.