Patterns and practices for an enterprise-scale adoption of serverless!
SheenBrisals
105 views
107 slides
Sep 06, 2024
Slide 1 of 107
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
About This Presentation
As an evolution of the cloud, serverless—a technical concept and an ecosystem—extends cloud capabilities to enable us to rapidly build and deliver modern business capabilities.
Unlike a successful start-up growing fast using serverless technology, enterprise adoption is often challenging. With ...
As an evolution of the cloud, serverless—a technical concept and an ecosystem—extends cloud capabilities to enable us to rapidly build and deliver modern business capabilities.
Unlike a successful start-up growing fast using serverless technology, enterprise adoption is often challenging. With several business areas, multiple teams, and different technologies, enterprises require careful thinking and planning before going headfirst into serverless.
This talk will begin by giving everyone an overview of the serverless technology ecosystem. It will then show efficient ways to tackle complexity using proven patterns and practices to adopt serverless successfully.
Size: 31.66 MB
Language: en
Added: Sep 06, 2024
Slides: 107 pages
Slide Content
Patterns and Practices for Developing Enterprise-Scale Applications with Serverless! Sheen Brisals Technologist, Author, AWS Serverless Hero
We are just getting started with serverless. It has decades of life in front of it! —Jeff Barr, VP & Chief Evangelistic, AWS
Understanding Serverless
Serverless Pay for compute & storage Auto scalable & highly available Cloud computing model Scale to zero & low cost No server management for you Characteristics Characteristics
Serverless Ecosystem of managed services Ideal for iterative development Optimization at granular level Engineering diversity in teams Deeper level security & data privacy Benefits Benefits
Individuality and granularity at service resource level
Source Destination Data bucket Function 21 SQS queue 2 Function 22 Function 11 SQS queue 1 Function 12 Function 31 SQS queue 3 Function 32 Price changes Product reviews Low latency Low cost Optimization at depth – cost, performance, sustainability
Serverless Control Suitability Quota Cost Timeouts Considerations Considerations
Serverless is more than just a technology… It is more than FaaS , Frameworks, and Architecture blueprints!
The Serverless Ecosystem
An ecosystem is a geographic area where plants, animals, and other organisms, as well as weather and landscape, work together to form a bubble of life. —NationalGeographic.org
This Photo by Unknown Author is licensed under CC BY-SA-NC
Cloud platform Architecture Managed Cloud services Infrastructure definition Development and test tools Repository and pipelines Observability tools Best practices On-demand scaling FaaS Sustainability Scale to zero Pay per use Event driven Deeper security Granularity High availability Builders and stakeholders
A serverless application is an event-driven orchestration of managed services knitted with infrastructure code that brings the best business value!
Complexities of Modern Systems
Modern systems require… Scalability Extendibility Observability Sustainability Reliability Recoverability Picture credit AWS
Some technologies are complex by nature. Often, we build complexity with technology.
Complexity in software systems Accumulated Distributed Monolith Macroservice Lambdalith
Complexity in software systems Monolith Macroservice Lambdalith Accumulated Distributed Simplicity Complexity visible hidden Simplicity Complexity visible hidden
Distributed Teams
Distributed complexity exists… Scalability Extendibility Observability Sustainability Reliability Recoverability Incremental & Iterative dev Automated pipelines Release anytime any day Alert & alarm system issues Recover from failures Fast flow & team velocity Business, Developmental, and Operational needs
Tangled architecture
Problem Decomposition
The most fundamental problem in computer science is problem decomposition : how to take a complex problem and divide it into pieces that can be solved independently.
Glitz & Glamour On screen Hard work & Complexity Behind the Scene
How do film-makers confront complexity ?
Film Interval Intro/title End/credits First Half Second Half
Film Interval Intro/title End/credits Scenes Scenes
I just don’t think it’s that simple. Nothing is. Everything is, when you break it down !
Set Pieces
A set piece is a scene or sequence of scenes whose execution requires logistical planning. Developing a set piece requires planning and execution , but can be rehearsed in advance, completed independently , and brought together.
Characteristics of a set piece A set piece is part of a whole (vision) The focus is on a set piece Planning is essential. Rehearsing or testing is necessary Work on set pieces can progress in parallel All the pieces brought together to make the whole
Film Interval Intro/title End/credits Scenes Scenes Parts Vision Focus Problem Pieces Whole
Decomposition Patterns
Org anization patterns It’s not a book. It’s an industry!
Team Patterns Organize teams for autonomy and flow
Team Patterns Bounded Context Bounded Context Bounded Context Bounded Context Rewards Domains Subdomains Bounded contexts Team ownership
Service Patterns Independent ly releasable single-purpose services
Service Patterns Domains Subdomains Bounded contexts Team ownership Microservices
Architecture Patterns
The world is asynchronous The world is event driven Dr. Werner Vogels CTO, Amazon.com AWS re:Invent 2022 The modern distributed applications’ Duo Asynchrony Event-Driven
The Duo – Asynchrony & Event-Driven Service A Service B Invokes with a request Returns with a response Service C Service D Submits a batch job Acknowledgment Job status Updates Polls Service C Service D Submits a batch job Acknowledgment Notification Service E Service F Messages Sends a message Receives a message
Event-driven architecture (EDA) is an architectural concept that uses events to communicate between decoupled applications asynchronously .
The elements of EDA Customer accounts Finance Customer service Event broker account created account created account created Event producer Event consumer Event broker or bus Events account deleted account deleted
Event producer or publisher Customer accounts Finance Customer service Event broker account created account created account created Agnostic of consumers Adds producer’s identity Conforms to a schema Unique event identifier Adds just the required data account deleted account deleted
Event consumer or subscriber Customer accounts Finance Customer service Event broker account created account created account created Idempotent Ordering not guaranteed Event authenticity Store events and process account deleted account deleted
Event broker, carrier, or bus Customer accounts Finance Customer service Event broker account created account created account created Support for multiple publishers & subscribers Routing events to many targets Event transformation Schema discovery and repository account deleted account deleted
An event is something already happened in the system.
Events – The data envelopes Customer accounts Finance Customer service Event broker account created account created account created Unique event identity Associate with a schema Immutable Carry just the required data account deleted account deleted
Event structure – Event detail { " version ": "0", " id ": "6a7e8feb-b491-4cf7", " detail-type ": "order-submission", " source ": “checkout", " account ": "123456789012", " time ": "2023-08-29T12:10:21Z", " region ": "eu-central-1", " resources ": ["arn:…your-event-bus"], "detail" : { // Your data. A valid JSON } { "detail": { "metadata": { // Details about the event }, "data": { // The instance data } }
Microservices choreography A coordinated performance of microservices
Service choreography is a coordinated sequence of actions across multiple microservices to accomplish a business process.
Use case: Product registration flow Product registration Award loyalty points Generate discount code Email discount code Inform customer support Notify manufacturer
Use case: Product registration flow Product registration Award loyalty points Generate discount code Email discount code Inform customer support Notify manufacturer There is dependency Not everything sequential Different systems involved Data format can differ External
Product registration choreography Products Loyalty Promotions Product registered App Product aftercare Customer Amazon EventBridge Product registered Product registered Product registered Product registered Discount generated Discount generated Amazon SES Third-party system Manufacturer Registration EventBridge rule API call API Destination
Service choreography – Key points Use choreography to coordinate between different microservices There is no controller ; each service performs its logic as per the event It promotes service decoupling and asynchrony, enabling extensibility Each service to implement idempotency measures to handle duplicate events Add traceability attributes in the events for better observability
Microservices orchestration An orchestrated performance of services
Image by https://pixabay.com/users/chenspec-7784448/ Orchestration is an automated and instructed coordination of several services and resources by an orchestrator to accomplish a business process.
In-service orchestration Customers domain Registration microservice Accounts Consent Registration flow Start End Task A1 Task A2 Task A4 API Simplest form of orchestration inside a microservice’s boundary The microservice owns all the resources part of the orchestration Primary benefit is a self-contained microservice – except shared event bus to put events Most use cases suitable for express Step Functions Ideal for sync and async workflows
Customers domain Registration microservice Accounts Registration flow Start End Task A1 Task A2 Task A4 Event bus Cross-service orchestration Interaction with services inside and outside of the domain boundary Most interactions with other services is via synchronous API calls Use of express and standard Step Functions depending on the execution time Ideal for sync and async workflows Loyalty domain Members Rewards Orders Consent
Distributed orchestration Primary orchestrator Domain B Microservice B Start End Task B1 Task B2 Task B3 Task B4 Domain A Microservice A Start End Task A1 Task A3 Task A2 Task A4 Task A5 Task A6 Domain C Microservice C Start End Task C1 Task C3 Task C2 Couple of hours to complete Takes a week to finish
Coordinate distribution with EventBridge Domain B Microservice B Start End Task B 1 Task B2 Task B3 Task B4 Domain A Microservice A Start End Task A1 Task A3 Task A2 Task A4 Task A5 Task A6 Domain C Microservice C Start End Task C1 Task C3 Task C2
Events and task tokens Domain A Step Function A Start End Task A1 Task A3 Task A2 Task A4 Task A5 Task A6 Domain C Microservice C 1 2 3 4 5 1 Task A5 emits an event with a task token and waits 2 Microservice C reacts and performs its job 3 Microservice C emits an event with the task token 4 A function submits the token to the Step Function 5 Step Function A resumes from Task 5 Amazon EventBridge
Distributed orchestration – Key points You can use m ultiple task tokens in a Step Function workflow; each token is unique Task token transport can be via EventBridge, SQS, SNS, and more Set a timeout for the task; extend the heartbeat interval when a task takes longer If one task token submission reports failure, the state machine itself fails Remote services to store the correlation of task request with the respective token
Building better orchestrations – Blog https://bit.ly/38Yxmwd
Sustainable Development
Traditional way of thinking Serverless way of thinking Requirements Analysis Design Development Testing Release Maintenance Ideate Design Build Operate Sustain MVP – Minimum Viable Product MVP – Most Valuable Product Sustain Maintain
The ability to keep something going for a prolonged period by nurturing it with a continuous provision of nourishment to ensure its growth and existence .
Sustain ability triangle Process Product Sustainability in Serverless Cloud Building sustainable serverless solutions Following sustainable development processes Applying cloud best practices Sustainability of the cloud Sustainability in the cloud Long-lived Max long-term value Principles Practices Operating platform
Sustainable processes Follow Lean Principles Reduce Waste Improve Value Stream Agile & Pragmatic Start Small & Scale Evolve in Iterations Automate Everything DevOps Mindset Refactor Continuously Grow Serverless Teams Educate Engineers Instil Ownership
Sustainable cloud Renewable energy Efficient power & cooling Sustainability of the Cloud Development language Data stores & policies Sustainability in the Cloud Server population Right sizing resources Shared resources On-demand scaling Compute & storage tiers options Managed services Customer Cloud
Development Practices
Perform Solution Design Technical agility Engineering clarity Business visibility Service longevity https://bit.ly/3tPEe7D
Security & Threat Modelling Security from the start Data privacy GDPR & C ompliance Service protection https://qrgo.page.link/aiQsb
# Automation & DevOps Account separation Infrastructure as Code ( IaC ) Grow CI/CD pipeline Instil a DevOps culture Integration tests Test in real environment Alerts and alarms Service ownership
Cloud Account Separation Production QA Develop Checkout Services Production QA Develop Payment Services
Cloud Account Separation Production QA Develop Checkout Services Production QA Develop Payment Services Sandbox
Set Pieces in Practice
Backend service Rewards CMS 3 rd Party CRM Website Stores details Business stakeholder Customer Uploads rewards content Redeems rewards Fetches rewards content Updates rewards data Requests redemption Use case : A rewards system
Backend service Rewards CMS 3 rd Party CRM Website Stores details Business stakeholder Customer Uploads rewards content Redeems rewards Fetches rewards content Updates rewards data Requests redemption Domain : Ecommerce Subdomain : Customer Bounded Context : Rewards Use case : A rewards system
Rewards One monolith service One delivery pipeline One observable complex view One bounded context One macro service Rewards commit build test stage production Rewards bounded context A traditional rewards system
How to handle one part with a high degree of change ? Why deploy everything every time ? How to have high visibility of the critical parts ? Would ACL be part of the same service? What will be the developer experience ?
Backend service Rewards CMS 3 rd Party CRM Website Stores details Business stakeholder Customer Uploads rewards content Redeems rewards Fetches rewards content Updates rewards data Requests redemption Find the core service(s) Rewards service Mark the data pipelines Reward data upload Anti-corruption layers CMS & Rewards (ACL) Rewards & CRM (ACL) Rewards system pieces Fraud detection Communications Data audit
Content upload CMS ACL Rewards CRM ACL Rewards System Bounded Context CMS CRM Website But how do they communicate? Rewards system microservices
Dialogue Music Events APIs Content Updates Rewards Communication Contract Messages Connecting the pieces
Content upload CMS ACL Rewards CRM ACL Rewards System Bounded Context CMS CRM Website Sync API Async webhook Sync API Async events Async events Connecting the pieces
Content upload CMS ACL Rewards Rewards System Bounded Context CRM ACL Production QA Develop Sandbox Stream-aligned team Bounded context & microservices Operated by one team Event Sourcing Admin Reports Emails Making the whole / Completing the vision
Public API clients Loyalty Bounded Context SaaS CRM Data Gateway Loyalty Core Event Bus Audit Service Order Processor Auth Service Admin Rewards Manager Members SaaS Survey Data Lake NPS Feeder CRM Mediator Fraud Engine Webhooks Other domain 3 rd Party
Serverless Characteristics Industry Patterns Service Boundaries Think Sustainability Asynchrony Event-Driven Team Autonomy Vision & Focus Monitor & Observability Evolve Architecture