SlideShare uma empresa Scribd logo
1 de 26
Baixar para ler offline
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
How to refactor a monolith to
serverless in 8 steps
Yan Cui
A P I 3 1 0 - R
Principal Consultant
THEBURNINGMONK LTD
Agenda
Eight steps to refactor a monolith to serverless
Walkthrough of a real-world example
Live discussion
Related breakouts
SVS215-R Build observability into a serverless application
SVS215-R1 Build observability into a serverless application
API313 Nondisruptive strategies for application migration
API315-R Application integration patterns for microservices
API315-R1 Application integration patterns for microservices
API315-R2 Application integration patterns for microservices
CMY301 Performing chaos engineering in a serverless world
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Ask questions at any time
Step 1: Reverse Conway’s maneuver
• Conway’s law: “Organizations which design systems . . . are constrained to produce designs
which are copies of the communication structures of these organizations.”
• Structure your organization to match the software you want to produce
• Create small, autonomous teams that are empowered and entrusted to run their services
• Recall Amazon’s mantra of “two pizza teams”
• Trust, but verify
• Provide guidance and context over centralized control and gatekeeping
• Create a success story first, a pathfinder
• Accept that your teams would need to skill up
Step 2: Identify service boundaries
• Start with low-risk, noncritical business processes
• Identify boundaries within the monolith and carve them out into separate services
• A service should be the authority of some business process
• Services are autonomous
• Services have clear boundaries
• Services own their data and are the authoritative sources for those data
• Services are loosely coupled through shared contracts and schema
• Beware the “entity service“ antipattern
Step 2: Identify service boundaries
Step 3: Organize your codebase
• Do not have one repo per function
Step 3: Organize your codebase
Step 3: Organize your codebase
• Do not have one repo per function
• One repo per service
• One deployment stack (both functions and other resources)
• One CI/CD pipeline
• Shared infrastructure in separate repo
• Reference shared resources through CFN outputs/exports, SSM parameters, etc.
• Share code through shared libraries (NPM, Maven, NuGet, etc.)
• Shared code vs. shared service
• Monorepo
• Great for small teams; prioritizes speed of iteration
• Requires discipline and good tooling
Step 4: Pick your tools
• Deployment frameworks, CI tool, monitoring, alerting, etc.
• There is no “best tool for X”; pick the best one for you and stick to it
• Maximize institutional knowledge
• Use deployment framework for AWS Lambda; don’t build your own
• Serverless
• AWS Serverless Application Model (AWS SAM)
• AWS Cloud Development Kit
• . . .
• How you deploy your code should be consistent across all your projects
Step 5: Keep functions simple
• Follow the single responsibility principle
• It’s easy to see what a function does
• Single-purposed functions are more secure
• Single-purposed functions have better cold-start performance
Step 6: Move to new services gracefully
• Maintain application programming interface (API) compatibility
• Switch traffic to new service gradually
• Services should own their data, but you should remove risks in the migration process
• Move ownership of the business function to the new service first
• Migrate data to the new database later
• Prefer synchronizing data over synchronous API calls
Step 6: Move to new services gracefully
Step 6: Move to new services gracefully
Step 6: Move to new services gracefully
Step 6: Move to new services gracefully
• Maintain API compatibility
• Switch traffic to new service gradually
• Services should own their data, but you should remove risks in the migration process
• Move ownership of the business function to the new service first
• Migrate data to the new database later
• Prefer synchronizing data over synchronous API calls
• Be mindful of GDPR
Step 7: Rethink testing
• Different failure modes to a monolith
• Unit tests have low return on investment
• Focus on integration tests
• Use temporary stacks for end-to-end tests
Step 8: Build resilience into the system
• Build observability into the system
• Use short and adaptive timeouts
• Use queues to amortize traffic spikes between services
• Use sagas to manage distributed transactions
• Use circuit breaks to prevent cascade failures
• Use bulkheads to isolate blast radius
• Employ chaos engineering practices to understand your system’s weaknesses
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
8 Steps to refactor a monolith to serverless
1. Apply Reverse Conway’s Maneuver
2. Identify service boundaries
3. Organize your codebase
4. Pick your tools
5. Keep your functions simple
6. Move to new services gracefully
7. Rethink testing
8. Build resilience into the system
Thank you!
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Yan Cui
@theburningmonk
https://theburningmonk.com
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.

