SlideShare une entreprise Scribd logo
1  sur  49
Scaling Your Architecture
with Services and Events
Randy Shoup
WeWork
Kraków, 15-17 May 2019
Background
• VP Engineering at WeWork
o Physical space as a service
• VP Engineering at Stitch Fix
o Software and data science in clothing retail
• Director of Engineering for Google App
Engine
o World’s largest Platform-as-a-Service
• Chief Engineer at eBay
o Multiple generations of eBay’s infrastructure
Evolution to Microservices
• eBay
• 5th generation today
• Monolithic Perl  Monolithic C++  Java  microservices
• Twitter
• 3rd generation today
• Monolithic Rails  JS / Rails / Scala  microservices
• Amazon
• Nth generation today
• Monolithic Perl / C++  Java / Scala  microservices
@randyshoup linkedin.com/in/randyshoup
No one starts with microservices
…
Past a certain scale, everyone
ends up with microservices
If you don’t end up regretting
your early technology
decisions, you probably over-
engineered.
Services and Events
• Migrating to Microservices
• Using Microservices and Events
Services and Events
• Migrating to Microservices
o When and Why to Migrate
o How to Migrate
• Using Microservices and Events
Services and Events
• Migrating to Microservices
o When and Why to Migrate
o How to Migrate
• Using Microservices and Events
Microservices
• Single-purpose
• Simple, well-defined interface
• Modular and independent
• Isolated persistence (!)
A
C D E
B
@randyshoup linkedin.com/in/randyshoup
Microservice Architecture
• Each unit is simple
• Independent scaling and
performance
• Independent testing and deployment
• “Optimal” technology stack
• Security boundary
• Multiple cooperating units
• Exchange in-process for network
latencies
• More sophisticated deployment and
monitoring tools
• System-level complexity
Pros Cons
Why Migrate?
• Velocity
o Time to market is constrained by coupling and lack of isolation in the monolith
o Teams step on each others’ toes, and can no longer develop independently
o Difficult for new engineers to be productive
• Scaling
o Vertical scaling of the monolith no longer works
o Parts of the system need to scale independently of others
Why Migrate?
• Deployment
o Parts of the system need to deploy independently of others
o Monolithic release is too slow, too complicated, too risky
Services and Events
• Migrating to Microservices
o When and Why to Migrate
o How to Migrate
• Using Microservices and Events
Extracting Microservices
• Problem: Monolithic shared DB
• Clients
• Shipments
• Items
• Styles, SKUs
stitchfix.com Styling app Warehouse app Merch app
CS app Logistics app Payments service Profile service
@randyshoup linkedin.com/in/randyshoup
Extracting Microservices
• Decouple applications / services from shared DB
• Clients
• Shipments
• Items
• Styles, SKUs
stitchfix.com Styling app Warehouse app Merch app
CS app Logistics app Payments service Profile service
@randyshoup linkedin.com/in/randyshoup
Extracting Microservices
• Decouple applications / services from shared DB
Styling app Warehouse app
core_item
core_sku
core_client
@randyshoup linkedin.com/in/randyshoup
Extracting Microservices
• Step 1: Create a service
Styling app Warehouse app
core_item
core_sku
core_client
client-service
@randyshoup linkedin.com/in/randyshoup
Extracting Microservices
• Step 2: Applications use the service
Styling app Warehouse app
core_item
core_sku
core_client
client-service
@randyshoup linkedin.com/in/randyshoup
Extracting Microservices
• Step 2: Applications use the service
Styling app Warehouse app
core_item
core_sku
core_client
client-service
Do NOT stop here!
① All the problems of a
distributed system
② All the problems of a
shared database
③ None of the benefits of
microservices 
@randyshoup linkedin.com/in/randyshoup
Extracting Microservices
• Step 3: Move data to private database
Styling app Warehouse app
core_item
core_sku
client-service
core_client
@randyshoup linkedin.com/in/randyshoup
Extracting Microservices
• Step 4: Rinse and Repeat
Styling app Warehouse app
core_sku
client-service
core_client
item-service
core_item
@randyshoup linkedin.com/in/randyshoup
Extracting Microservices
• Step 4: Rinse and Repeat
Styling app Warehouse app
client-service
core_client
item-service
core_item
style-service
core_sku
@randyshoup linkedin.com/in/randyshoup
Extracting Microservices
• Step 4: Rinse and Repeat
Styling app Warehouse app
client-service
core_client
item-service
core_item
style-service
core_sku
@randyshoup linkedin.com/in/randyshoup
Services and Events
• Migrating to Microservices
• Using Microservices and Events
o Two Architectural Tools
o Shared Data
o Joins
o Transactions
Services and Events
• Migrating to Microservices
• Using Microservices and Events
o Two Architectural Tools
o Shared Data
o Joins
o Transactions
System of Record
• Single System of Record
o Every piece of data is owned by a single service
o That service is the canonical system of record for that data
• Every other copy is a read-only, non-authoritative cache
@randyshoup linkedin.com/in/randyshoup
customer-service
styling-service
customer-search
billing-service
Events are First-Class
• “A significant change in state”
o Statement that some interesting thing occurred
• Traditional 3-tier system
o Presentation  interface / interaction
o Application  stateless business logic
o Persistence  database
• Fourth fundamental building block
o State changes  events
o 0 | 1 | N consumers subscribe to the event, typically asynchronously
@randyshoup linkedin.com/in/randyshoup
Microservices and Events
• Events are a first-class part of a service interface
• A service interface includes
o Synchronous request-response (REST, gRPC, etc)
o Events the service produces
o Events the service consumes
o Bulk reads and writes (ETL)
• The interface includes any mechanism for getting data in or
out of the service (!)
@randyshoup linkedin.com/in/randyshoup
Services and Events
• Migrating to Microservices
• Using Microservices and Events
o Two Architectural Tools
o Shared Data
o Joins
o Transactions
Shared Data
• Monolithic database makes it easy to leverage shared data
• Where does shared data go in a microservices world?
@randyshoup linkedin.com/in/randyshoup
Shared Data
Option 1: Synchronous Lookup
o Customer service owns customer data
o Fulfillment service calls customer service in real time
fulfillment-service
customer-service
@randyshoup linkedin.com/in/randyshoup
Shared Data
Option 2: Async event + local cache
o Customer service owns customer data
o Customer service sends address-updated event when customer address
changes
o Fulfillment service caches current customer address
fulfillment-servicecustomer-service
@randyshoup linkedin.com/in/randyshoup
Shared Data
Option 3: Shared metadata library
o Read-only metadata, basically immutable
o E.g., size schemas, colors, EU countries, US states, etc.
receiving-serviceitem-service
style-service
@randyshoup linkedin.com/in/randyshoup
Services and Events
• Migrating to Microservices
• Using Microservices and Events
o Two Architectural Tools
o Shared Data
o Joins
o Transactions
Joins
• Monolithic database makes it easy to join tables
• Splitting the data across microservices makes joins very hard
@randyshoup linkedin.com/in/randyshoup
SELECT FROM A INNER JOIN B ON …
Joins
Option 1: Join in Client Application
o Get a single customer from customer-service
o Query matching orders for that customer from order-service
Customers
Orders
order-history-page
customer-service order-service
@randyshoup linkedin.com/in/randyshoup
Joins
Option 2: Service that “Materializes the View”
o Listen to events from item-service, events from order-service
o Maintain denormalized join of items and orders together in local storage
Items Order Feedback
item-feedback-service
item-service
order-feedback-service
@randyshoup linkedin.com/in/randyshoup
Joins
Many common systems do this
• “Materialized view” in database systems
• Most NoSQL systems
• Search engines
• Analytic systems
@randyshoup linkedin.com/in/randyshoup
Services and Events
• Migrating to Microservices
• Using Microservices and Events
o Two Architectural Tools
o Shared Data
o Joins
o Transactions
Transactions
• Monolithic database makes transactions across multiple
entities easy
• Splitting data across services makes transactions very hard
@randyshoup linkedin.com/in/randyshoup
BEGIN; INSERT INTO A …; UPDATE B...; COMMIT;
“In general, application
developers simply do not
implement large scalable
applications assuming
distributed transactions.”
-- Pat Helland
Life After Distributed Transactions: An Apostate’s Opinion, 2007
“Grownups don’t use
distributed transactions”
-- Pat Helland
Workflows and Sagas
• Transaction  Saga
o Model the transaction as a state machine of atomic events
• Reimplement as a workflow
• Roll back with compensating operations in reverse
A B C
A B C
@randyshoup linkedin.com/in/randyshoup
Workflows and Sagas
Many real-world systems work like this
• Payment processing
• Expense approval
• Travel
• Software development process
@randyshoup linkedin.com/in/randyshoup
Intermediate States
Model intermediate states as part of your interface
• Payment started, pending, complete
• Expense submitted, approved, paid
• Feature developed, reviewed, deployed, released
@randyshoup linkedin.com/in/randyshoup
Choreography
No central coordinator
o No central management of workflow state
o State transitions entirely through events
o Implicit “guarantees” for termination of the state machine
@randyshoup linkedin.com/in/randyshoup
Transport
A B C
Orchestration
Workflow coordinator
o Coordinator maintains state of workflow, guarantees termination
o Coordinator triggers state transitions
o Events (optionally) signal transitions
@randyshoup linkedin.com/in/randyshoup
Payment
A B C
Services and Events
• Migrating to Microservices
o When and Why to Migrate
o How to Migrate
• Using Microservices and Events
o Two Architectural Tools
o Shared Data
o Joins
o Transactions
Dziękuję bardzo!
@randyshoup
linkedin.com/in/randyshoup
medium.com/@randyshoup

