Con l’ascesa delle architetture di microservizi e delle ricche applicazioni mobili e Web, le API sono più importanti che mai per offrire agli utenti finali una user experience eccezionale. In questa sessione impareremo come affrontare le moderne sfide di progettazione delle API con GraphQL, un linguaggio di query API open source utilizzato da Facebook, Amazon e altro e come utilizzare AWS AppSync, un servizio GraphQL serverless gestito su AWS. Approfondiremo diversi scenari, comprendendo come AppSync può aiutare a risolvere questi casi d’uso creando API moderne con funzionalità di aggiornamento dati in tempo reale e offline.
Inoltre, impareremo come Sky Italia utilizza AWS AppSync per fornire aggiornamenti sportivi in tempo reale agli utenti del proprio portale web.
Track 6 Session 3_如何藉由 AWS AI 和機器學習平台搭建多功能的 AI 解決方案.pptx
API moderne real-time per applicazioni mobili e web
1. API moderne real-time per
applicazioni mobili e web
Stefano Sandrini, AWS Sr. EMEA Mobile Specialist SA
Daniel De Gaspari, Solution Architect – Sky Italia
32. 38
Scope & High Level Requirements
Logical View: Engine and Plugin
Logical View: Capabilities
System Engineering View: component by component
Monitoring
AWS AppSync & GraphQL
Amplify Framework
Next Planned Evolution
33. 39
• Real time and near real time data available
• High Horizontal Scalability
• Source and consumer agnostic Data ingestion, Data
feeding and rendering engine
• SEO optimization with SSR
• Data rendering using microfrontend and
webcomponent approach
• Full monitoring
• Easy onboarding for developers with same language
FE and BE
• Query language(AppSync for GraphQL) instead of
REST in order to optimize data transfer between BE
and Webcomponent.
• Pushing intstead of Polling to get data update
• Different level of caching to reduce db interaction
34. 40
Data Feeding and Data rendering (Engine) Data Ingestion (Engine)
Data sources (plugin components) Consumers for Web Components or Data (plugin components)
35. 41
• Receives data from data sources
• Stores data into Sports Data Repository
• Notifies HTML Component Generator
• Retrieves sports data
• Sends updates to clients
• Generates widgets’ HTML
• Stores generated widget
• Notifies HTML Page Generator
• Generates web pages
• Stores generated widget into
HTML Component Repository
A
B C D E
A
B
C
D
E
36. 42
Data Ingestion Queue
• receives message from data providers
• triggers Data Ingestion Lambda
Data Ingestion Lambda
• parses received messages
• updates DB tables
• inserts messages on SNS’s topics
• 1:1 topics-tables mapping
37. 43
AWS System Manager
• parameter store
• contains parameters necessary to the lambda
execution
Database
• entity-relationship model
38. 44
Data Ingestion Notifier
• entry point for data feeding
• receives requests by the Ingestion Lambda
• 1 topic for each DB table
Web Component Generator Queue
• receives messages from Data Ingestion Notifier
• triggers the associated lambda dedicated to the
generation of a specific web component
39. 45
Web Component Generator Lambda (for each web component)
• reads messages received by SQS
• contains all information necessary in order to identify
the specific widget of that type
• retrieves widget’s configurations from S3 bucket
• performs a GraphQL interaction (query-mutation)
• generates the web component and notify creation
(notifier)
• stores web component in an S3 bucket
40. 46
Web Component Notifier
• one topic for each BE system
AppSync (managed graphQL)
• Query: retrieves data in a data source
• Mutation: modifies data in a data source
• Subscription: pushes data to clients via websocket
• invokes the Lambda Data API
• solves the “fake mutation”, sending updates to all
clients subscribed
41. 47
Data API Lambda
• implements queries to extract data from the
database
• each data API Lambda represents a microservice
Secrets Manager
• contains credentials used to access and reads data
from Sports Data Database
42. 48
Widget Writer Queue
• receives messages from the Web Component Notifier
• triggers Widget Writer Lambda
Widget Writer Lambda
• acts as an adapter for our CMS
• reads messages received by SQS
• makes a request to the API Gateway, obtaining the
HTML of the new widget
• store widget into EFS
43. 49
EFS
• repository for web components generated
• used by Adobe Experience Manager for pages'
generation that include the these web components
Configuration Writer Queue
• receives message from AEM’s Author instance
• triggers the associated lambda dedicated to
propagates the widget configurations to Sports Data
infrastructure
44. 50
Configuration Writer Lambda
• reads messages received by SQS
• updates the new rules relating to the configuration
of the web components on the S3 bucket
45. 51
• Infrastructure level
– evaluate services’ health
• Application level
– custom metrics based on logs in our applications
• Involved services
– instances with CloudWatch Agent
– CloudWatch Logs
– metric filters based on logs’ patterns
– thresholds based on our metrics and associated alarms
– email notifications
46. 52
• Managed service with GraphQL
– Serverless
• Hierarchical data structure
– MatchCompetition > MatchSeason > MatchDay > …
• Queries structured with a channel logic
– getTeamCalendarDesktop()
– getTeamCalendarMobile()
• Resolver
– Apache Velocity for a simple/remapping logic
– lambda for complex logic
47. 53
• Resolvers’ reuse & pipeline resolvers
• Local Resolver
– Invoke mutation with data as request payload
– Avoid useless invocation for already calculated fields
– Push data passed as mutation’s payload via
subscription
getMatchDay(params: InputGetMatchDay): [MatchDay]
#@function(name:"getCurrentCompetitionStatus-${env}")
#@function(name: "getMatchDay-${env}")
type BaseFields{
field1: Int
field2: String
calculatedField: Int @function….
}
type BaseFields{
field1: Int
field2: String
}
type UsedByQuery{
baseFields: BaseFields
calculated: Int @function…..
}
Type UsedByMutation{
baseFields: BaseFields
calculated: Int
}
48. 54
• Shared IAM Role between lambda functions
– custom resolvers for each lambda function
• Custom languages for lambda functions
– Custom tasks (run tests, compile, etc…)
• GraphQL schema splitting
• Multiple environments
49. 55
• Multiple clients
• RDS Proxy
• AppSync Cache
• AWS EventBridge
– serverless event bus
– replace SNS & SQS
• DynamoDB
– replace MySQL with NoSQL
– streams
- push events directly from our data source
• Custom protection in AppSync
– AWS Amplify: open source framework
– AWS Cognito
– custom rules for GraphQL operations
61. 67
AWS Training & Certification
https://www.aws.training: Free on-demand courses to help you build new cloud skills
Introduction to Amazon API Gateway
https://www.aws.training/Details/Video?id=16452
e-Learning: Amazon API Gateway for Serverless Applications
https://www.aws.training/Details/eLearning?id=27199
e-Learning: Architecting Serverless Solutions
https://www.aws.training/Details/eLearning?id=42594
For more info on AWS T&C visit: https://aws.amazon.com/it/training/