Mais conteúdo relacionado

Mais procurados

Mais procurados (20)

How to build observability into a serverless application
How to build observability into a serverless applicationHow to build observability into a serverless application
How to build observability into a serverless application
 
What makes me to migrate entire VPC JAWS PANKRATION 2021
What makes me to migrate entire VPC JAWS PANKRATION 2021What makes me to migrate entire VPC JAWS PANKRATION 2021
What makes me to migrate entire VPC JAWS PANKRATION 2021
 
Stop calling everything serverless!
Stop calling everything serverless!Stop calling everything serverless!
Stop calling everything serverless!
 
Serverless security: defense against the dark arts
Serverless security: defense against the dark artsServerless security: defense against the dark arts
Serverless security: defense against the dark arts
 
(SEC202) Best Practices for Securely Leveraging the Cloud
(SEC202) Best Practices for Securely Leveraging the Cloud(SEC202) Best Practices for Securely Leveraging the Cloud
(SEC202) Best Practices for Securely Leveraging the Cloud
 
Serverless a superpower for frontend developers
Serverless a superpower for frontend developersServerless a superpower for frontend developers
Serverless a superpower for frontend developers
 
AWS Multiple Account Management
AWS Multiple Account ManagementAWS Multiple Account Management
AWS Multiple Account Management
 
Serverless Design Patterns (London Dev Community)
Serverless Design Patterns (London Dev Community)Serverless Design Patterns (London Dev Community)
Serverless Design Patterns (London Dev Community)
 
Serverless Summit 21 - Resilient serverless architecture on AWS
Serverless Summit 21 - Resilient serverless architecture on AWSServerless Summit 21 - Resilient serverless architecture on AWS
Serverless Summit 21 - Resilient serverless architecture on AWS
 
Serverless - When to FaaS?
Serverless - When to FaaS?Serverless - When to FaaS?
Serverless - When to FaaS?
 
How to build a social network on Serverless (AWS Community Summit)
How to build a social network on Serverless (AWS Community Summit)How to build a social network on Serverless (AWS Community Summit)
How to build a social network on Serverless (AWS Community Summit)
 