Contenu connexe

Tendances

Intranet show and_tell_2010
Intranet show and_tell_2010Intranet show and_tell_2010
Intranet show and_tell_2010
Charlie Hull
 
The (not so) Dark Art of Atlassian Performance Tuning
The (not so) Dark Art of Atlassian Performance TuningThe (not so) Dark Art of Atlassian Performance Tuning
The (not so) Dark Art of Atlassian Performance Tuning
colleenfry
 

Tendances (20)

Learning from Learnings: Anatomy of Three Incidents
Learning from Learnings: Anatomy of Three IncidentsLearning from Learnings: Anatomy of Three Incidents
Learning from Learnings: Anatomy of Three Incidents
 
Service Architectures At Scale - QCon London 2015
Service Architectures At Scale - QCon London 2015Service Architectures At Scale - QCon London 2015
Service Architectures At Scale - QCon London 2015
 
Being Elastic -- Evolving Programming for the Cloud
Being Elastic -- Evolving Programming for the CloudBeing Elastic -- Evolving Programming for the Cloud
Being Elastic -- Evolving Programming for the Cloud
 
Art of the Possible - Serverless Conference NYC 2017
Art of the Possible - Serverless Conference NYC 2017 Art of the Possible - Serverless Conference NYC 2017
Art of the Possible - Serverless Conference NYC 2017
 
