Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2017, Amazon Web Services, Inc. or its Affiliat...
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2017, Amazon Web Services, Inc. or its Affiliat...
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2017, Amazon Web Services, Inc. or its Affiliat...
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Microservices at AWS
Service-Oriented Architectu...
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Monolithic vs. SOA vs. Microservices
Microservic...
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Monolithic vs. SOA vs. Microservices
SOA
Coarse-...
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Microservice Challenges
Distributed computing is...
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Key Elements of Microservices…
Some core concept...
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Key Elements of Microservices…
Eliminates any lo...
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Key Elements of Microservices…
Each microservice...
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Microservices Benefits
Fast to develop
Rapid dep...
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Two-pizza teams
Full ownership
Full accountabili...
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
How do Two Pizza Teams work?
We call them “Servi...
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2017, Amazon Web Services, Inc. or its Affiliat...
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Challenge: Centralized Database
user-svc account...
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Centralized Database – Anti-pattern
Applications...
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Decentralized Data Stores
account-svccart-svc
Dy...
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Challenge: Transactional Integrity
Polyglot pers...
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Best Practice: Use Correlation IDs
09-02-2015 15...
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Best Practice: Microservice owns Rollback
Every ...
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Event-Driven: DynamoDB Streams
If async, conside...
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Challenge: Report Errors / Rollback
What if func...
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Challenge: Report Errors / Rollback
ERROR
Dynamo...
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Challenge: Code Error
Lambda Execution Error bec...
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Beware: Stream Model with AWS Lambda
DynamoDB St...
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
MDM – Keep Data Consistent
Databases
AWS Lambda
...
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2017, Amazon Web Services, Inc. or its Affiliat...
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Storage & DB options in AWS
Amazon
RDS
Amazon
Dy...
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Service
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Challenge: What Service to Use?
Many problems ca...
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Determine Your Non-Functional Requirements
Requi...
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Map Non-Functional Requirements to Services
Serv...
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Finalizing Your Data Store Choices
After mapping...
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Challenge: Reporting and Analytics
Data is now s...
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Aggregation
usr svc
Pull model
Data Aggregation
...
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Aggregation
usr svc
Pull model Push model
Data A...
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Aggregation
usr svc
Pull model Push model
Data A...
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Aggregation
usr svc
Pull model Push model
Data A...
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
A Few Thoughts
Use Non-Functional Requirements t...
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Learn from our Customers
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Thank You for Attending the Webinar
We hope you ...
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2017, Amazon Web Services, Inc. or its Affiliat...
Upcoming SlideShare
Loading in …5
×

A Modern Data Architecture for Microservices

5,121 views

Published on