AWS re:Invent 2016: Application Lifecycle Management in a Serverless World (S...
AWS re:Invent 2016: Application Lifecycle Management in a Serverless World (S...AWS re:Invent 2016: Application Lifecycle Management in a Serverless World (S...
AWS re:Invent 2016: Application Lifecycle Management in a Serverless World (S...
 
Security in serverless world
Security in serverless worldSecurity in serverless world
Security in serverless world
 
You Can’t Protect What You Can’t See: AWS Security Monitoring & Compliance Va...
You Can’t Protect What You Can’t See: AWS Security Monitoring & Compliance Va...You Can’t Protect What You Can’t See: AWS Security Monitoring & Compliance Va...
You Can’t Protect What You Can’t See: AWS Security Monitoring & Compliance Va...
 
Patterns and practices for building resilient serverless applications.pdf
Patterns and practices for building resilient serverless applications.pdfPatterns and practices for building resilient serverless applications.pdf
Patterns and practices for building resilient serverless applications.pdf
 
Serverless Security: What's Left to Protect?
Serverless Security: What's Left to Protect?Serverless Security: What's Left to Protect?
Serverless Security: What's Left to Protect?
 
Serverless Architecture
Serverless ArchitectureServerless Architecture
Serverless Architecture
 
Why your next serverless project should use AWS AppSync
Why your next serverless project should use AWS AppSyncWhy your next serverless project should use AWS AppSync
Why your next serverless project should use AWS AppSync
 
You wouldn't build a toast, would you?
You wouldn't build a toast, would you?You wouldn't build a toast, would you?
You wouldn't build a toast, would you?
 
GitHub's Latest: Automation and More
GitHub's Latest: Automation and MoreGitHub's Latest: Automation and More
GitHub's Latest: Automation and More
 

Semelhante a API310 - How to refactor a monolith to serverless in 8 steps

AperiStorageResourceManager
AperiStorageResourceManagerAperiStorageResourceManager
AperiStorageResourceManager
Robert Wipfel
 
[QCon London 2020] The Future of Cloud Native API Gateways - Richard Li
[QCon London 2020] The Future of Cloud Native API Gateways - Richard Li[QCon London 2020] The Future of Cloud Native API Gateways - Richard Li
[QCon London 2020] The Future of Cloud Native API Gateways - Richard Li
Ambassador Labs
 

Semelhante a API310 - How to refactor a monolith to serverless in 8 steps (20)

Deploying at will - SEI
 Deploying at will - SEI Deploying at will - SEI
Deploying at will - SEI
 
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
 
The 7 deadly sins of micro services
The 7 deadly sins of micro servicesThe 7 deadly sins of micro services
The 7 deadly sins of micro services
 
Technology insights: Decision Science Platform
Technology insights: Decision Science PlatformTechnology insights: Decision Science Platform
Technology insights: Decision Science Platform
 
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
 
The 7 deadly sins of micro services
The 7 deadly sins of micro servicesThe 7 deadly sins of micro services
The 7 deadly sins of micro services
 
Disruptive Trends in Application Development
Disruptive Trends in Application DevelopmentDisruptive Trends in Application Development
Disruptive Trends in Application Development
 
Making Cloud Deployment A Reality For End-To-End Policy Administration
Making Cloud Deployment A Reality For End-To-End Policy AdministrationMaking Cloud Deployment A Reality For End-To-End Policy Administration
Making Cloud Deployment A Reality For End-To-End Policy Administration
 
CI/CD for Serverless and Containerized Applications (DEV309-R1) - AWS re:Inve...
CI/CD for Serverless and Containerized Applications (DEV309-R1) - AWS re:Inve...CI/CD for Serverless and Containerized Applications (DEV309-R1) - AWS re:Inve...
CI/CD for Serverless and Containerized Applications (DEV309-R1) - AWS re:Inve...
 
Better application architecture with #microservices and #BPM (as APaaS)
Better application architecture with #microservices and #BPM (as APaaS)Better application architecture with #microservices and #BPM (as APaaS)
Better application architecture with #microservices and #BPM (as APaaS)
 
AperiStorageResourceManager
AperiStorageResourceManagerAperiStorageResourceManager
AperiStorageResourceManager
 
Microservices: Yes or not?
Microservices: Yes or not?Microservices: Yes or not?
Microservices: Yes or not?
 
From Zero to Serverless (CoderCruise 2018)
From Zero to Serverless (CoderCruise 2018)From Zero to Serverless (CoderCruise 2018)
From Zero to Serverless (CoderCruise 2018)
 
Serverless: Market Overview and Investment Opportunities
Serverless: Market Overview and Investment OpportunitiesServerless: Market Overview and Investment Opportunities
Serverless: Market Overview and Investment Opportunities
 
AWS Community Day - Vitaliy Shtym - Pragmatic Container Security
AWS Community Day - Vitaliy Shtym - Pragmatic Container SecurityAWS Community Day - Vitaliy Shtym - Pragmatic Container Security
AWS Community Day - Vitaliy Shtym - Pragmatic Container Security
 
Pragmatic container security - DEM11-R - AWS re:Inforce 2019
Pragmatic container security - DEM11-R - AWS re:Inforce 2019 Pragmatic container security - DEM11-R - AWS re:Inforce 2019
Pragmatic container security - DEM11-R - AWS re:Inforce 2019
 
Tech Talk on Cloud Computing
Tech Talk on Cloud ComputingTech Talk on Cloud Computing
Tech Talk on Cloud Computing
 
[QCon London 2020] The Future of Cloud Native API Gateways - Richard Li
[QCon London 2020] The Future of Cloud Native API Gateways - Richard Li[QCon London 2020] The Future of Cloud Native API Gateways - Richard Li
[QCon London 2020] The Future of Cloud Native API Gateways - Richard Li
 
Modernizing Testing as Apps Re-Architect
Modernizing Testing as Apps Re-ArchitectModernizing Testing as Apps Re-Architect
Modernizing Testing as Apps Re-Architect
 

Mais de Yan Cui

How serverless changes the cost paradigm
How serverless changes the cost paradigmHow serverless changes the cost paradigm
How serverless changes the cost paradigm
Yan Cui
 

Mais de Yan Cui (20)

How to win the game of trade-offs
How to win the game of trade-offsHow to win the game of trade-offs
How to win the game of trade-offs
 
How to choose the right messaging service
How to choose the right messaging serviceHow to choose the right messaging service
How to choose the right messaging service
 
How to choose the right messaging service for your workload
How to choose the right messaging service for your workloadHow to choose the right messaging service for your workload
How to choose the right messaging service for your workload
 
Lessons from running AppSync in prod
Lessons from running AppSync in prodLessons from running AppSync in prod
Lessons from running AppSync in prod
 
Serverless observability - a hero's perspective
Serverless observability - a hero's perspectiveServerless observability - a hero's perspective
Serverless observability - a hero's perspective
 
How to ship customer value faster with step functions
How to ship customer value faster with step functionsHow to ship customer value faster with step functions
How to ship customer value faster with step functions
 
How serverless changes the cost paradigm
How serverless changes the cost paradigmHow serverless changes the cost paradigm
How serverless changes the cost paradigm
 
Build social network in 4 weeks
Build social network in 4 weeksBuild social network in 4 weeks
Build social network in 4 weeks
 
Patterns and practices for building resilient serverless applications
Patterns and practices for building resilient serverless applicationsPatterns and practices for building resilient serverless applications
Patterns and practices for building resilient serverless applications
 
How to bring chaos engineering to serverless
How to bring chaos engineering to serverlessHow to bring chaos engineering to serverless
How to bring chaos engineering to serverless
 
Migrating existing monolith to serverless in 8 steps
Migrating existing monolith to serverless in 8 stepsMigrating existing monolith to serverless in 8 steps
Migrating existing monolith to serverless in 8 steps
 
Building a social network in under 4 weeks with Serverless and GraphQL
Building a social network in under 4 weeks with Serverless and GraphQLBuilding a social network in under 4 weeks with Serverless and GraphQL
Building a social network in under 4 weeks with Serverless and GraphQL
 
FinDev as a business advantage in the post covid19 economy
FinDev as a business advantage in the post covid19 economyFinDev as a business advantage in the post covid19 economy
FinDev as a business advantage in the post covid19 economy
 
How to improve lambda cold starts
How to improve lambda cold startsHow to improve lambda cold starts
How to improve lambda cold starts
 
What can you do with lambda in 2020
What can you do with lambda in 2020What can you do with lambda in 2020
What can you do with lambda in 2020
 
A chaos experiment a day, keeping the outage away
A chaos experiment a day, keeping the outage awayA chaos experiment a day, keeping the outage away
A chaos experiment a day, keeping the outage away
 
How to debug slow lambda response times
How to debug slow lambda response timesHow to debug slow lambda response times
How to debug slow lambda response times
 
What can you do with lambda in 2020
What can you do with lambda in 2020What can you do with lambda in 2020
What can you do with lambda in 2020
 
How to ship customer value faster with step functions
How to ship customer value faster with step functionsHow to ship customer value faster with step functions
How to ship customer value faster with step functions
 
Debugging Lambda timeouts
Debugging Lambda timeoutsDebugging Lambda timeouts
Debugging Lambda timeouts
 

Último

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Último (20)

Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 

API310 - How to refactor a monolith to serverless in 8 steps

  • 1.
  • 2. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. How to refactor a monolith to serverless in 8 steps Yan Cui A P I 3 1 0 - R Principal Consultant THEBURNINGMONK LTD
  • 3. Agenda Eight steps to refactor a monolith to serverless Walkthrough of a real-world example Live discussion
  • 4. Related breakouts SVS215-R Build observability into a serverless application SVS215-R1 Build observability into a serverless application API313 Nondisruptive strategies for application migration API315-R Application integration patterns for microservices API315-R1 Application integration patterns for microservices API315-R2 Application integration patterns for microservices CMY301 Performing chaos engineering in a serverless world
  • 5. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
  • 6. Ask questions at any time
  • 7. Step 1: Reverse Conway’s maneuver • Conway’s law: “Organizations which design systems . . . are constrained to produce designs which are copies of the communication structures of these organizations.” • Structure your organization to match the software you want to produce • Create small, autonomous teams that are empowered and entrusted to run their services • Recall Amazon’s mantra of “two pizza teams” • Trust, but verify • Provide guidance and context over centralized control and gatekeeping • Create a success story first, a pathfinder • Accept that your teams would need to skill up
  • 8. Step 2: Identify service boundaries • Start with low-risk, noncritical business processes • Identify boundaries within the monolith and carve them out into separate services • A service should be the authority of some business process • Services are autonomous • Services have clear boundaries • Services own their data and are the authoritative sources for those data • Services are loosely coupled through shared contracts and schema • Beware the “entity service“ antipattern
  • 9. Step 2: Identify service boundaries
  • 10. Step 3: Organize your codebase • Do not have one repo per function
  • 11. Step 3: Organize your codebase
  • 12. Step 3: Organize your codebase • Do not have one repo per function • One repo per service • One deployment stack (both functions and other resources) • One CI/CD pipeline • Shared infrastructure in separate repo • Reference shared resources through CFN outputs/exports, SSM parameters, etc. • Share code through shared libraries (NPM, Maven, NuGet, etc.) • Shared code vs. shared service • Monorepo • Great for small teams; prioritizes speed of iteration • Requires discipline and good tooling
  • 13. Step 4: Pick your tools • Deployment frameworks, CI tool, monitoring, alerting, etc. • There is no “best tool for X”; pick the best one for you and stick to it • Maximize institutional knowledge • Use deployment framework for AWS Lambda; don’t build your own • Serverless • AWS Serverless Application Model (AWS SAM) • AWS Cloud Development Kit • . . . • How you deploy your code should be consistent across all your projects
  • 14. Step 5: Keep functions simple • Follow the single responsibility principle • It’s easy to see what a function does • Single-purposed functions are more secure • Single-purposed functions have better cold-start performance
  • 15. Step 6: Move to new services gracefully • Maintain application programming interface (API) compatibility • Switch traffic to new service gradually • Services should own their data, but you should remove risks in the migration process • Move ownership of the business function to the new service first • Migrate data to the new database later • Prefer synchronizing data over synchronous API calls
  • 16. Step 6: Move to new services gracefully
  • 17. Step 6: Move to new services gracefully
  • 18. Step 6: Move to new services gracefully
  • 19. Step 6: Move to new services gracefully • Maintain API compatibility • Switch traffic to new service gradually • Services should own their data, but you should remove risks in the migration process • Move ownership of the business function to the new service first • Migrate data to the new database later • Prefer synchronizing data over synchronous API calls • Be mindful of GDPR
  • 20. Step 7: Rethink testing • Different failure modes to a monolith • Unit tests have low return on investment • Focus on integration tests • Use temporary stacks for end-to-end tests
  • 21. Step 8: Build resilience into the system • Build observability into the system • Use short and adaptive timeouts • Use queues to amortize traffic spikes between services • Use sagas to manage distributed transactions • Use circuit breaks to prevent cascade failures • Use bulkheads to isolate blast radius • Employ chaos engineering practices to understand your system’s weaknesses
  • 22. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
  • 23.
  • 24. 8 Steps to refactor a monolith to serverless 1. Apply Reverse Conway’s Maneuver 2. Identify service boundaries 3. Organize your codebase 4. Pick your tools 5. Keep your functions simple 6. Move to new services gracefully 7. Rethink testing 8. Build resilience into the system
  • 25. Thank you! © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. Yan Cui @theburningmonk https://theburningmonk.com
  • 26. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.