DataEngConf SF16 - Methods for Content Relevance at LinkedIn
DataEngConf SF16 - Methods for Content Relevance at LinkedInDataEngConf SF16 - Methods for Content Relevance at LinkedIn
DataEngConf SF16 - Methods for Content Relevance at LinkedIn
 
You build it - Cyber Chicago Keynote
You build it -  Cyber Chicago KeynoteYou build it -  Cyber Chicago Keynote
You build it - Cyber Chicago Keynote
 
Managing a Microservices Development Team (And advanced Microservice concerns)
Managing a Microservices Development Team (And advanced Microservice concerns)Managing a Microservices Development Team (And advanced Microservice concerns)
Managing a Microservices Development Team (And advanced Microservice concerns)
 
DevSecOps - London Gathering : June 2018
DevSecOps - London Gathering : June 2018DevSecOps - London Gathering : June 2018
DevSecOps - London Gathering : June 2018
 
Deploying Big Data Platforms
Deploying Big Data PlatformsDeploying Big Data Platforms
Deploying Big Data Platforms
 
Intranet show and_tell_2010
Intranet show and_tell_2010Intranet show and_tell_2010
Intranet show and_tell_2010
 
Content Engineering and The Internet of “Smart” Things
Content Engineering and The Internet of “Smart” ThingsContent Engineering and The Internet of “Smart” Things
Content Engineering and The Internet of “Smart” Things
 
