Gilt, a global e-commerce company, implemented a sophisticated microservices architecture on AWS to handle millions of customers visiting their site at noon every day. The microservices architecture pattern enables independent service scaling, faster deployments, better fault isolation, and graceful degradation. In this session, Emerson Loureiro, Sr. Software Engineer at Gilt, will share Gilt's experiences and lessons learned during their evolution from a single monolithic Rails application in a traditional data center to more than 300 Scala/Java microservices deployed in the cloud. Derek Chiles, AWS Solutions Architect, will review best practices and recommended architectures for deploying microservices on AWS.
1 of 83
More Related Content
AWS re:Invent 2016: From Monolithic to Microservices: Evolving Architecture Patterns in the Cloud (ARC305)
2. What to Expect from the Session
• Why Microservices?
• Migration approaches and considerations
• Gilt’s journey to microservices on AWS
• Architecture patterns and best practices
5. Gilt
“How can we scale things up independently?”
“How can we arrange teams around strategic initiatives?”
“How can we make it easy and fast to push changes to
production?”
10. Monolithic Organization
Organized on technology capabilities
UI Team
DBA Team
App Logic Team
Web Tier
App Tier
DB
Organizational Structure Application Architecture
19. Auto Scaling Group
Typical Service Stack at Gilt
ELB
DNS
Docker registry
…
Amazon CloudWatch Metrics
Amazon SNS Topic
EC2 Instance
Service “X” VM
EC2 Instance
Service “X” VM
CloudWatch Log Group
23. No New Features on the Monolith
Database
StoreFront
UI
Browser
New
Microservice
New DB
Cart
Service
Account
Service
User
Service
24. Anti-Corruption Layer for Integration
ACL
Database
StoreFront
UI
Browser
New
Microservice
New DB
Cart
Service
Account
Service
User
Service
25. Cart
Service
Account
Service
Start With a Simple Existing Service…
Database
StoreFront
UI
Browser
User
Microservice
User DB
New
Microservice
New DB
User
Service
Client
26. Account
Service
User
Service
Client
…Move on to More Complicated Services
Cart
Microservice
Database
StoreFront
UI
Browser
User
Microservice
User DB
New
Microservice
New DB
ACL
Cart DB
Cart
Service
28. …The Monolith is Eventually Gone
Cart
Microservice
StoreFront
UI
Browser
User
Microservice
User DB
New
Microservice
New DB
Account
Microservice
Cart DB Account DB
33. Cross-Service Transactions
1) Avoid them
2) Use an optimistic model
• Accept eventual consistency
• Design for idempotency
• Detect conflicts and resolve later
• Ignore conflicts
3) Use a pessimistic model
• Create a transaction manager or distributed locking service
• Build transaction logic into the services
• Rethink your design
34. Aggregation
usr svc
Pull model Push model
Data Aggregation
Application
usr svc
Data
Aggregation
Application
Pub/Sub Composite
Composite Data Service
usr account cart
account svc cart svc
account svc
cart svc
Pub Sub
usr svc
account svc
cart svc
Data
Aggregation
Application
Push
Pull
35. Aggregation
usr svc
Pull model Push model
Data Aggregation
Application
usr svc
Data
Aggregation
Application
Pub/Sub Composite
Composite Data Service
usr account cart
account svc cart svc
account svc
cart svc
Pub Sub
usr svc
account svc
cart svc
Data
Aggregation
Application
Push
Pull
36. Aggregation
usr svc
Pull model Push model
Data Aggregation
Application
usr svc
Data
Aggregation
Application
Pub/Sub Composite
Composite Data Service
usr account cart
account svc cart svc
account svc
cart svc
Pub Sub
usr svc
account svc
cart svc
Data
Aggregation
Application
Push
Pull
37. Aggregation
usr svc
Pull model Push model
Data Aggregation
Application
usr svc
Data
Aggregation
Application
Pub/Sub Composite
Composite Data Service
usr account cart
account svc cart svc
account svc
cart svc
Pub Sub
usr svc
account svc
cart svc
Data
Aggregation
Application
Push
Pull
42. API Management
• Enforce API consistency
• Monitor key metrics
• Implement read-through caching
• Provide authentication and authorization
• Meter and throttle
43. Amazon API Gateway
• Enforce API consistency
• Monitor key metrics
• Implement read-through caching
• Provide authentication and authorization
• Meter and throttle
44. Amazon API Gateway for Microservices
Client
API Gateway
Monolith
on EC2
Microservice 1
(Lambda)
Microservice 2
(ELB+EC2)
Microservice 3
(AWS Elastic Beanstalk)
45. DO DON’T
• Add new methods
• Add optional params
• Deprecate
• Negotiate disruptive
changes
• Delete or rename
• Add required params
• Remove required params
• Mandate disruptive
changes
API Version Management
51. Elastic Beanstalk Application
Phased Rollout at Gilt Under the Hood
Blue-Green Deployments with Elastic Beanstalk
Environment (0.0.1)
Instance Instance Instance
Environment (0.0.2)
Instance Instance Instance
ELB
52. Elastic Beanstalk Application
Phased Rollout at Gilt Under the Hood
Blue-Green Deployments with Elastic Beanstalk
Environment (0.0.1)
Instance Instance Instance
Environment (0.0.2)
Instance Instance Instance
ELB
53. Elastic Beanstalk Application
Phased Rollout at Gilt Under the Hood
Blue-Green Deployments with Elastic Beanstalk
Environment (0.0.1)
Instance Instance Instance
Environment (0.0.2)
Instance Instance Instance
ELB
54. Elastic Beanstalk Application
Phased Rollout at Gilt Under the Hood
Blue-Green Deployments with Elastic Beanstalk
Environment (0.0.1)
Instance Instance Instance
Environment (0.0.2)
Instance Instance Instance
ELB
55. Elastic Beanstalk Application
Phased Rollout at Gilt Under the Hood
Blue-Green Deployments with Elastic Beanstalk
Environment (0.0.2)
Instance Instance Instance
ELB
56. Phased Rollout at Gilt Under the Hood
CodeDeploy Application
Canary Deployment Group Production Deployment GroupDevelopment Deployment Group
InstanceInstanceInstanceInstance
Production ELBDevelopment ELB
Gilt Production
Users
Production DNSDevelopment DNS
Testing in Production with CodeDeploy
57. Phased Rollout at Gilt Under the Hood
CodeDeploy Application
Canary Deployment Group Production Deployment GroupDevelopment Deployment Group
InstanceInstanceInstanceInstance
Production ELBDevelopment ELB
Gilt Production
Production DNS
UsersEngineers
Development DNS
Testing in Production with CodeDeploy
Promote Promote
58. Phased Rollout at Gilt Under the Hood
CodeDeploy Application
Canary Deployment Group Production Deployment GroupDevelopment Deployment Group
InstanceInstanceInstanceInstance
Production ELBDevelopment ELB
Gilt Production
UsersEngineers & QA
Production DNSDevelopment DNS
Testing in Production with CodeDeploy
Promote Promote
Dev, please
64. Logging
• Push your logs somewhere
• Have visibility on the whole life cycle
Deployment => instance startup => application => termination
S3 Elasticsearch CloudWatch
65. Logging
• Push your logs somewhere
• Have visibility on the whole life cycle
Deployment => instance startup => application => termination
• Separate your logs by service and by instance
S3 Elasticsearch CloudWatch
66. Logging At Gilt
Service
EC2 Instance
Service “X” VM
EC2 Instance
Service “X” VM
CloudWatch Log Group
Log Stream
Log Stream
Errors!
67. Aggregation Layer
Log Aggregation
CloudWatch Log Group
Log Stream
Log Stream
CloudWatch Log Group
Log Stream
Log Stream
CloudWatch Log Group
Log Stream
Log Stream
CloudWatch Log Group
Log Stream
Log Stream
CloudWatch Log Group
Log Stream
Log Stream
CloudWatch Log Group
Log Stream
Log Stream
CloudWatch Log Group
Log Stream
Log Stream
CloudWatch Log Group
Log Stream
Log Stream
CloudWatch Log Group
Log Stream
Log Stream
CloudWatch Log Group
Log Stream
Log Stream
+ + + + + =
68. Cleanup Service
EC2 Instance
Service “X” VM
EC2 Instance
Service “X” VM
CloudWatch Log Group
Log Stream
Log Stream
Service
EC2 Instance
Service “X” VM
EC2 Instance
Service “X” VM
CloudWatch Log Group
Log Stream
Log Stream
Log Aggregation At Gilt
Service
EC2 Instance
Service “X” VM
EC2 Instance
Service “X” VM
CloudWatch Log Group
Log Stream
Log Stream
LambdaAWS Elasticsearch
Kibana
Lambda
Delete!
Index!
Timer
70. Service Consumer Tenets
• Design for failure
• Plan to be throttled
• Plan to retry (w/ exponential backoff)
• Degrade gracefully
• Cache when appropriate
71. Service Provider Tenets
• Publish standard metrics
• Publish logs for aggregation
• Be prepared to throttle
• Implementation details are private
• Maintain backwards compatibility
74. Parallelize
for {
a <- callServiceA()
b <- callServiceB()
c <- callServiceC(a, b)
} yield c
val futureA = callServiceA()
val futureB = callServiceB()
for {
a <- futureA
b <- futureB
c <- callServiceC(a, b)
} yield c