© 2020, Amazon Web Services, Inc. or its Affiliates.
How to migrate an existing
application to serverless
Marcia Villalba
Developer Advocate AWS
@mavi888uy
© 2020, Amazon Web Services, Inc. or its Affiliates.
About me
AWS Developer Advocate
Working with serverless since 2015
Host of FooBar YouTube Channel
https://youtube.com/foobar_codes
@mavi888uy
© 2020, Amazon Web Services, Inc. or its Affiliates.© 2020, Amazon Web Services, Inc. or its Affiliates.
2 stories
rovio
Not that
successful story
Successful
story
© 2020, Amazon Web Services, Inc. or its Affiliates.
Serverless
”Serverless is a
methodology for
planning, building and
deploying software in a
way that maximizes value
by minimizing
undifferentiated heavy
lifting…”
Jeremy Daly
© 2020, Amazon Web Services, Inc. or its Affiliates.
What it means that something is serverless?
No managing infrastructure High availability built in
Pay for what you useScales automagically
© 2020, Amazon Web Services, Inc. or its Affiliates.© 2020, Amazon Web Services, Inc. or its Affiliates.
© 2020, Amazon Web Services, Inc. or its Affiliates.
Function as a Service (FaaS)
“AWS Lambda lets you run code without
provisioning or managing servers. ...
…Just upload your code and Lambda takes care
of everything required to run and scale your code
with high availability.
You can set up your code to automatically
trigger from other AWS services or call it directly
from any web or mobile app”
AWS – Lambda definition
AWS
Lambda
© 2020, Amazon Web Services, Inc. or its Affiliates.
How AWS Lambda works?
Event source Function Services
Node.js
Python
Java
C#
Go
Custom runtimes
Changes in
data state
Requests to
endpoints
Changes in
resource state
Amazon S3
DynamoDB
Amazon
SQS
APIs
Business
logic
© 2020, Amazon Web Services, Inc. or its Affiliates.
Managed services
Amazon S3
Amazon SQS
DynamoDB
© 2020, Amazon Web Services, Inc. or its Affiliates.
© 2020, Amazon Web Services, Inc. or its Affiliates.© 2020, Amazon Web Services, Inc. or its Affiliates.@theburningmonk
© 2020, Amazon Web Services, Inc. or its Affiliates.
Story 1
© 2020, Amazon Web Services, Inc. or its Affiliates.© 2020, Amazon Web Services, Inc. or its Affiliates.
© 2020, Amazon Web Services, Inc. or its Affiliates.
Managing unknowns
© 2020, Amazon Web Services, Inc. or its Affiliates.© 2020, Amazon Web Services, Inc. or its Affiliates.
Lack of technology knowledge
© 2020, Amazon Web Services, Inc. or its Affiliates.
Will this solve my problem?
© 2020, Amazon Web Services, Inc. or its Affiliates.
Foundational work
© 2020, Amazon Web Services, Inc. or its Affiliates.
Conway Law
”Any organization that designs a system will inevitably
produce a design whose structure is a copy of the
organization communication structure…”
Melvin Conway
Reverse Conway’s maneuver
Structure your organization to match the software you
would like to build
Small, agile teams – Two pizza teams
© 2020, Amazon Web Services, Inc. or its Affiliates.
Pick your tools
- Programming languages
- Deployment frameworks
- Developer tools
© 2020, Amazon Web Services, Inc. or its Affiliates.
Use Infrastructure as code
1. Minimize risk and bugs
2. Make infrastructure changes
repeatable and predictable
3. infrastructure changes using the
same tools as code changes
© 2020, Amazon Web Services, Inc. or its Affiliates.
CI/CD
© 2020, Amazon Web Services, Inc. or its Affiliates.
Check my other talk in the
conference later today J
© 2020, Amazon Web Services, Inc. or its Affiliates.
Monitoring and observability
Make sure that all your services send
metrics and logs
Pick a centralized tool for handling this
© 2020, Amazon Web Services, Inc. or its Affiliates.
Observability in AWS
CloudWatch
Insights
CloudWatch
Alarms
CloudWatch
Dashboard
CloudWatch
ServiceLens
© 2020, Amazon Web Services, Inc. or its Affiliates.
AWS Lambda Power Tools
Tracing - Decorators and utilities to trace Lambda function handlers, and both
synchronous and asynchronous functions
Logging - Structured logging made easier, and decorator to enrich structured
logging with key Lambda context details
Metrics - Custom Metrics created asynchronously via CloudWatch Embedded
Metric Format (EMF)
https://github.com/awslabs/aws-lambda-powertools-python
https://github.com/awslabs/aws-lambda-powertools-java
https://github.com/getndazn/dazn-lambda-powertools
© 2020, Amazon Web Services, Inc. or its Affiliates.© 2020, Amazon Web Services, Inc. or its Affiliates.
The big rewrite
Please don’t do it
© 2020, Amazon Web Services, Inc. or its Affiliates.
Story 2
© 2020, Amazon Web Services, Inc. or its Affiliates.
SCALING CHALLENGES
350
DONATIONS PER SECOND
© 2020, Amazon Web Services, Inc. or its Affiliates.
2016
Drupal 7 monolith
- Static content
- Pay-in fundraising
- Gift aid declaration
- Fundraiser gallery
- Contact us
Giving
Pages
Donate
© 2020, Amazon Web Services, Inc. or its Affiliates.
2017
Drupal 7 monolith
- Static content
- Contact us
Drupal 8
- Static content
Pay-in
fund-
raising
SMS
Gift aid
Fundraise
gallery
Giving
Pages
Donate
© 2020, Amazon Web Services, Inc. or its Affiliates.
2018
Drupal 8
- Static content
Pay-in fund-
raising
SMS
Gift aid
Giving
Pages
Donate
Contact
us
Red Nose
Comp
School
step calc
© 2020, Amazon Web Services, Inc. or its Affiliates.
2018
Drupal 8
- Static content
Pay-in fund-
raising
SMS
Gift aid
Contact
usGiving
Pages
Donate
Red Nose
Comp
School
step calc
Mailer Service
Postcode lookup
© 2020, Amazon Web Services, Inc. or its Affiliates.
2019
Drupal 8
- Static content
Pay-in fund-
raising
Contact
us
Payment Service layer
Image uploader service
Marketing preferences service
Mailer Service
Postcode lookup service
SMS Gift
Aid
Donate
Donate
bit.ly/cr-donate-blueprint
OLD VS NEW
March 2019 cost*
$5,393
March 2015 cost*
$83,908
*All hosting costs are paid for through corporate partnerships.
100% of public donations go to the projects we fund.
WE COULD DO
IT ALL AGAIN TOMORROW
Serverless services cost
$92
© 2020, Amazon Web Services, Inc. or its Affiliates.
comicrelief.com/donate
© 2020, Amazon Web Services, Inc. or its Affiliates.
The strangler pattern
© 2020, Amazon Web Services, Inc. or its Affiliates.
Strangler pattern
Monolith
Users
DB
Monolith
Service1
LB
Users
DBDB
Monolith
LB
Service1 Service n
Users
DB DB DB
© 2020, Amazon Web Services, Inc. or its Affiliates.© 2020, Amazon Web Services, Inc. or its Affiliates.
Steps for doing the strangler pattern
Migrating to serverless in 5 steps
© 2020, Amazon Web Services, Inc. or its Affiliates.© 2020, Amazon Web Services, Inc. or its Affiliates.
Step 1 – Find the seams in the code
”… a seam is a portion of the code that can be treated
in isolation and worked on without impacting the rest
of the codebase…”
Michael Feathers
© 2020, Amazon Web Services, Inc. or its Affiliates.
Step 1 – Find the bounded context in the code
Examples of seams in Java
Package content
- Organize your code inside different packages if its not done already
Example of seams in Javascript
Modules
- Be careful when moving things around if you don’t have unit tests.
© 2020, Amazon Web Services, Inc. or its Affiliates.© 2020, Amazon Web Services, Inc. or its Affiliates.
Big mess of Customer, orders and inventory business logic
OrderId Order info
CustomerId Customer
info…
CustomerId OrderId OrderId ItemId
ItemId Item info
DB manager
Authentication / User management
© 2020, Amazon Web Services, Inc. or its Affiliates.© 2020, Amazon Web Services, Inc. or its Affiliates.
ItemsCustomersOrders
OrderId Order info
CustomerId Customer
info…
CustomerId OrderId OrderId ItemId
ItemId Item info
DB manager
Authentication / User management
© 2020, Amazon Web Services, Inc. or its Affiliates.
Package1
Repository1
Package2
Repository2
PackageN
Repository
N
Monolithic application
DB
Step 2 – Organizing the data
© 2020, Amazon Web Services, Inc. or its Affiliates.© 2020, Amazon Web Services, Inc. or its Affiliates.
ItemsCustomers Orders
OrderId Order info
CustomerId Customer
info…
CustomerId OrderId
OrderId ItemId
ItemId Item info
DB order manager
DB customer
manager
DB items manager
Authentication / User management
© 2020, Amazon Web Services, Inc. or its Affiliates.
Step 3 – Move the code gracefully
1. Choose what to
migrate first
2. Rebuild it as a
serverless component
Tidy
Monolith
Users
DB
Tidy
Monolith
Service1
LB
Users
DBDB
© 2020, Amazon Web Services, Inc. or its Affiliates.
Where to start?
Strategy 1
Start with the least critical
part of your system
Strategy 2
Start with the part of the
system with the highest
return of invested time
🤔
© 2020, Amazon Web Services, Inc. or its Affiliates.
Recommended strategy
Start with the least critical
part of your system (2 or 3
services)
Then move the most critical
part
© 2020, Amazon Web Services, Inc. or its Affiliates.
Express tips to design serverless
applications
© 2020, Amazon Web Services, Inc. or its Affiliates.
Tidy Monolith
LB
Users
Logical microservice
AWS Lambda AWS Lambda
AWS Lambda AWS Lambda
AWS Lambda
DB
DB
Logical Microservices
© 2020, Amazon Web Services, Inc. or its Affiliates.
Microservices architectures
Mobile client
Client
IoT
API
Gateway
Shipping DB
Inventory DB
Store Front
Web App
Shipment
Query
Inventory
Query
Logical microservice
AWS Lambda
AWS Lambda
AWS Lambda
SQS
Amazon DynamoDB
© 2020, Amazon Web Services, Inc. or its Affiliates.
Integration options from AWS
Amazon
API Gateway
Amazon
SQS
Amazon
SNS
AWS
Step Functions
APIs Choreography Orchestration
Amazon
EventBridge
© 2020, Amazon Web Services, Inc. or its Affiliates.
APIs are the front door of microservices
© 2020, Amazon Web Services, Inc. or its Affiliates.
Microservices architectures
Shipment
serviceCustomer
service
API
Gateway
© 2020, Amazon Web Services, Inc. or its Affiliates.
Track status of data
and execution
Remove
redundant code
Build workflows to orchestrate everything
© 2020, Amazon Web Services, Inc. or its Affiliates.
Single responsibility principle
“A class should have only one reason to change”
Robert C. Martin – Uncle Bob
In the serverless worlds this means:
- Simpler functions – easier to know what they are doing
- Less code to test
- Single purpose functions are more secure
- Single purpose functions perform better
© 2020, Amazon Web Services, Inc. or its Affiliates.
Single responsibility principle
“A class should have only one reason to change”
Robert C. Martin – Uncle Bob
In the serverless worlds this means:
- Simpler functions – easier to know what they are doing
- Less code to test
- Single purpose functions are more secure
- Single purpose functions perform better
However, you need to find the right balance on
the size of the function – not to big or too small
© 2020, Amazon Web Services, Inc. or its Affiliates.
DB
Coordinating functions can be hard
Queue
© 2020, Amazon Web Services, Inc. or its Affiliates.
Turning functions into microservices
“I want to select functions based on data”
“I want to retry functions”
“I want try/catch/finally”
“I have code that runs for hours”
“I want to sequence functions”
“I want to run functions in parallel”
© 2020, Amazon Web Services, Inc. or its Affiliates.
AWS Step Functions
Resilient workflow automation
Built-in error handling
Powerful AWS service integration
First-class support for integrating with
your own services
Auditable execution history and visual monitoring
Fully-managed state machines on AWS
© 2020, Amazon Web Services, Inc. or its Affiliates.
AWS Cloud
House owners
AWS Step Functions workflow
Validate owner
Validate property
Validation Successful
Validation Not Successful
Validated?
Amazon API Gateway
Add a
property
Amazon EventBridge
Properties
service
Messaging
service
Validator service
© 2020, Amazon Web Services, Inc. or its Affiliates.
Choreography
Event-driven architectures
© 2020, Amazon Web Services, Inc. or its Affiliates.
Decouple state from code using messaging
Queues
Simple
Fully-managed
Any volume
Pub/sub
Simple
Fully-managed
Flexible
Amazon Simple
Queue Service
Amazon Simple
Notification
Service
Messaging
Synchronization
Rapid
Fully-managed
Real-time
Amazon
EventBridge
- Independent releases
- Scalability
- Modular code
- Easy to maintain and to work on
- Adds resiliency to the application
© 2020, Amazon Web Services, Inc. or its Affiliates.
So why we need decoupling?
© 2020, Amazon Web Services, Inc. or its Affiliates.
Event bus to help us to decouple our microservices
© 2020, Amazon Web Services, Inc. or its Affiliates.
Mobile client
Client
IoT
API
Gateway
Shipping DB
Inventory DB
Store Front
Web App
Shipment
Query
Inventory
Query
Logical microservice
AWS Lambda
AWS Lambda
AWS Lambda
SQS
Amazon DynamoDB
© 2020, Amazon Web Services, Inc. or its Affiliates.
Replace existing functionality with managed services
Amazon Cognito
Order service
Customer
service
Items service
Users
© 2020, Amazon Web Services, Inc. or its Affiliates.
Serverless analytics pipeline
Amazon Cognito
Amazon S3 Users
Amazon
Kinesis Data
Firehose
Amazon
Athena
AWS Glue Amazon
QuickSight
S3
Bucket
AWS Cloud
Client
© 2020, Amazon Web Services, Inc. or its Affiliates.
Step 4 - Breaking the database
Logical microservices should own their data
Migrate the data to the new database
Rethink how your data is stored – noSQL, files, SQL, ect.
© 2020, Amazon Web Services, Inc. or its Affiliates.
Step 5 – Breaking the APIs
We need to keep the APIS compatible after migration for our clients
We want to switch the traffic to the new service gradually
© 2020, Amazon Web Services, Inc. or its Affiliates.
Move traffic gradually to the new service
Tidy Monolith with
old service 1
Service1
Application Load
Balancer
Users
30% traffic
70% traffic
ALB Weighted Target Groups
© 2020, Amazon Web Services, Inc. or its Affiliates.
Closing remarks
© 2020, Amazon Web Services, Inc. or its Affiliates.
Steps start migrating
1 – Do the foundational work
2 – Move your monolith to the cloud if needed
3 – Find the seams for your code
4 – Organize the data layer
5 – Move the code to serverless
6 – Break the database
7 – Break the APIs
8 – Repeat from step 5 until 7 until you are done
© 2020, Amazon Web Services, Inc. or its Affiliates.
Thanks
Marcia Villalba
@mavi888uy
FooBar YouTube Channel
https://youtube.com/foobar_codes