Turning search upside down with powerful open source search software
Turning search upside down with powerful open source search softwareTurning search upside down with powerful open source search software
Turning search upside down with powerful open source search software
 
How to Join the "1M JIRA Issues" Club
How to Join the "1M JIRA Issues" ClubHow to Join the "1M JIRA Issues" Club
How to Join the "1M JIRA Issues" Club
 
FIBEP WMIC 2015 - How Infomedia upgraded their closed-source search engine to...
FIBEP WMIC 2015 - How Infomedia upgraded their closed-source search engine to...FIBEP WMIC 2015 - How Infomedia upgraded their closed-source search engine to...
FIBEP WMIC 2015 - How Infomedia upgraded their closed-source search engine to...
 
Performance Optimization of Cloud Based Applications by Peter Smith, ACL
Performance Optimization of Cloud Based Applications by Peter Smith, ACLPerformance Optimization of Cloud Based Applications by Peter Smith, ACL
Performance Optimization of Cloud Based Applications by Peter Smith, ACL
 
Database Source Control: Migrations vs State
Database Source Control: Migrations vs StateDatabase Source Control: Migrations vs State
Database Source Control: Migrations vs State
 
Workflowvs vs Flow 365 Saturday Amsterdam
Workflowvs vs Flow 365 Saturday AmsterdamWorkflowvs vs Flow 365 Saturday Amsterdam
Workflowvs vs Flow 365 Saturday Amsterdam
 
Galichet XML Workflow Brief History NISO
Galichet XML Workflow Brief History NISOGalichet XML Workflow Brief History NISO
Galichet XML Workflow Brief History NISO
 
Taking Over & Managing Large Messy Systems
Taking Over & Managing Large Messy SystemsTaking Over & Managing Large Messy Systems
Taking Over & Managing Large Messy Systems
 
The (not so) Dark Art of Atlassian Performance Tuning
The (not so) Dark Art of Atlassian Performance TuningThe (not so) Dark Art of Atlassian Performance Tuning
The (not so) Dark Art of Atlassian Performance Tuning
 

Similaire à Scaling Your Architecture with Services and Events

MongoDB Breakfast Milan - Mainframe Offloading Strategies
MongoDB Breakfast Milan -  Mainframe Offloading StrategiesMongoDB Breakfast Milan -  Mainframe Offloading Strategies
MongoDB Breakfast Milan - Mainframe Offloading Strategies
MongoDB
 
Techniques for scaling application with security and visibility in cloud
Techniques for scaling application with security and visibility in cloudTechniques for scaling application with security and visibility in cloud
Techniques for scaling application with security and visibility in cloud
Akshay Mathur
 

Similaire à Scaling Your Architecture with Services and Events (20)

Kafka Summit SF 2017 - Keynote - Managing Data at Scale: The Unreasonable Eff...
Kafka Summit SF 2017 - Keynote - Managing Data at Scale: The Unreasonable Eff...Kafka Summit SF 2017 - Keynote - Managing Data at Scale: The Unreasonable Eff...
Kafka Summit SF 2017 - Keynote - Managing Data at Scale: The Unreasonable Eff...
 
SharePoint Custom Development
SharePoint Custom DevelopmentSharePoint Custom Development
SharePoint Custom Development
 
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
 
Minimal Viable Architecture - Silicon Slopes 2020
Minimal Viable Architecture - Silicon Slopes 2020Minimal Viable Architecture - Silicon Slopes 2020
Minimal Viable Architecture - Silicon Slopes 2020
 
MongoDB Breakfast Milan - Mainframe Offloading Strategies
MongoDB Breakfast Milan -  Mainframe Offloading StrategiesMongoDB Breakfast Milan -  Mainframe Offloading Strategies
MongoDB Breakfast Milan - Mainframe Offloading Strategies
 
QCon 2015 - Microservices Track Notes
QCon 2015 - Microservices Track Notes QCon 2015 - Microservices Track Notes
QCon 2015 - Microservices Track Notes
 
