Microservices are not for everyone! If you're a small shop, a monolith provides a great amount of value and reduces the complexities involved. However as your company grows, this monolith becomes more difficult to maintain. We’ll look at how microservices allow you to easily deploy and debug atomic pieces of infrastructure which allows for increased velocity in reliable, tested, and consistent deploys. We’ll look into key metrics you can use to identify the right time to begin the transition from monolith to microservices.
2. “The Monolith”
Monoliths can be GOOD when you are starting
out
Always build to keep things as simple as
possible
When your application or company grows,
Monoliths begin slowing you down.
Let’s look at the challenges as you grow..
3. Challenges with monolithic software
Long Build/Test/Release
Cycles
(who broke the build?)
Operations
is a nightmare
(module X is failing, who’s
the owner?)
Difficult to scale
New releases
take months
Long time to add
new features
Architecture is hard to
maintain and evolve
Lack of innovation
Frustrated customers
Lack of agility
4. Long Build/Test/Release
Cycles
(who broke the build?)
Operations
is a nightmare
(module X is failing, who’s
the owner?)
Difficult to scale
New releases
take months
Long time to add
new features
Architecture is hard to
maintain and evolve
Lack of innovation
Frustrated customers
Lack of agility
Challenges with monolithic software
5. Long Build/Test/Release
Cycles
(who broke the build?)
Operations
is a nightmare
(module X is failing, who’s
the owner?)
Difficult to scale
New releases
take months
Long time to add
new features
Architecture is hard to
maintain and evolve
Lack of innovation
Frustrated customers
Lack of agility
Challenges with monolithic software
11. Silo’d functional teams à silo’d application
architectures
Image from Martin Fowler’s article on microservices, at
http://martinfowler.com/articles/microservices.html
No alterations other than cropping.
Permission to reproduce: http://martinfowler.com/faq.html
12. Cross functional teams à self-contained
services
Image from Martin Fowler’s article on microservices, at
http://martinfowler.com/articles/microservices.html
No alterations other than cropping.
Permission to reproduce: http://martinfowler.com/faq.html
13. Full ownership
Full accountability
Aligned incentives
“DevOps”
Non-pizza image from Martin Fowler’s article on microservices, at
http://martinfowler.com/articles/microservices.html
No alterations other than cropping.
Permission to reproduce: http://martinfowler.com/faq.html
Cross functional teams à self-contained
services
(“Two-pizza teams”)
21. It’s a journey…
Expect challenges along the way…
• Understanding of business domains
• Eventual Consistency
• Service discovery
• Lots of moving parts requires
increased coordination
• Complexity of testing / deploying /
operating a distributed system
• Cultural transformation
22. = 50 million deployments a year
Thousands of teams
× Microservice architecture
× Continuous delivery
× Multiple environments
(5708 per hour, or every 0.63 second)
26. “service-oriented
architecture
composed of
loosely coupled
elements
that have
bounded contexts”
You can update the
services independently;
updating one service
doesn’t require changing
any other services.
Adrian Cockcroft (VP of Cloud Architecture @
AWS, former Cloud Architect at Netflix)
27. “service-oriented
architecture
composed of
loosely coupled
elements
that have
bounded contexts” Self-contained; you can
update the code without
knowing anything about
the internals of other
microservices
Adrian Cockcroft (VP of Cloud Architecture @
AWS, former Cloud Architect at Netflix)
31. Public API
POST /restaurants
GET /restaurants
Application/Logic
(code, libraries, etc)
Data Store
(eg, RDS, DynamoDB
ElastiCache, ElasticSearch)
Anatomy of a Microservice
35. Elastic Compute Cloud (EC2)
Virtual Servers in the Cloud
§ Resizable Compute Capacity
§ Complete control of your computing resources
§ Reduces time to obtain and boot new server
instances to minutes
§ Choose from 30+ different instance types
§ Scale as your requirements change
§ Pay only for what you use
Compute
41. Elastic Beanstalk vs. DIY
Your code
HTTP server
Application server
Language interpreter
Operating system
Host
Elastic Beanstalk configures
each EC2 instance in your
environment with the
components necessary to run
applications for the selected
platform. No more worrying
about logging into instances to
install and configure your
application stack.
Focus on building your
application
Provided by you
Provided and managed by Elastic Beanstalk
On-instance configuration
42. EC2 Container Service
Run and Manage Docker Containers
§ A high performance container management service
for running Docker containers on EC2 instances
§ Use the built in scheduler, write your own, or use a
third-party scheduler
§ Integrates with other services like ELB and EBS
§ No additional charge
§ EC2 Container Registry
Compute
46. Lambda
Run Code in Response to Events
§ Runs code in response to triggers such as S3
upload, DynamoDB updates, Kinesis streams,
and API Gateway requests
§ Automatically scales
§ You only need to provide the code; there is no
infrastructure to manage
§ Pay only for what you use
Compute
47. Lambda
automatically
scales
Upload your code
(Java, JavaScript,
Python)
Pay for only
the compute
time
you use
(sub-second
metering)
Set up your code to
trigger from other
AWS services,
webservice calls, or
app activity
48. Application Services
API Gateway
Build, Publish and Manage APIs
§ Performance at any scale via worldwide edge locations,
traffic throttling, and API output caching
§ Monitor API activity
§ Integrates with Lambda functions
§ Run multiple versions of the same API
§ Fully Managed
49. Create a unified
API frontend for
multiple
micro-services
…as well as
monitoring,
logging,
rollbacks,
client SDK
generation…
Authenticate
and authorize
requests
Handles DDoS
protection and
API throttling
50. DynamoDB
Predictable and Scalable NoSQL Data Store
§ Fast, fully-managed NoSQL Database Service
§ Capable of handling any amount of data
§ Durable and Highly Available
§ All SSD storage
§ Simple and Cost Effective
Database
55. Principle 1
Microservices only
rely on each other’s
public API
“Contracts” by NobMouse. No alterations other than cropping.
https://www.flickr.com/photos/nobmouse/4052848608/
Image used with permissions under Creative Commons license 2.0, Attribution
Generic License (https://creativecommons.org/licenses/by/2.0/)
56. Micro-service A Micro-service B
public API public API
Principle 1:
Microservices only rely on each other’s public API
57. public API public API
Micro-service A Micro-service B
Principle 1:
Microservices only rely on each other’s public API
Hide your data!
58. public API public API
Nope!
Micro-service A Micro-service B
Principle 1:
Microservices only rely on each other’s public API
Hide your data!
59. public API public API
Micro-service A Micro-service B
Principle 1:
Microservices only rely on each other’s public API
Hide your data!
60. Principle 1:
Microservices only rely on each other’s public API
storeRestaurant (id, name, cuisine)
Version 1.0.0
public API
Micro-service A
Evolve API in backward-compatible way .. And document!
61. Principle 1:
Microservices only rely on each other’s public API
storeRestaurant (id, name, cuisine)
storeRestaurant (id, name, cuisine)
storeRestaurant (id, name, arbitrary_metadata)
addReview (restaurantId, rating, comments)
Version 1.0.0
Version 1.1.0
public API
Micro-service A
Evolve API in backward-compatible way .. And document!
62. storeRestaurant (id, name, cuisine)
storeRestaurant (id, name, cuisine)
storeRestaurant (id, name, arbitrary_metadata)
addReview (restaurantId, rating, comments)
storeRestaurant (id, name, arbitrary_metadata)
addReview (restaurantId, rating, comments)
Version 1.0.0
Version 1.1.0
Version 2.0.0
public API
Micro-service A
Evolve API in backward-compatible way .. And document!
Principle 1:
Microservices only rely on each other’s public API
63. Principle 2
Use the right tool for the
job
“Tools #2” by Juan Pablo Olmo. No alterations other than cropping.
https://www.flickr.com/photos/juanpol/1562101472/
Image used with permissions under Creative Commons license 2.0, Attribution
Generic License (https://creativecommons.org/licenses/by/2.0/)
64. public API public API
DynamoDB
Micro-service A Micro-service B
Embrace polyglot persistence
Principle 2:
Use the right tool for the job
65. public API public API
DynamoDB
Micro-service A Micro-service B
Amazon
Elasticsearch
Service
Embrace polyglot persistence
Principle 2:
Use the right tool for the job
66. public API public API
RDS
Aurora
Micro-service A Micro-service B
Amazon
Elasticsearch
Service
Embrace polyglot persistence
Principle 2:
Use the right tool for the job
67. public API public API
RDS
Aurora
Micro-service A Micro-service B
Amazon
Elasticsearch
Service
Embrace polyglot programming frameworks
Principle 2:
Use the right tool for the job
68. public API public API
RDS
Aurora
Micro-service A Micro-service B
Amazon
Elasticsearch
Service
Embrace polyglot programming frameworks
Principle 2:
Use the right tool for the job
69. Principle 3
Secure Your Services
“security” by Dave Bleasdale. No alterations other than cropping.
https://www.flickr.com/photos/sidelong/3878741556/
Image used with permissions under Creative Commons license 2.0,
Attribution Generic License (https://creativecommons.org/licenses/by/2.0/)
70. • Defense-in-depth
• Network level (e.g. VPC, Security Groups, TLS)
• Server/container-level
• App-level
• IAM policies
• Gateway (“Front door”)
• API Throttling
• Authentication & Authorization
• Client-to-service, as well as service-to-service
• API Gateway: custom Lambda authorizers
• Token-based auth (JWT tokens, OAuth 2.0)
• IAM-based Authentication
• Secrets management
• S3 bucket policies + KMS + IAM
• Open-source tools (e.g. Vault, Keywhiz)
API Gateway
Principle 3:
Secure your services
71. Principle 4
Be a good citizen
within the ecosystem
“Lamington National Park, rainforest” by Jussarian. No alterations other than cropping.
https://www.flickr.com/photos/kerr_at_large/87771074/
Image used with permissions under Creative Commons license 2.0,
Attribution Generic License (https://creativecommons.org/licenses/by/2.0/)
72. Hey Sally, we need to call
your micro-service to
fetch restaurants details.
Sure Paul. Which APIs you need to
call? Once I know better your use
cases I’ll give you permission to
register your service as a client on
our service’s directory entry.
Micro-service A Micro-service B
public API public API
Principle 4:
Be a good citizen within the ecosystem
Proper retries with
exponential backoff
73. Restaurant
Micro-service
15 TPS100 TPS5 TPS20 TPS
Before we let you call our
micro-service we need to
understand your use case,
expected load (TPS) and
accepted latency
Have clear SLAs
Principle 4:
Be a good citizen within the ecosystem
74. Distributed monitoring and tracing
• “Is the service meeting its SLA?”
• “Which services were involved in a request?”
• “How did downstream dependencies perform?”
Shared metrics
• e.g. request time, time to first byte
Distributed tracing
• e.g. Zipkin, OpenTracing
User-experience metrics
Distributed monitoring, logging, and tracing
Principle 4:
Be a good citizen within the ecosystem
76. AWS X-Ray
traces
requests made
to your
application
X-Ray service
X-Ray
combines the
data gathered
from each
service into
singular units
called traces
View the
service map to
see trace data
such as
latencies,
HTTP
statuses, and
metadata for
Drill into the
service
showing
unusual
behavior to
identify the
root issue
X-Ray collects
data about the
request from each
of the underlying
applications
services it passes
through
78. Principles of Microservices
1. Rely only on the public API
Ÿ Hide your data
Ÿ Document your APIs
Ÿ Define a versioning strategy
2. Use the right tool for the job
Ÿ Container journey? (use ECS)
Ÿ Polyglot persistence (data layer)
Ÿ Polyglot frameworks (app layer)
3. Secure your services
Ÿ Defense-in-depth
Ÿ Authentication/authorization
6. Automate everything
Ÿ Adopt DevOps
4. Be a good citizen within the ecosystem
Ÿ Have SLAs
Ÿ Distributed monitoring, logging,
tracing
5. More than just technology transformation
Ÿ Embrace organizational change
Ÿ Favor small focused dev teams
79. It’s a journey…
Expect challenges along the way…
• Understanding of business domains
• Coordinating txns across multiple
services
• Eventual Consistency
• Service discovery
• Lots of moving parts requires
increased coordination
• Complexity of testing / deploying /
operating a distributed system
• Cultural transformation
80. AWS resources:
• Microservices without the Servers
https://aws.amazon.com/blogs/compute/
microservices-without-the-servers
• Microservices with ECS:
https://aws.amazon.com/blogs/compute/using-amazon-
api-gateway-with-microservices-deployed-on-amazon-ecs/
• Serverless Service Discovery:
https://aws.amazon.com/blogs/developer/
serverless-service-discovery-part-1-get-started/
• ECS Service Discovery:
https://aws.amazon.com/blogs/compute/
service-discovery-an-amazon-ecs-reference-architecture/
• Serverless Webapp - Reference Architecture:
https://github.com/awslabs/lambda-refarch-webapp
• Zombie Microservices Workshop:
https://github.com/awslabs/aws-lambda-zombie-workshop
Additional Resources