More Related Content Similar to When, how and if to adopt Microservices, AWS Startup Day Cape Town 2018 (20) More from Amazon Web Services (20) When, how and if to adopt Microservices, AWS Startup Day Cape Town 20181. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
When, how and if to adopt
Microservices
BRADLEY ACAR, SOLUTIONS ARCHITECT | 13 SEPTEMBER 2018
2. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Monolithic Applications
3. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
The Monolith
“…a single-tiered software application in which the user interface and data
access code are combined into a single program from a single platform.
A monolithic application is self-contained, and independent from other
computing applications.”
- Wikipedia
4. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Where did they all come from?
5. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Monolith = “Traditional” Applications
• Applications developed to “best practices” and standards of the time
• Monolith <> poorly designed
• Applications didn’t need to be or weren’t designed to be distributed
• Application design constrained by resources
6. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Monolith = “Traditional” Applications
Pros:
• At first…
o Simple
o No over-engineering
• In-process latencies
• Single codebase
• Resource efficient at small
scale
Cons:
• Modularity is hard to enforce
as app grows
• Can only really scale up
• All or nothing deployment
• Database dependencies
• Long release cycles
• Slow to react to customer
demand
7. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Microservices
8. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
What microservices are…
“…the microservice architectural style is an approach to developing a
single application as a suite of small services, each running in its own
process and communicating with lightweight mechanisms, often an HTTP
resource API…”
- Martin Fowler
https://martinfowler.com/aboutMe.html
9. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
What microservices are…
“Independently deployable services that work together, modelled around a
business domain…”
- Sam Newman
10. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
What microservices are…
“The technical authority for a business capability”
- Udi Dahan
11. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Monolith development lifecycle
developers
releasetestbuild
delivery pipelineapp
12. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Microservice development lifecycle
developers delivery pipelinesservices
releasetestbuild
releasetestbuild
releasetestbuild
releasetestbuild
releasetestbuild
releasetestbuild
13. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
2001
Development transformation at Amazon: 2001+
2009+
monolithic
application + teams
microservices + 2 pizza teams
14. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Single-purpose
Connect only through APIs
Connect over HTTPS
Largely “black boxes” to each
other
Microservices
15. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Two-pizza teams
Full ownership
Full accountability
Aligned incentives
DevOps
“You build it, you run it”
16. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Managing Dependencies
Loose Coupling / High Cohesion
Encapsulation
17. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Think about: Coupling
18. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Types of coupling
• Afferent (Ca) and Efferent (Ce)
Measurement units of the degree of coupling
Who depends on you?… Who do you depend on?
• Platform Coupling
May be introduced by things like proprietary protocols or
components that are platform specific
• Temporal Coupling
Dealing with time-based dependencies between
collaborating system components, e.g. waiting operations
or sequential processing
• Spatial Coupling
Not having to know the location of your collaborating
services on the network and providing failover
mechanisms, e.g. Amazon Elastic Load Balancer
A B
A B
19. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Loose coupling?
• Coupling is a function of
multiple dimensions
• Need to make tradeoffs
Platform
Spatial
TemporalAfferent
Efferent
20. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Think about: Messaging
21. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Think about: Messaging
a Serverless example…
22. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Amazon Simple Queue Service (Amazon SQS)
• Simple enough to get started in minutes
• Highly reliable, always available, and durable
• Continuous scale allows burst loads with no
excess capacity
• Integrated with AWS platform with monitoring
and queue management
• Comprehensive security and compliance
“Worry-free managed
queues - simply and reliably
distribute any volume of
messages between
endpoints"
23. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Amazon SQS Features
High durability
with messages
persisted across
multiple AZs
High availability in
all AWS regions
Continuous and
unlimited scaling
Simplified
troubleshooting
with a Dead Letter
Queue
Integrated with
other AWS services
as a destination
> aws sqs create-queue --queue-name MyQueue
24. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Using AWS Lambda with Amazon SQS
1. Scheduled
time occurs
2. Lambda invoked
Lambda
function
CloudWatch Events
(time-based)
SQS
Queue
3. Pull messages from
queue
Lambda
function
CloudWatch Events
(time-based)
SQS
Queue
4. Pull message
from queue
3. Lambda invoked
n times
2. Execute Step Function
every minute
1. Scheduled
time occurs
25. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Amazon SQS as an Event Source (SQSaaES)
• Lambda polls the queue and when it detects new
messages, it invokes your Lambda function by
passing the messages as an event
• Full control over the queue processing settings
such as visibility timeouts, delay queues, redrive
policy, etc. Supports batch processing
• Lambda will gradually increase the queue polling
rate as long as queue polling results in fetching of
new messages
• Supports Identity and Resource based policy3. Lambda invoked
Lambda
function
SQS
Queue
2. Pull messages
from queue
1. Message arrives
on queue
26. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Amazon Simple Notification Service (Amazon SNS)
• Highly reliable, available, and durable pub-
sub service that delivers messages to
multiple destinations, including system and
mobile endpoints
• Continuous scale allows burst loads with no
excess capacity
• Integrated with AWS platform delivering
messages from services to subscribing
endpoints
• Comprehensive monitoring, security, and
compliance
“Simply and reliably distribute
any volume of messages and
event notifications anywhere”
27. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
> aws sns create-topic --name my-topic
Amazon SNS Key Features
High durability
with messages
persisted across
multiple AZs
High availability in
all AWS regions
Continuous and
unlimited scaling
Simplify
development with
filtered message
delivery
Easy monitoring
with CloudWatch,
with alarming
28. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Publish / Subscribe
• One logical publisher for a given domain event
• Fully enforces a consistent boundary
• Addresses multiple types of coupling
SNS
Topic
Service B
Service C
Service D
Service A
• Each subscriber can react to domain
events in their own bounded context
• SNS supports multiple subscription
channels – Lambda, SQS, HTTP/S,
Email, SMS, Mobile Push
29. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Mapping events to topics
Grey
Topic
Attr=
Blue
Grey
Publisher
Blue
Topic
Blue
Grey
Blue
Blue
Grey
Subscribers
Service C
Service D
Service E
Service F
Message type mapped to logical destination
30. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Amazon SNS Message Filters
• Publishers do not need to route message
• Subscribers do not need to filter for message of interest
• Lowers cost
SNS
Topic
Attr=
Grey
Attr=
Blue
Attr=
Blue
Attr=
Grey
Attr=
Blue
Attr=
Grey
Filter Policy
Attr=Grey
Filter Policy
Attr=Blue
Publisher
31. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Long Running Processes?
32. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Coordination by Function Chaining
33. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
“I want
try/catch/finally”
“I want to
select tasks based on data”
“I want to
retry failed tasks”
A
B C
A
?
“I want to
sequence tasks”
BA
“I want to
run tasks in parallel”
CBA
34. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
…makes it easy to coordinate the
components of distributed
applications using visual workflows
AWS Step Functions
35. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AWS Step Functions
“Serverless” workflow management with zero
administration
• Coordinate the components of distributed
applications and microservices using visual
workflows
• Keeps the orchestration out of the code!
• State management
• Automatically triggers and tracks each step, and
retries when there are errors
• Logs the state of each step, so when things do go
wrong, you can diagnose and debug problems
quickly
Task
Choice
Fail
Parallel
36. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Microservices messaging patterns
One-Way
Lambda
function
SQS Queue
Return Address
SQS QueueLambda
function
Request / Response
Lambda
function
SQS Queue
SNS
Topic
Service B
Service C
Service D
Service A
Publish / Subscribe
request
response
request
response
37. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Microviews
• Don’t forget about the user interface!
• If a microservice is the technical
authority for a business capability then
it is also the authority on how interacts
with the user
• Leverage composite user interfaces
B
A
C D
E
A B C D E
38. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Containers?
39. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Why do we love Containers?
Packaging Distribution Immutable
infrastructure
40. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Amazon Container Services
41. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Amazon Elastic Container Service
42. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Building an Ecosystem
43. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Helping Customers Scale their Containers
450+%
growth
Hundreds of millions
of containers started each week
millions
of container instances
44. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Customers are our key to innovation
50+
releases
since 2015
Customers
Release
Feedback /
New Use
Cases
Learn
Experiment,
Innovate,
& Build
Features
45. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Enable Focus on Applications
46. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Run containers without the need to manage
underlying infrastructure
47. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Changing Compute Consumption Model
No instances
to manage
Task
native API
Resource
based pricing
Simple, easy to use,
powerful – and new
consumption model
=
48. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Production Workloads on AWS
AWSVPC networking
mode
Advanced task
placement
Deep integration
with AWS platform
ECS CLI…{ }
Global footprint
Powerful scheduling engines
Auto scaling
CloudWatch metrics
Load balancers
49. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Fargate: Under the Hood
50. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Running Container
51. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
EC2 Instance
TaskTask
Task Task
EC2 Instance
TaskTask
Task Task
EC2 Instance
TaskTask
Task Task
EC2 Instance
TaskTask
Task Task
EC2 Instance
TaskTask
Task Task
Running Containers
52. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Scheduling and Orchestration
Cluster Manager Placement Engine
Running Containers at Scale with ECS
Availability Zone #1 Availability Zone #2 Availability Zone #3
53. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
ECS
AMI
Docker
agent
ECS
agent
ECSTaskECSTask
ECSTaskECSTask
EC2 Instance
54. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Scheduling and Orchestration
Cluster Manager Placement Engine
ECS
AMI
Docker
agent
ECS
agent
EC2 Instance
ECS
AMI
Docker
agent
ECS
agent
EC2 Instance
ECS
AMI
Docker
agent
ECS
agent
EC2 Instance
55. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Running Fargate Containers with ECS
56. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Elastic Container Service for Kubernetes (EKS)
57. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
57% of Kubernetes workloads
run on AWS today
—CNCF survey
58. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Availability
Zone 1
etcd
Master
etcd
Master
Availability
Zone 2
Availability
Zone 3
etcd
Master
59. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
mycluster.eks.amazonaws.com
Availability
Zone 1
Availability
Zone 2
Availability
Zone 3
kubectl
60. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
61. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Summary
Chances are YAGNI… Not everyone needs Microservices. If you have a well
defined domain then you don’t have to break the monolith apart entirely.
Don’t use a big bang approach. It’s an evolutionary journey.
Perhaps consider a monolith-first approach.
Identify your bounded contexts first.
Lead your microservices strategy from strategic perspective.
Model your microservices around business capabilities.
Leverage messaging services and publish subscribe patterns to provide strict
boundaries around your bounded contexts and use them to manage coupling
inside your application.
Editor's Notes © 2003 Microsoft Corporation. All rights reserved.
This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary. © 2003 Microsoft Corporation. All rights reserved.
This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.