From Monoliths to Services: Paying Your Technical Debt
From Monoliths to Services: Paying Your Technical DebtFrom Monoliths to Services: Paying Your Technical Debt
From Monoliths to Services: Paying Your Technical Debt
 
From Monoliths to Services: Grafually paying your Technical Debt
From Monoliths to Services: Grafually paying your Technical DebtFrom Monoliths to Services: Grafually paying your Technical Debt
From Monoliths to Services: Grafually paying your Technical Debt
 
Neo4j the Anti Crime Database
Neo4j the Anti Crime DatabaseNeo4j the Anti Crime Database
Neo4j the Anti Crime Database
 
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
 
SaaS for Understanding
SaaS for UnderstandingSaaS for Understanding
SaaS for Understanding
 
Simply Business - Near Real Time Event Processing
Simply Business - Near Real Time Event ProcessingSimply Business - Near Real Time Event Processing
Simply Business - Near Real Time Event Processing
 
Assessing New Databases– Translytical Use Cases
Assessing New Databases– Translytical Use CasesAssessing New Databases– Translytical Use Cases
Assessing New Databases– Translytical Use Cases
 
Techniques for scaling application with security and visibility in cloud
Techniques for scaling application with security and visibility in cloudTechniques for scaling application with security and visibility in cloud
Techniques for scaling application with security and visibility in cloud
 
Large Scale Architecture -- The Unreasonable Effectiveness of Simplicity
Large Scale Architecture -- The Unreasonable Effectiveness of SimplicityLarge Scale Architecture -- The Unreasonable Effectiveness of Simplicity
Large Scale Architecture -- The Unreasonable Effectiveness of Simplicity
 
Enabling Telco to Build and Run Modern Applications
Enabling Telco to Build and Run Modern Applications Enabling Telco to Build and Run Modern Applications
Enabling Telco to Build and Run Modern Applications
 
Microstrategy Overview
Microstrategy OverviewMicrostrategy Overview
Microstrategy Overview
 
LeanIX Keynote Lessons from a startup
LeanIX Keynote Lessons from a startupLeanIX Keynote Lessons from a startup
LeanIX Keynote Lessons from a startup
 
Project Flogo: Serverless Integration, Powered by Flogo and Lambda
Project Flogo: Serverless Integration, Powered by Flogo and LambdaProject Flogo: Serverless Integration, Powered by Flogo and Lambda
Project Flogo: Serverless Integration, Powered by Flogo and Lambda
 

Plus de Randy Shoup

An Agile Approach to Machine Learning
An Agile Approach to Machine LearningAn Agile Approach to Machine Learning
An Agile Approach to Machine Learning
Randy Shoup
 
DevOps - It's About How We Work
DevOps - It's About How We WorkDevOps - It's About How We Work
DevOps - It's About How We Work
Randy Shoup
 
Ten Lessons of the DevOps Transition
Ten Lessons of the DevOps TransitionTen Lessons of the DevOps Transition
Ten Lessons of the DevOps Transition
Randy Shoup
 

Plus de Randy Shoup (18)

Anatomy of Three Incidents -- Commonalities and Lessons
Anatomy of Three Incidents -- Commonalities and LessonsAnatomy of Three Incidents -- Commonalities and Lessons
Anatomy of Three Incidents -- Commonalities and Lessons
 
One Terrible Day at Google, and How It Made Us Better
One Terrible Day at Google, and How It Made Us BetterOne Terrible Day at Google, and How It Made Us Better
One Terrible Day at Google, and How It Made Us Better
 
An Agile Approach to Machine Learning
An Agile Approach to Machine LearningAn Agile Approach to Machine Learning
An Agile Approach to Machine Learning
 
Moving Fast at Scale
Moving Fast at ScaleMoving Fast at Scale
Moving Fast at Scale
 
Breaking Codes, Designing Jets, and Building Teams
Breaking Codes, Designing Jets, and Building TeamsBreaking Codes, Designing Jets, and Building Teams
Breaking Codes, Designing Jets, and Building Teams
 
Moving Fast At Scale
Moving Fast At ScaleMoving Fast At Scale
Moving Fast At Scale
 