20201013 - Serverless Architecture Conference - How to migrate your existing app to serverless?

  • 1.
    © 2020, AmazonWeb Services, Inc. or its Affiliates. How to migrate an existing application to serverless Marcia Villalba Developer Advocate AWS @mavi888uy
  • 2.
    © 2020, AmazonWeb Services, Inc. or its Affiliates. About me AWS Developer Advocate Working with serverless since 2015 Host of FooBar YouTube Channel https://youtube.com/foobar_codes @mavi888uy
  • 3.
    © 2020, AmazonWeb Services, Inc. or its Affiliates.© 2020, Amazon Web Services, Inc. or its Affiliates. 2 stories rovio Not that successful story Successful story
  • 4.
    © 2020, AmazonWeb Services, Inc. or its Affiliates. Serverless ”Serverless is a methodology for planning, building and deploying software in a way that maximizes value by minimizing undifferentiated heavy lifting…” Jeremy Daly
  • 5.
    © 2020, AmazonWeb Services, Inc. or its Affiliates. What it means that something is serverless? No managing infrastructure High availability built in Pay for what you useScales automagically
  • 6.
    © 2020, AmazonWeb Services, Inc. or its Affiliates.© 2020, Amazon Web Services, Inc. or its Affiliates.
  • 7.
    © 2020, AmazonWeb Services, Inc. or its Affiliates. Function as a Service (FaaS) “AWS Lambda lets you run code without provisioning or managing servers. ... …Just upload your code and Lambda takes care of everything required to run and scale your code with high availability. You can set up your code to automatically trigger from other AWS services or call it directly from any web or mobile app” AWS – Lambda definition AWS Lambda
  • 8.
    © 2020, AmazonWeb Services, Inc. or its Affiliates. How AWS Lambda works? Event source Function Services Node.js Python Java C# Go Custom runtimes Changes in data state Requests to endpoints Changes in resource state Amazon S3 DynamoDB Amazon SQS APIs Business logic
  • 9.
    © 2020, AmazonWeb Services, Inc. or its Affiliates. Managed services Amazon S3 Amazon SQS DynamoDB
  • 10.
    © 2020, AmazonWeb Services, Inc. or its Affiliates.
  • 11.
    © 2020, AmazonWeb Services, Inc. or its Affiliates.© 2020, Amazon Web Services, Inc. or its Affiliates.@theburningmonk
  • 12.
    © 2020, AmazonWeb Services, Inc. or its Affiliates. Story 1
  • 13.
    © 2020, AmazonWeb Services, Inc. or its Affiliates.© 2020, Amazon Web Services, Inc. or its Affiliates.
  • 14.
    © 2020, AmazonWeb Services, Inc. or its Affiliates. Managing unknowns
  • 15.
    © 2020, AmazonWeb Services, Inc. or its Affiliates.© 2020, Amazon Web Services, Inc. or its Affiliates. Lack of technology knowledge
  • 16.
    © 2020, AmazonWeb Services, Inc. or its Affiliates. Will this solve my problem?
  • 17.
    © 2020, AmazonWeb Services, Inc. or its Affiliates. Foundational work
  • 18.
    © 2020, AmazonWeb Services, Inc. or its Affiliates. Conway Law ”Any organization that designs a system will inevitably produce a design whose structure is a copy of the organization communication structure…” Melvin Conway Reverse Conway’s maneuver Structure your organization to match the software you would like to build Small, agile teams – Two pizza teams
  • 19.
    © 2020, AmazonWeb Services, Inc. or its Affiliates. Pick your tools - Programming languages - Deployment frameworks - Developer tools
  • 20.
    © 2020, AmazonWeb Services, Inc. or its Affiliates. Use Infrastructure as code 1. Minimize risk and bugs 2. Make infrastructure changes repeatable and predictable 3. infrastructure changes using the same tools as code changes
  • 21.
    © 2020, AmazonWeb Services, Inc. or its Affiliates. CI/CD
  • 22.
    © 2020, AmazonWeb Services, Inc. or its Affiliates. Check my other talk in the conference later today J
  • 23.
    © 2020, AmazonWeb Services, Inc. or its Affiliates. Monitoring and observability Make sure that all your services send metrics and logs Pick a centralized tool for handling this
  • 24.
    © 2020, AmazonWeb Services, Inc. or its Affiliates. Observability in AWS CloudWatch Insights CloudWatch Alarms CloudWatch Dashboard CloudWatch ServiceLens
  • 25.
    © 2020, AmazonWeb Services, Inc. or its Affiliates. AWS Lambda Power Tools Tracing - Decorators and utilities to trace Lambda function handlers, and both synchronous and asynchronous functions Logging - Structured logging made easier, and decorator to enrich structured logging with key Lambda context details Metrics - Custom Metrics created asynchronously via CloudWatch Embedded Metric Format (EMF) https://github.com/awslabs/aws-lambda-powertools-python https://github.com/awslabs/aws-lambda-powertools-java https://github.com/getndazn/dazn-lambda-powertools
  • 26.
    © 2020, AmazonWeb Services, Inc. or its Affiliates.© 2020, Amazon Web Services, Inc. or its Affiliates. The big rewrite Please don’t do it
  • 27.
    © 2020, AmazonWeb Services, Inc. or its Affiliates. Story 2
  • 28.
    © 2020, AmazonWeb Services, Inc. or its Affiliates.
  • 29.
  • 30.
    © 2020, AmazonWeb Services, Inc. or its Affiliates. 2016 Drupal 7 monolith - Static content - Pay-in fundraising - Gift aid declaration - Fundraiser gallery - Contact us Giving Pages Donate
  • 31.
    © 2020, AmazonWeb Services, Inc. or its Affiliates. 2017 Drupal 7 monolith - Static content - Contact us Drupal 8 - Static content Pay-in fund- raising SMS Gift aid Fundraise gallery Giving Pages Donate
  • 32.
    © 2020, AmazonWeb Services, Inc. or its Affiliates. 2018 Drupal 8 - Static content Pay-in fund- raising SMS Gift aid Giving Pages Donate Contact us Red Nose Comp School step calc
  • 33.
    © 2020, AmazonWeb Services, Inc. or its Affiliates. 2018 Drupal 8 - Static content Pay-in fund- raising SMS Gift aid Contact usGiving Pages Donate Red Nose Comp School step calc Mailer Service Postcode lookup
  • 34.
    © 2020, AmazonWeb Services, Inc. or its Affiliates. 2019 Drupal 8 - Static content Pay-in fund- raising Contact us Payment Service layer Image uploader service Marketing preferences service Mailer Service Postcode lookup service SMS Gift Aid Donate
  • 35.
  • 36.
    OLD VS NEW March2019 cost* $5,393 March 2015 cost* $83,908 *All hosting costs are paid for through corporate partnerships. 100% of public donations go to the projects we fund.
  • 37.
    WE COULD DO ITALL AGAIN TOMORROW Serverless services cost $92
  • 38.
    © 2020, AmazonWeb Services, Inc. or its Affiliates. comicrelief.com/donate
  • 39.
    © 2020, AmazonWeb Services, Inc. or its Affiliates. The strangler pattern
  • 40.
    © 2020, AmazonWeb Services, Inc. or its Affiliates. Strangler pattern Monolith Users DB Monolith Service1 LB Users DBDB Monolith LB Service1 Service n Users DB DB DB
  • 41.
    © 2020, AmazonWeb Services, Inc. or its Affiliates.© 2020, Amazon Web Services, Inc. or its Affiliates. Steps for doing the strangler pattern Migrating to serverless in 5 steps
  • 42.
    © 2020, AmazonWeb Services, Inc. or its Affiliates.© 2020, Amazon Web Services, Inc. or its Affiliates. Step 1 – Find the seams in the code ”… a seam is a portion of the code that can be treated in isolation and worked on without impacting the rest of the codebase…” Michael Feathers
  • 43.
    © 2020, AmazonWeb Services, Inc. or its Affiliates. Step 1 – Find the bounded context in the code Examples of seams in Java Package content - Organize your code inside different packages if its not done already Example of seams in Javascript Modules - Be careful when moving things around if you don’t have unit tests.
  • 44.
    © 2020, AmazonWeb Services, Inc. or its Affiliates.© 2020, Amazon Web Services, Inc. or its Affiliates. Big mess of Customer, orders and inventory business logic OrderId Order info CustomerId Customer info… CustomerId OrderId OrderId ItemId ItemId Item info DB manager Authentication / User management
  • 45.
    © 2020, AmazonWeb Services, Inc. or its Affiliates.© 2020, Amazon Web Services, Inc. or its Affiliates. ItemsCustomersOrders OrderId Order info CustomerId Customer info… CustomerId OrderId OrderId ItemId ItemId Item info DB manager Authentication / User management
  • 46.
    © 2020, AmazonWeb Services, Inc. or its Affiliates. Package1 Repository1 Package2 Repository2 PackageN Repository N Monolithic application DB Step 2 – Organizing the data
  • 47.
    © 2020, AmazonWeb Services, Inc. or its Affiliates.© 2020, Amazon Web Services, Inc. or its Affiliates. ItemsCustomers Orders OrderId Order info CustomerId Customer info… CustomerId OrderId OrderId ItemId ItemId Item info DB order manager DB customer manager DB items manager Authentication / User management
  • 48.
    © 2020, AmazonWeb Services, Inc. or its Affiliates. Step 3 – Move the code gracefully 1. Choose what to migrate first 2. Rebuild it as a serverless component Tidy Monolith Users DB Tidy Monolith Service1 LB Users DBDB
  • 49.
    © 2020, AmazonWeb Services, Inc. or its Affiliates. Where to start? Strategy 1 Start with the least critical part of your system Strategy 2 Start with the part of the system with the highest return of invested time 🤔
  • 50.
    © 2020, AmazonWeb Services, Inc. or its Affiliates. Recommended strategy Start with the least critical part of your system (2 or 3 services) Then move the most critical part
  • 51.
    © 2020, AmazonWeb Services, Inc. or its Affiliates. Express tips to design serverless applications
  • 52.
    © 2020, AmazonWeb Services, Inc. or its Affiliates. Tidy Monolith LB Users Logical microservice AWS Lambda AWS Lambda AWS Lambda AWS Lambda AWS Lambda DB DB Logical Microservices
  • 53.
    © 2020, AmazonWeb Services, Inc. or its Affiliates. Microservices architectures Mobile client Client IoT API Gateway Shipping DB Inventory DB Store Front Web App Shipment Query Inventory Query Logical microservice AWS Lambda AWS Lambda AWS Lambda SQS Amazon DynamoDB
  • 54.
    © 2020, AmazonWeb Services, Inc. or its Affiliates. Integration options from AWS Amazon API Gateway Amazon SQS Amazon SNS AWS Step Functions APIs Choreography Orchestration Amazon EventBridge
  • 55.
    © 2020, AmazonWeb Services, Inc. or its Affiliates. APIs are the front door of microservices
  • 56.
    © 2020, AmazonWeb Services, Inc. or its Affiliates. Microservices architectures Shipment serviceCustomer service API Gateway
  • 57.
    © 2020, AmazonWeb Services, Inc. or its Affiliates. Track status of data and execution Remove redundant code Build workflows to orchestrate everything
  • 58.
    © 2020, AmazonWeb Services, Inc. or its Affiliates. Single responsibility principle “A class should have only one reason to change” Robert C. Martin – Uncle Bob In the serverless worlds this means: - Simpler functions – easier to know what they are doing - Less code to test - Single purpose functions are more secure - Single purpose functions perform better
  • 59.
    © 2020, AmazonWeb Services, Inc. or its Affiliates. Single responsibility principle “A class should have only one reason to change” Robert C. Martin – Uncle Bob In the serverless worlds this means: - Simpler functions – easier to know what they are doing - Less code to test - Single purpose functions are more secure - Single purpose functions perform better However, you need to find the right balance on the size of the function – not to big or too small
  • 60.
    © 2020, AmazonWeb Services, Inc. or its Affiliates. DB Coordinating functions can be hard Queue
  • 61.
    © 2020, AmazonWeb Services, Inc. or its Affiliates. Turning functions into microservices “I want to select functions based on data” “I want to retry functions” “I want try/catch/finally” “I have code that runs for hours” “I want to sequence functions” “I want to run functions in parallel”
  • 62.
    © 2020, AmazonWeb Services, Inc. or its Affiliates. AWS Step Functions Resilient workflow automation Built-in error handling Powerful AWS service integration First-class support for integrating with your own services Auditable execution history and visual monitoring Fully-managed state machines on AWS
  • 63.
    © 2020, AmazonWeb Services, Inc. or its Affiliates. AWS Cloud House owners AWS Step Functions workflow Validate owner Validate property Validation Successful Validation Not Successful Validated? Amazon API Gateway Add a property Amazon EventBridge Properties service Messaging service Validator service
  • 64.
    © 2020, AmazonWeb Services, Inc. or its Affiliates. Choreography Event-driven architectures
  • 65.
    © 2020, AmazonWeb Services, Inc. or its Affiliates. Decouple state from code using messaging Queues Simple Fully-managed Any volume Pub/sub Simple Fully-managed Flexible Amazon Simple Queue Service Amazon Simple Notification Service Messaging Synchronization Rapid Fully-managed Real-time Amazon EventBridge - Independent releases - Scalability - Modular code - Easy to maintain and to work on - Adds resiliency to the application
  • 66.
    © 2020, AmazonWeb Services, Inc. or its Affiliates. So why we need decoupling?
  • 67.
    © 2020, AmazonWeb Services, Inc. or its Affiliates. Event bus to help us to decouple our microservices
  • 68.
    © 2020, AmazonWeb Services, Inc. or its Affiliates. Mobile client Client IoT API Gateway Shipping DB Inventory DB Store Front Web App Shipment Query Inventory Query Logical microservice AWS Lambda AWS Lambda AWS Lambda SQS Amazon DynamoDB
  • 69.
    © 2020, AmazonWeb Services, Inc. or its Affiliates. Replace existing functionality with managed services Amazon Cognito Order service Customer service Items service Users
  • 70.
    © 2020, AmazonWeb Services, Inc. or its Affiliates. Serverless analytics pipeline Amazon Cognito Amazon S3 Users Amazon Kinesis Data Firehose Amazon Athena AWS Glue Amazon QuickSight S3 Bucket AWS Cloud Client
  • 71.
    © 2020, AmazonWeb Services, Inc. or its Affiliates. Step 4 - Breaking the database Logical microservices should own their data Migrate the data to the new database Rethink how your data is stored – noSQL, files, SQL, ect.
  • 72.
    © 2020, AmazonWeb Services, Inc. or its Affiliates. Step 5 – Breaking the APIs We need to keep the APIS compatible after migration for our clients We want to switch the traffic to the new service gradually
  • 73.
    © 2020, AmazonWeb Services, Inc. or its Affiliates. Move traffic gradually to the new service Tidy Monolith with old service 1 Service1 Application Load Balancer Users 30% traffic 70% traffic ALB Weighted Target Groups
  • 74.
    © 2020, AmazonWeb Services, Inc. or its Affiliates. Closing remarks
  • 75.
    © 2020, AmazonWeb Services, Inc. or its Affiliates. Steps start migrating 1 – Do the foundational work 2 – Move your monolith to the cloud if needed 3 – Find the seams for your code 4 – Organize the data layer 5 – Move the code to serverless 6 – Break the database 7 – Break the APIs 8 – Repeat from step 5 until 7 until you are done
  • 76.
    © 2020, AmazonWeb Services, Inc. or its Affiliates. Thanks Marcia Villalba @mavi888uy FooBar YouTube Channel https://youtube.com/foobar_codes