A Modern Data Architecture for Microservices

  1. 1. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. A Modern Data Architecture for Microservices Blair Layton Business Development Manager Database Services
  2. 2. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. What to Expect from the Session • Microservices at AWS • Overview and Challenges • Key Elements and Benefits • Two Pizza Teams • Data Architecture Challenges • Transactions and Rollbacks • Streams • Master Data Management • Choosing a Data Store • Aggregation
  3. 3. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Microservices at AWS
  4. 4. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Microservices at AWS Service-Oriented Architecture (SOA) Single-purpose Connect only through APIs Connect over HTTPS “Microservices”
  5. 5. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Monolithic vs. SOA vs. Microservices Microservices: Many very small components Business logic lives inside of single service domain Simple wire protocols(HTTP with XML/JSON) API driven with SDKs/Clients SOA: Fewer more sophisticated components Business logic can live across domains Enterprise Service Bus like layers between services Middleware
  6. 6. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Monolithic vs. SOA vs. Microservices SOA Coarse-grained Microservices Fine-grained Monolithic Single Unit
  7. 7. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Microservice Challenges Distributed computing is hard Transactions • Multiple Databases across multiple services Eventual Consistency Lots of moving parts Service discovery Increase coordination Increase message routing
  8. 8. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Key Elements of Microservices… Some core concepts are common to all services • Service registration, discovery, wiring, administration • State management • Service metadata • Service versioning • Caching Low Friction Deployment Automated Management and Monitoring
  9. 9. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Key Elements of Microservices… Eliminates any long-term commitment to a technology stack Polyglot ecosystem Polyglot persistence • Decompose Databases • Database per microservice pattern Allows easy use of Canary and Blue-Green deployments
  10. 10. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Key Elements of Microservices… Each microservice is: • Elastic: scales up or down independently of other services • Resilient: services provide fault isolation boundaries • Composable: uniform APIs for each service • Minimal: highly cohesive set of entities • Complete: loosely coupled with other services Controller A Controller B Controller A Controller B Q Q Tight Coupling Loose Coupling
  11. 11. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Microservices Benefits Fast to develop Rapid deployment Parallel development & deployment Closely integrated with DevOps • Now ”DevSecOps” Improved scalability, availability & fault tolerance More closely aligned to business domain
  12. 12. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Two-pizza teams Full ownership Full accountability Aligned incentives “DevOps” Principles of the Two Pizza Team
  13. 13. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. How do Two Pizza Teams work? We call them “Service teams” Own the “primitives” they build: • Product planning (roadmap) • Development work • Operational/Client support work “You build it, you run it” Part of a larger concentrated org (Amazon.com, AWS, Prime, etc)
  14. 14. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Data Architecture Challenges
  15. 15. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Challenge: Centralized Database user-svc account-svccart-svc DB Applications often have a monolithic data store • Difficult to make schema changes • Technology lock-in • Vertical scaling • Single point of failure
  16. 16. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Centralized Database – Anti-pattern Applications often have a monolithic data store • Difficult to make schema changes • Technology lock-in • Vertical scaling • Single point of failure user-svc account-svccart-svc DB
  17. 17. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Decentralized Data Stores account-svccart-svc DynamoDB RDS user-svc ElastiCache RDS Polyglot Persistence Each service chooses it’s data store technology Low impact schema changes Independent scalability Data is gated through the service API
  18. 18. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Challenge: Transactional Integrity Polyglot persistence generally translates into eventual consistency Asynchronous calls allow non-blocking, but returns need to be handled properly How about transactional integrity? • Event-sourcing – Capture changes as sequence of events • Staged commit • Rollback on failure ERROR STATE? ROLLBACK?
  19. 19. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Best Practice: Use Correlation IDs 09-02-2015 15:03:24 ui-svc INFO [uuid-123] …… 09-02-2015 15:03:25 catalog-svc INFO [uuid-123] …… 09-02-2015 15:03:26 checkout-svc ERROR [uuid-123] …… 09-02-2015 15:03:27 payment-svc INFO [uuid-123] …… 09-02-2015 15:03:27 shipping-svc INFO [uuid-123] …… ui-svc catalog- svc checkout- svc shipping- svc payment- svc request correlation id: “uuid-123” correlation id: “uuid-123”
  20. 20. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Best Practice: Microservice owns Rollback Every microservice should expose it’s own “rollback” method This method could just rollback changes, or trigger subsequent actions • Could send a notification If you implement staged commit, also expose a commit function Microservice Function 1 Rollback Commit (optional)
  21. 21. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Event-Driven: DynamoDB Streams If async, consider event-driven approach with DynamoDB Streams Don’t need to manage function execution failure, DDB Streams automatically retries until successful “Attach” yourself to the data of interest Microservice
  22. 22. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Challenge: Report Errors / Rollback What if functions fail? (business logic failure, not code failure) Create a “Transaction Manager” microservice that notifies all relevant microservices to rollback or take action DynamoDB is the trigger for the clean-up function (could be SQS, Kinesis etc.) Use Correlation ID to identify relations mm-svc Transaction Manager Function DDB Streams API Call Error Table
  23. 23. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Challenge: Report Errors / Rollback ERROR DynamoDB Error Table Transaction Manager Function Kinesis Error Stream SQS Error Queue Rollback (correlation-id) Rollback (correlation-id) Rollback (correlation-id) Rollback (correlation-id)
  24. 24. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Challenge: Code Error Lambda Execution Error because of faulty code Leverage Cloudwatch Logs to process error message and call Transaction Manager Set Cloudwatch Logs Metric Filter to look for Error/Exception and call Lambda Handler upon Alarm state ui-svc Cloudwatch Logs Cloudwatch Alarm Transaction Manager Function
  25. 25. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Beware: Stream Model with AWS Lambda DynamoDB Streams and Kinesis streams directly work with AWS Lambda, however AWS Lambda needs to acknowledge processing the message correctly If Lambda fails to process the message, the stream horizon will not be moved forward, creating a “jam” Solution: Monitor AWS Lambda Error Cloudwatch Metric and react when error rate of same “Correlation ID” keeps increasing
  26. 26. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. MDM – Keep Data Consistent Databases AWS Lambda “Cleanup” Function Cloudwatch Scheduled Event Perform Master Data Management (MDM) to keep data consistent Create AWS Lambda function to check consistencies across microservices and “cleanup” Create Cloudwatch Event to schedule the function (e.g. hourly basis)
  27. 27. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Choosing a Datastore
  28. 28. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Storage & DB options in AWS Amazon RDS Amazon DynamoDB Amazon Elasticsearch Service Amazon S3 Amazon Kinesis Amazon ElastiCache In-Memory NoSQL SQL SearchObject Streaming Amazon Redshift Amazon Glacier
  29. 29. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Service
  30. 30. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Challenge: What Service to Use? Many problems can be solved with NoSQL, RDBMS or even in-memory cache technologies Non-functional requirements can help identify appropriate services Solution: Classify your organizations non-functional requirements and map them to service capabilities
  31. 31. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Determine Your Non-Functional Requirements Requirement Latency > 1s 200 ms -1s 20 ms – 200 ms < 20 ms Durability 99.99 99.999 99.9999 > 99.9999 Storage Scale < 256 GB 256 GB – 1 TB 1 TB – 16 TB > 16 TB Availability 99 99.9 99.95 > 99.95 Data Class Public Important Secret Top Secret Recoverability 12 – 24 hours 1 – 12 hours 5 mins – 1 hour < 5 mins Skills None Average Good Expert This is only an example. Your company’s classifications will be different There will be other requirements such as regulatory compliance too.
  32. 32. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Map Non-Functional Requirements to Services Service Latency Durability Storage Availability Recoverability from AZ Failure (RPO, RTO) RDS < 100 ms > 99.8 (EBS) 6 TB (SQL Server 16 TB) 99.95 0s and 90s (MAZ) Aurora < 100 ms > 99.9 64 TB > 99.95 0s and < 30s (MAZ) Aurora + ElastiCache < 1 ms > 99.9 64 TB > 99.95 0s and < 30s (MAZ) DynamoDB < 10 ms > 99.9 No Limit > 99.99 0s and 0s DynamoDB / DAX < 1 ms > 99.9 No Limit > 99.99 0s and 0s ElastiCache Redis < 1 ms N/A 3.5 TiB 99.95 0s and < 30s (MAZ) Elasticsearch < 200 ms > 99.8 (EBS) 150 TB 99.95 0s and < 30s (Zone Aware) S3 < 500 ms 99.999999999 No Limit 99.99 0s and 0s The information below is not exact and does not represent SLAs
  33. 33. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Finalizing Your Data Store Choices After mapping your non-functional requirements to services you should have a short list to choose from Functional requirements such as geospatial data and query support will refine the list further You may institute standards to make data store selection simpler and also make it easier for people to move between teams, e.g Redis over Memcached and PostgreSQL over MySQL. These can still be overridden, but require justification to senior management
  34. 34. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Challenge: Reporting and Analytics Data is now spread across a number of isolated polyglot data stores Consolidation and aggregation required Solution: Pull data from required microservices, push data to data aggregation service, use pub/sub, or use a composite service (anti-pattern).
  35. 35. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Aggregation usr svc Pull model Data Aggregation Application account svc cart svc Pull
  36. 36. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Aggregation usr svc Pull model Push model Data Aggregation Application account svc cart svc usr svc account svc cart svc Data Aggregation Application Push Pull
  37. 37. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Aggregation usr svc Pull model Push model Data Aggregation Application usr svc Data Aggregation Application Pub/Sub account svc cart svc account svc cart svc Pub Sub usr svc account svc cart svc Data Aggregation Application Push Pull
  38. 38. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 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
  39. 39. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. A Few Thoughts Use Non-Functional Requirements to help identify the right data store(s) for each microservice Use polyglot persistence to avoid bottlenecks, schema issues and allow independent scalability (and cache) Embrace eventual consistency and design fault-tolerant business processes which can recover Think ahead and plan your analytics requirements as part of the overall architecture
  40. 40. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Learn from our Customers
  41. 41. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Thank You for Attending the Webinar We hope you found it interesting! A kind reminder to complete the survey. Let us know what you thought of today’s event and how we can improve the event experience for you in the future. aws-apac-marketing@amazon.com twitter.com/AWSCloud facbook.com/AmazonWebServices youtube.com/user/AmazonWebServices slideshare.net/AmazonWebServices twitch.tv/aws
  42. 42. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. New to AWS Introductory labs and videos can help you ramp up Start learning Take a Class Build technical skills and learn best practices from an accredited instructor Find a class AWS Certification Validate knowledge and show expertise with industry recognized certifications Get Certified Online Labs Take an online Self-Paced Lab to get hands-on- practice with AWS services Start practicing Learn more: aws.amazon.com/training

×