DevOps - It's About How We Work
DevOps - It's About How We WorkDevOps - It's About How We Work
DevOps - It's About How We Work
 
Ten Lessons of the DevOps Transition
Ten Lessons of the DevOps TransitionTen Lessons of the DevOps Transition
Ten Lessons of the DevOps Transition
 
Pragmatic Microservices
Pragmatic MicroservicesPragmatic Microservices
Pragmatic Microservices
 
A CTO's Guide to Scaling Organizations
A CTO's Guide to Scaling OrganizationsA CTO's Guide to Scaling Organizations
A CTO's Guide to Scaling Organizations
 
From the Monolith to Microservices - CraftConf 2015
From the Monolith to Microservices - CraftConf 2015From the Monolith to Microservices - CraftConf 2015
From the Monolith to Microservices - CraftConf 2015
 
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
 
Minimum Viable Architecture -- Good Enough is Good Enough in a Startup
Minimum Viable Architecture -- Good Enough is Good Enough in a StartupMinimum Viable Architecture -- Good Enough is Good Enough in a Startup
Minimum Viable Architecture -- Good Enough is Good Enough in a Startup
 
Why Enterprises Are Embracing the Cloud
Why Enterprises Are Embracing the CloudWhy Enterprises Are Embracing the Cloud
Why Enterprises Are Embracing the Cloud
 
DevOpsDays Silicon Valley 2014 - The Game of Operations
DevOpsDays Silicon Valley 2014 - The Game of OperationsDevOpsDays Silicon Valley 2014 - The Game of Operations
DevOpsDays Silicon Valley 2014 - The Game of Operations
 
QCon New York 2014 - Scalable, Reliable Analytics Infrastructure at KIXEYE
QCon New York 2014 - Scalable, Reliable Analytics Infrastructure at KIXEYEQCon New York 2014 - Scalable, Reliable Analytics Infrastructure at KIXEYE
QCon New York 2014 - Scalable, Reliable Analytics Infrastructure at KIXEYE
 
QCon Tokyo 2014 - Virtuous Cycles of Velocity: What I Learned About Going Fas...
QCon Tokyo 2014 - Virtuous Cycles of Velocity: What I Learned About Going Fas...QCon Tokyo 2014 - Virtuous Cycles of Velocity: What I Learned About Going Fas...
QCon Tokyo 2014 - Virtuous Cycles of Velocity: What I Learned About Going Fas...
 
The Importance of Culture: Building and Sustaining Effective Engineering Org...
The Importance of Culture:  Building and Sustaining Effective Engineering Org...The Importance of Culture:  Building and Sustaining Effective Engineering Org...
The Importance of Culture: Building and Sustaining Effective Engineering Org...
 

Dernier

CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceCALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
anilsa9823
 
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
 
+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
 

Dernier (20)

Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
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
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
 
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
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
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
 
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 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...
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceCALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female 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 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
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
 
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
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
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 ...
 
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
 
+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...
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 

Scaling Your Architecture with Services and Events

  • 1. Scaling Your Architecture with Services and Events Randy Shoup WeWork Kraków, 15-17 May 2019
  • 2. Background • VP Engineering at WeWork o Physical space as a service • VP Engineering at Stitch Fix o Software and data science in clothing retail • Director of Engineering for Google App Engine o World’s largest Platform-as-a-Service • Chief Engineer at eBay o Multiple generations of eBay’s infrastructure
  • 3. Evolution to Microservices • eBay • 5th generation today • Monolithic Perl  Monolithic C++  Java  microservices • Twitter • 3rd generation today • Monolithic Rails  JS / Rails / Scala  microservices • Amazon • Nth generation today • Monolithic Perl / C++  Java / Scala  microservices @randyshoup linkedin.com/in/randyshoup
  • 4. No one starts with microservices … Past a certain scale, everyone ends up with microservices
  • 5. If you don’t end up regretting your early technology decisions, you probably over- engineered.
  • 6. Services and Events • Migrating to Microservices • Using Microservices and Events
  • 7. Services and Events • Migrating to Microservices o When and Why to Migrate o How to Migrate • Using Microservices and Events
  • 8. Services and Events • Migrating to Microservices o When and Why to Migrate o How to Migrate • Using Microservices and Events
  • 9. Microservices • Single-purpose • Simple, well-defined interface • Modular and independent • Isolated persistence (!) A C D E B @randyshoup linkedin.com/in/randyshoup
  • 10. Microservice Architecture • Each unit is simple • Independent scaling and performance • Independent testing and deployment • “Optimal” technology stack • Security boundary • Multiple cooperating units • Exchange in-process for network latencies • More sophisticated deployment and monitoring tools • System-level complexity Pros Cons
  • 11. Why Migrate? • Velocity o Time to market is constrained by coupling and lack of isolation in the monolith o Teams step on each others’ toes, and can no longer develop independently o Difficult for new engineers to be productive • Scaling o Vertical scaling of the monolith no longer works o Parts of the system need to scale independently of others
  • 12. Why Migrate? • Deployment o Parts of the system need to deploy independently of others o Monolithic release is too slow, too complicated, too risky
  • 13. Services and Events • Migrating to Microservices o When and Why to Migrate o How to Migrate • Using Microservices and Events
  • 14. Extracting Microservices • Problem: Monolithic shared DB • Clients • Shipments • Items • Styles, SKUs stitchfix.com Styling app Warehouse app Merch app CS app Logistics app Payments service Profile service @randyshoup linkedin.com/in/randyshoup
  • 15. Extracting Microservices • Decouple applications / services from shared DB • Clients • Shipments • Items • Styles, SKUs stitchfix.com Styling app Warehouse app Merch app CS app Logistics app Payments service Profile service @randyshoup linkedin.com/in/randyshoup
  • 16. Extracting Microservices • Decouple applications / services from shared DB Styling app Warehouse app core_item core_sku core_client @randyshoup linkedin.com/in/randyshoup
  • 17. Extracting Microservices • Step 1: Create a service Styling app Warehouse app core_item core_sku core_client client-service @randyshoup linkedin.com/in/randyshoup
  • 18. Extracting Microservices • Step 2: Applications use the service Styling app Warehouse app core_item core_sku core_client client-service @randyshoup linkedin.com/in/randyshoup
  • 19. Extracting Microservices • Step 2: Applications use the service Styling app Warehouse app core_item core_sku core_client client-service Do NOT stop here! ① All the problems of a distributed system ② All the problems of a shared database ③ None of the benefits of microservices  @randyshoup linkedin.com/in/randyshoup
  • 20. Extracting Microservices • Step 3: Move data to private database Styling app Warehouse app core_item core_sku client-service core_client @randyshoup linkedin.com/in/randyshoup
  • 21. Extracting Microservices • Step 4: Rinse and Repeat Styling app Warehouse app core_sku client-service core_client item-service core_item @randyshoup linkedin.com/in/randyshoup
  • 22. Extracting Microservices • Step 4: Rinse and Repeat Styling app Warehouse app client-service core_client item-service core_item style-service core_sku @randyshoup linkedin.com/in/randyshoup
  • 23. Extracting Microservices • Step 4: Rinse and Repeat Styling app Warehouse app client-service core_client item-service core_item style-service core_sku @randyshoup linkedin.com/in/randyshoup
  • 24. Services and Events • Migrating to Microservices • Using Microservices and Events o Two Architectural Tools o Shared Data o Joins o Transactions
  • 25. Services and Events • Migrating to Microservices • Using Microservices and Events o Two Architectural Tools o Shared Data o Joins o Transactions
  • 26. System of Record • Single System of Record o Every piece of data is owned by a single service o That service is the canonical system of record for that data • Every other copy is a read-only, non-authoritative cache @randyshoup linkedin.com/in/randyshoup customer-service styling-service customer-search billing-service
  • 27. Events are First-Class • “A significant change in state” o Statement that some interesting thing occurred • Traditional 3-tier system o Presentation  interface / interaction o Application  stateless business logic o Persistence  database • Fourth fundamental building block o State changes  events o 0 | 1 | N consumers subscribe to the event, typically asynchronously @randyshoup linkedin.com/in/randyshoup
  • 28. Microservices and Events • Events are a first-class part of a service interface • A service interface includes o Synchronous request-response (REST, gRPC, etc) o Events the service produces o Events the service consumes o Bulk reads and writes (ETL) • The interface includes any mechanism for getting data in or out of the service (!) @randyshoup linkedin.com/in/randyshoup
  • 29. Services and Events • Migrating to Microservices • Using Microservices and Events o Two Architectural Tools o Shared Data o Joins o Transactions
  • 30. Shared Data • Monolithic database makes it easy to leverage shared data • Where does shared data go in a microservices world? @randyshoup linkedin.com/in/randyshoup
  • 31. Shared Data Option 1: Synchronous Lookup o Customer service owns customer data o Fulfillment service calls customer service in real time fulfillment-service customer-service @randyshoup linkedin.com/in/randyshoup
  • 32. Shared Data Option 2: Async event + local cache o Customer service owns customer data o Customer service sends address-updated event when customer address changes o Fulfillment service caches current customer address fulfillment-servicecustomer-service @randyshoup linkedin.com/in/randyshoup
  • 33. Shared Data Option 3: Shared metadata library o Read-only metadata, basically immutable o E.g., size schemas, colors, EU countries, US states, etc. receiving-serviceitem-service style-service @randyshoup linkedin.com/in/randyshoup
  • 34. Services and Events • Migrating to Microservices • Using Microservices and Events o Two Architectural Tools o Shared Data o Joins o Transactions
  • 35. Joins • Monolithic database makes it easy to join tables • Splitting the data across microservices makes joins very hard @randyshoup linkedin.com/in/randyshoup SELECT FROM A INNER JOIN B ON …
  • 36. Joins Option 1: Join in Client Application o Get a single customer from customer-service o Query matching orders for that customer from order-service Customers Orders order-history-page customer-service order-service @randyshoup linkedin.com/in/randyshoup
  • 37. Joins Option 2: Service that “Materializes the View” o Listen to events from item-service, events from order-service o Maintain denormalized join of items and orders together in local storage Items Order Feedback item-feedback-service item-service order-feedback-service @randyshoup linkedin.com/in/randyshoup
  • 38. Joins Many common systems do this • “Materialized view” in database systems • Most NoSQL systems • Search engines • Analytic systems @randyshoup linkedin.com/in/randyshoup
  • 39. Services and Events • Migrating to Microservices • Using Microservices and Events o Two Architectural Tools o Shared Data o Joins o Transactions
  • 40. Transactions • Monolithic database makes transactions across multiple entities easy • Splitting data across services makes transactions very hard @randyshoup linkedin.com/in/randyshoup BEGIN; INSERT INTO A …; UPDATE B...; COMMIT;
  • 41. “In general, application developers simply do not implement large scalable applications assuming distributed transactions.” -- Pat Helland Life After Distributed Transactions: An Apostate’s Opinion, 2007
  • 42. “Grownups don’t use distributed transactions” -- Pat Helland
  • 43. Workflows and Sagas • Transaction  Saga o Model the transaction as a state machine of atomic events • Reimplement as a workflow • Roll back with compensating operations in reverse A B C A B C @randyshoup linkedin.com/in/randyshoup
  • 44. Workflows and Sagas Many real-world systems work like this • Payment processing • Expense approval • Travel • Software development process @randyshoup linkedin.com/in/randyshoup
  • 45. Intermediate States Model intermediate states as part of your interface • Payment started, pending, complete • Expense submitted, approved, paid • Feature developed, reviewed, deployed, released @randyshoup linkedin.com/in/randyshoup
  • 46. Choreography No central coordinator o No central management of workflow state o State transitions entirely through events o Implicit “guarantees” for termination of the state machine @randyshoup linkedin.com/in/randyshoup Transport A B C
  • 47. Orchestration Workflow coordinator o Coordinator maintains state of workflow, guarantees termination o Coordinator triggers state transitions o Events (optionally) signal transitions @randyshoup linkedin.com/in/randyshoup Payment A B C
  • 48. Services and Events • Migrating to Microservices o When and Why to Migrate o How to Migrate • Using Microservices and Events o Two Architectural Tools o Shared Data o Joins o Transactions