SlideShare uma empresa Scribd logo
1 de 24
Baixar para ler offline
Build Data Driven Apps with Real-time and
Offline Capabilities
Pahud Hsieh(謝洪恩)
Solutions Architect
Level 200
Agenda
• Overview
• What challenges does AppSync address?
• Use cases
• GraphQL
• Details
• Pricing
What is AWS AppSync?
• Managed service for application data using GraphQL with
real-time capabilities and an offline programming model
- Connect to resources in your account
- Make your data services in real time or offline
- Use AWS services with GraphQL
- Automatic sync, conflict resolution in the cloud
- Enterprise-level security features
• Build real-time, collaborative
mobile and web apps
• Handles offline scenarios
common to mobile apps
• Automatically resolves data
conflicts
• Helps keep data secure
• Quickly prototype and build apps
from multiple data sources
• Fully-managed GraphQL service
with benefits
AWS AppSync (available in public preview at re:Invent 2017)
Customers can request access at https://aws.amazon.com/appsync/
What problem does it solve?
Developer Challenges With App Data
Data requirements
vary across devices
and become harder
when multiple users
share data
Users want instant
access to data
Building scalable
data-driven apps
without learning
distributed systems
concepts is hard
Users want to
continue using their
apps even with low
or no connectivity
Build Powerful Data Driven Apps
With AppSync
Real-time
Collaboration
Offline
Programming
Model with
Sync
Get Only the
Data You Need
Own Your Data Fine-grained
Access Control
Apps You Can Build With AppSync
Real-time Apps
- Dashboard
- Leaderboard
- Field service apps
Chat Apps Apps with Complex
Data Structures
and Types
Geo Apps
Offline/Realtime use cases
• Users expect data immediately
- Banking alerts
- News stories
- Multi-player games
- Chat applications
- Shared whiteboards
- AR/VR experiences
- Document collaboration
• Users expect data availability offline
- Financial transactions
- News articles
- Games
- Messaging (pending chat)
- Document collaboration
Let’s simplify by comparing with a
more well-understood approach
I have a web and mobile app, and a
data source
Data
API Gateway Lambda
Using API Gateway and Lambda is one
approach for performing DB operations
What is GraphQL?
• Open, declarative data-fetching specification
• != Graph database
• Use NoSQL, Relational, HTTP, etc.
Traditional data-fetching GraphQL
/posts
/postInfo
/postJustTitle
/postsByAuthor
/postNameStartsWithX
/commentsOnPost
How does GraphQL work?
{
"id": "1",
"name": "Get Milk",
“priority": "1"
},
{
"id": “2",
"name": “Go to gym",
“priority": “5"
},…
type Query {
getTodos: [Todo]
}
type Todo {
id: ID!
name: String
description: String
priority: Int
duedate: String
}
query {
getTodos {
id
name
priority
}
}
Model data with
application schema
Client requests what it
needs
Only that data is
returned
What are the GraphQL benefits?
• Rapid prototyping and iteration
• Introspection
• Co-location of data requirements & application views
- Implementations aren’t encoded in the server
• Data behavior control
- Batching, request/response and real-time
• Bandwidth optimization (N+1 problem)
Can you do … with GraphQL?
• Realtime? YES
• Batching? YES
• Pagination? YES
• Relations? YES
• Aggregations? YES
• Search? YES
• Offline? YES
How does AWS AppSync work?
GraphQL Subscriptions
• Near Realtime updates of data
• Event based mode, triggered by Mutations
- Scalable model, designed as a platform for common use-cases
• Can be used with ANY data source in AppSync
- Lambda, DynamoDB, Elasticsearch
mutation addPost( id:123
title:”New post!”
author:”Nadia”){
id
title
author
}
data: [{
id:123,
title:”New Post!”
author:”Nadia”
}]
Client experience and configuration
• Offline is a write-through “Store”
- Persistent storage mediums back the client “normalized
cache”
- Local Storage for web
- SQLite on hybrid/native platforms
• SQLite database can be preloaded
- Hydrate after installing from AppStore
• Offline client can be configured
- Wifi only vs. wifi & carrier
• Queries automatically persist offline
• Mutations are an “optimistic write”
- Control offline UI updates with “optimistic response”
- Update views/lists when editing/adding data offline
Offline mutations
Jane
Version : 2 Updated Document
Jane
Version : 2 Updated Document
Version : 3 Updated Document
Version : 1 New Document
Time
John
John
Jane goes offline
Jane comes back online
Version : 4 Updated Document
John
Jane
Conflict Resolution and synchronization
Conflict resolution in the cloud
1. Server wins
2. Silent reject
3. Custom logic (AWS Lambda)
- Optimistic version check
- Extend with your own checks
Optional
• Client callback for Conflict Resolution is still
available as a fallback
{
"version" : "2017-02-28",
"operation" : "PutItem",
"key" : {
"id" : { "S" : "1" }
},
"condition" : {
"expression" : "attribute_not_exists(id)"
}
}
Example: Check that an ID doesn’t already exist:
"condition" : {
"expression" : "someExpression"
"conditionalCheckFailedHandler" : {
"strategy" : "Custom",
"lambdaArn" : "arn:..."
}
}
Run Lambda if version wrong:
Images and rich content
type S3Object {
bucket: String!
key: String!
region: String!
}
input S3ObjectInput {
bucket: String!
key: String!
region: String!
localUri: String!
}
type Profile {
name: String!
profilePic: S3Object!
}
type Mutation {
updatePhoto(name: String!,
profilePicInput: S3ObjectInput!): Profile
}
Service Cost per month
• Free Tier lasts for first 12 months
• Don’t forget to add Data Transfer + Database
• Always review the AWS Pricing Page for latest pricing
Free Tier Standard Cost
Queries 250,000 $4 / million
Real-time Updates 250,000 $2 / million
Real-time Connection-minutes 600,000 $0.08 / million
* US Pricing, as of December 1, 2017
Pricing Example (all numbers per month)
• Chat application with 2,500 users
• Average user connects for 1,500 minutes
• Sends 1,000 and Receives 1,000 messages
• 2.5M queries and 2.5M real-time updates
AppSync Query 2.5M x $4/million = $10.00
AppSync Real-time 2.5M x $2/million = $5.00
AppSync Minutes 2,500 x 1,500 x $0.08/million = $0.30
Data Transfer 1KB x 2.5M = 2.4GB x $0.09 = $0.21
DynamoDB Database Free Tier (as long as store < 25Gb)
Total $15.51
Thank You
Pahud Hsieh(謝洪恩)
Solutions Architect

Mais conteúdo relacionado

Mais procurados

Mais procurados (20)

AWS Database and Analytics State of the Union
AWS Database and Analytics State of the UnionAWS Database and Analytics State of the Union
AWS Database and Analytics State of the Union
 
Migrating your traditional Data Warehouse to a Modern Data Lake
Migrating your traditional Data Warehouse to a Modern Data LakeMigrating your traditional Data Warehouse to a Modern Data Lake
Migrating your traditional Data Warehouse to a Modern Data Lake
 
Scaling Up to Your First 10 Million Users
Scaling Up to Your First 10 Million UsersScaling Up to Your First 10 Million Users
Scaling Up to Your First 10 Million Users
 
GPSWKS401_Designing a Cloud Enterprise Data Warehouse
GPSWKS401_Designing a Cloud Enterprise Data WarehouseGPSWKS401_Designing a Cloud Enterprise Data Warehouse
GPSWKS401_Designing a Cloud Enterprise Data Warehouse
 
AWS reInvent 2017 recap - Optimizing Costs as You Scale on AWS
AWS reInvent 2017 recap - Optimizing Costs as You Scale on AWSAWS reInvent 2017 recap - Optimizing Costs as You Scale on AWS
AWS reInvent 2017 recap - Optimizing Costs as You Scale on AWS
 
Introduction to GraphQL and AWS Appsync on AWS - iOS
Introduction to GraphQL and AWS Appsync on AWS - iOSIntroduction to GraphQL and AWS Appsync on AWS - iOS
Introduction to GraphQL and AWS Appsync on AWS - iOS
 
AWS Database and Analytics State of the Union
AWS Database and Analytics State of the UnionAWS Database and Analytics State of the Union
AWS Database and Analytics State of the Union
 
GPSTEC307_Too Many Tools
GPSTEC307_Too Many ToolsGPSTEC307_Too Many Tools
GPSTEC307_Too Many Tools
 
Unlocking New Todays - Artificial Intelligence and Data Platforms on AWS
Unlocking New Todays - Artificial Intelligence and Data Platforms on AWSUnlocking New Todays - Artificial Intelligence and Data Platforms on AWS
Unlocking New Todays - Artificial Intelligence and Data Platforms on AWS
 
在遊戲上應用AI (包括現場展示)
在遊戲上應用AI (包括現場展示)在遊戲上應用AI (包括現場展示)
在遊戲上應用AI (包括現場展示)
 
Best of AWS re:Invent 2017
Best of AWS re:Invent 2017Best of AWS re:Invent 2017
Best of AWS re:Invent 2017
 
FSV307-Capital Markets Discovery How FINRA Runs Trade Analytics and Surveilla...
FSV307-Capital Markets Discovery How FINRA Runs Trade Analytics and Surveilla...FSV307-Capital Markets Discovery How FINRA Runs Trade Analytics and Surveilla...
FSV307-Capital Markets Discovery How FINRA Runs Trade Analytics and Surveilla...
 
An Overview of Best Practices for Large Scale Migrations
An Overview of Best Practices for Large Scale MigrationsAn Overview of Best Practices for Large Scale Migrations
An Overview of Best Practices for Large Scale Migrations
 
ABD206-Building Visualizations and Dashboards with Amazon QuickSight
ABD206-Building Visualizations and Dashboards with Amazon QuickSightABD206-Building Visualizations and Dashboards with Amazon QuickSight
ABD206-Building Visualizations and Dashboards with Amazon QuickSight
 
Create an ML Factory in Financial Services with CI CD - FSI301 - New York AWS...
Create an ML Factory in Financial Services with CI CD - FSI301 - New York AWS...Create an ML Factory in Financial Services with CI CD - FSI301 - New York AWS...
Create an ML Factory in Financial Services with CI CD - FSI301 - New York AWS...
 
BDA305 Building Data Lakes and Analytics on AWS
BDA305 Building Data Lakes and Analytics on AWSBDA305 Building Data Lakes and Analytics on AWS
BDA305 Building Data Lakes and Analytics on AWS
 
How TrueCar Gains Actionable Insights with Splunk Cloud PPT
How TrueCar Gains Actionable Insights with Splunk Cloud PPTHow TrueCar Gains Actionable Insights with Splunk Cloud PPT
How TrueCar Gains Actionable Insights with Splunk Cloud PPT
 
GPSTEC201_Building an Artificial Intelligence Practice for Consulting Partners
GPSTEC201_Building an Artificial Intelligence Practice for Consulting PartnersGPSTEC201_Building an Artificial Intelligence Practice for Consulting Partners
GPSTEC201_Building an Artificial Intelligence Practice for Consulting Partners
 
GPSBUS221_Breaking Barriers Move Enterprise SAP Customers to SAP HANA on AWS ...
GPSBUS221_Breaking Barriers Move Enterprise SAP Customers to SAP HANA on AWS ...GPSBUS221_Breaking Barriers Move Enterprise SAP Customers to SAP HANA on AWS ...
GPSBUS221_Breaking Barriers Move Enterprise SAP Customers to SAP HANA on AWS ...
 
AMF302-Alexa Wheres My Car A Test Drive of the AWS Connected Car Reference.pdf
AMF302-Alexa Wheres My Car A Test Drive of the AWS Connected Car Reference.pdfAMF302-Alexa Wheres My Car A Test Drive of the AWS Connected Car Reference.pdf
AMF302-Alexa Wheres My Car A Test Drive of the AWS Connected Car Reference.pdf
 

Semelhante a Build Data Driven Apps with Real-time and Offline Capabilities

Sviluppare Applicazioni Real Time con AppSync Deck.pptx
Sviluppare Applicazioni Real Time con AppSync Deck.pptxSviluppare Applicazioni Real Time con AppSync Deck.pptx
Sviluppare Applicazioni Real Time con AppSync Deck.pptx
Amazon Web Services
 

Semelhante a Build Data Driven Apps with Real-time and Offline Capabilities (20)

Data Driven Application with GraphQL and AWS App Sync
Data Driven Application with GraphQL and AWS App SyncData Driven Application with GraphQL and AWS App Sync
Data Driven Application with GraphQL and AWS App Sync
 
Building Real-time Serverless Backends with GraphQL
Building Real-time Serverless Backends with GraphQLBuilding Real-time Serverless Backends with GraphQL
Building Real-time Serverless Backends with GraphQL
 
Building Real-time Serverless Backends
Building Real-time Serverless BackendsBuilding Real-time Serverless Backends
Building Real-time Serverless Backends
 
Sviluppare Applicazioni Real Time con AppSync Deck.pptx
Sviluppare Applicazioni Real Time con AppSync Deck.pptxSviluppare Applicazioni Real Time con AppSync Deck.pptx
Sviluppare Applicazioni Real Time con AppSync Deck.pptx
 
Serverless Architecture Patterns
Serverless Architecture PatternsServerless Architecture Patterns
Serverless Architecture Patterns
 
serverless_architecture_patterns_london_loft.pdf
serverless_architecture_patterns_london_loft.pdfserverless_architecture_patterns_london_loft.pdf
serverless_architecture_patterns_london_loft.pdf
 
Serverless Culture
Serverless CultureServerless Culture
Serverless Culture
 
Frontend APIs powering fast paced product iterations
Frontend APIs powering fast paced product iterationsFrontend APIs powering fast paced product iterations
Frontend APIs powering fast paced product iterations
 
MongoDB.local Dallas 2019: Pissing Off IT and Delivery: A Tale of 2 ODS's
MongoDB.local Dallas 2019: Pissing Off IT and Delivery: A Tale of 2 ODS'sMongoDB.local Dallas 2019: Pissing Off IT and Delivery: A Tale of 2 ODS's
MongoDB.local Dallas 2019: Pissing Off IT and Delivery: A Tale of 2 ODS's
 
"Serverless Java Applications" at Froscon 2018 by Vadym Kazulkin/Elmar Warken
"Serverless Java Applications" at Froscon 2018 by Vadym Kazulkin/Elmar Warken"Serverless Java Applications" at Froscon 2018 by Vadym Kazulkin/Elmar Warken
"Serverless Java Applications" at Froscon 2018 by Vadym Kazulkin/Elmar Warken
 
Supercharge Your Product Development with Continuous Delivery & Serverless Co...
Supercharge Your Product Development with Continuous Delivery & Serverless Co...Supercharge Your Product Development with Continuous Delivery & Serverless Co...
Supercharge Your Product Development with Continuous Delivery & Serverless Co...
 
Better APIs with GraphQL
Better APIs with GraphQL Better APIs with GraphQL
Better APIs with GraphQL
 
apidays LIVE Paris - Exploring an API with Blocks by Larry Kluger
apidays LIVE Paris - Exploring an API with Blocks by Larry Klugerapidays LIVE Paris - Exploring an API with Blocks by Larry Kluger
apidays LIVE Paris - Exploring an API with Blocks by Larry Kluger
 
MongoDB World 2018: Evolving your Data Access with MongoDB Stitch
MongoDB World 2018: Evolving your Data Access with MongoDB StitchMongoDB World 2018: Evolving your Data Access with MongoDB Stitch
MongoDB World 2018: Evolving your Data Access with MongoDB Stitch
 
Aws-What You Need to Know_Simon Elisha
Aws-What You Need to Know_Simon ElishaAws-What You Need to Know_Simon Elisha
Aws-What You Need to Know_Simon Elisha
 
I Love APIs Europe 2015: Developer Sessions
I Love APIs Europe 2015: Developer SessionsI Love APIs Europe 2015: Developer Sessions
I Love APIs Europe 2015: Developer Sessions
 
Evolving your Data Access with MongoDB Stitch - Drew Di Palma
Evolving your Data Access with MongoDB Stitch - Drew Di PalmaEvolving your Data Access with MongoDB Stitch - Drew Di Palma
Evolving your Data Access with MongoDB Stitch - Drew Di Palma
 
MongoDB Schema Design: Practical Applications and Implications
MongoDB Schema Design: Practical Applications and ImplicationsMongoDB Schema Design: Practical Applications and Implications
MongoDB Schema Design: Practical Applications and Implications
 
AWS Summit Singapore - You Don't Need a Server For That!
AWS Summit Singapore - You Don't Need a Server For That!AWS Summit Singapore - You Don't Need a Server For That!
AWS Summit Singapore - You Don't Need a Server For That!
 
SQL to NoSQL: Top 6 Questions
SQL to NoSQL: Top 6 QuestionsSQL to NoSQL: Top 6 Questions
SQL to NoSQL: Top 6 Questions
 

Mais de Amazon Web Services

Tools for building your MVP on AWS
Tools for building your MVP on AWSTools for building your MVP on AWS
Tools for building your MVP on AWS
Amazon Web Services
 
How to Build a Winning Pitch Deck
How to Build a Winning Pitch DeckHow to Build a Winning Pitch Deck
How to Build a Winning Pitch Deck
Amazon Web Services
 
Building a web application without servers
Building a web application without serversBuilding a web application without servers
Building a web application without servers
Amazon Web Services
 
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
Amazon Web Services
 

Mais de Amazon Web Services (20)

Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...
Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...
Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...
 
Big Data per le Startup: come creare applicazioni Big Data in modalità Server...
Big Data per le Startup: come creare applicazioni Big Data in modalità Server...Big Data per le Startup: come creare applicazioni Big Data in modalità Server...
Big Data per le Startup: come creare applicazioni Big Data in modalità Server...
 
Esegui pod serverless con Amazon EKS e AWS Fargate
Esegui pod serverless con Amazon EKS e AWS FargateEsegui pod serverless con Amazon EKS e AWS Fargate
Esegui pod serverless con Amazon EKS e AWS Fargate
 
Costruire Applicazioni Moderne con AWS
Costruire Applicazioni Moderne con AWSCostruire Applicazioni Moderne con AWS
Costruire Applicazioni Moderne con AWS
 
Come spendere fino al 90% in meno con i container e le istanze spot
Come spendere fino al 90% in meno con i container e le istanze spot Come spendere fino al 90% in meno con i container e le istanze spot
Come spendere fino al 90% in meno con i container e le istanze spot
 
Open banking as a service
Open banking as a serviceOpen banking as a service
Open banking as a service
 
Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...
Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...
Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...
 
OpsWorks Configuration Management: automatizza la gestione e i deployment del...
OpsWorks Configuration Management: automatizza la gestione e i deployment del...OpsWorks Configuration Management: automatizza la gestione e i deployment del...
OpsWorks Configuration Management: automatizza la gestione e i deployment del...
 
Microsoft Active Directory su AWS per supportare i tuoi Windows Workloads
Microsoft Active Directory su AWS per supportare i tuoi Windows WorkloadsMicrosoft Active Directory su AWS per supportare i tuoi Windows Workloads
Microsoft Active Directory su AWS per supportare i tuoi Windows Workloads
 
Computer Vision con AWS
Computer Vision con AWSComputer Vision con AWS
Computer Vision con AWS
 
Database Oracle e VMware Cloud on AWS i miti da sfatare
Database Oracle e VMware Cloud on AWS i miti da sfatareDatabase Oracle e VMware Cloud on AWS i miti da sfatare
Database Oracle e VMware Cloud on AWS i miti da sfatare
 
Crea la tua prima serverless ledger-based app con QLDB e NodeJS
Crea la tua prima serverless ledger-based app con QLDB e NodeJSCrea la tua prima serverless ledger-based app con QLDB e NodeJS
Crea la tua prima serverless ledger-based app con QLDB e NodeJS
 
API moderne real-time per applicazioni mobili e web
API moderne real-time per applicazioni mobili e webAPI moderne real-time per applicazioni mobili e web
API moderne real-time per applicazioni mobili e web
 
Database Oracle e VMware Cloud™ on AWS: i miti da sfatare
Database Oracle e VMware Cloud™ on AWS: i miti da sfatareDatabase Oracle e VMware Cloud™ on AWS: i miti da sfatare
Database Oracle e VMware Cloud™ on AWS: i miti da sfatare
 
Tools for building your MVP on AWS
Tools for building your MVP on AWSTools for building your MVP on AWS
Tools for building your MVP on AWS
 
How to Build a Winning Pitch Deck
How to Build a Winning Pitch DeckHow to Build a Winning Pitch Deck
How to Build a Winning Pitch Deck
 
Building a web application without servers
Building a web application without serversBuilding a web application without servers
Building a web application without servers
 
Fundraising Essentials
Fundraising EssentialsFundraising Essentials
Fundraising Essentials
 
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
 
Introduzione a Amazon Elastic Container Service
Introduzione a Amazon Elastic Container ServiceIntroduzione a Amazon Elastic Container Service
Introduzione a Amazon Elastic Container Service
 

Build Data Driven Apps with Real-time and Offline Capabilities

  • 1. Build Data Driven Apps with Real-time and Offline Capabilities Pahud Hsieh(謝洪恩) Solutions Architect Level 200
  • 2. Agenda • Overview • What challenges does AppSync address? • Use cases • GraphQL • Details • Pricing
  • 3. What is AWS AppSync? • Managed service for application data using GraphQL with real-time capabilities and an offline programming model - Connect to resources in your account - Make your data services in real time or offline - Use AWS services with GraphQL - Automatic sync, conflict resolution in the cloud - Enterprise-level security features
  • 4. • Build real-time, collaborative mobile and web apps • Handles offline scenarios common to mobile apps • Automatically resolves data conflicts • Helps keep data secure • Quickly prototype and build apps from multiple data sources • Fully-managed GraphQL service with benefits AWS AppSync (available in public preview at re:Invent 2017) Customers can request access at https://aws.amazon.com/appsync/
  • 5. What problem does it solve?
  • 6. Developer Challenges With App Data Data requirements vary across devices and become harder when multiple users share data Users want instant access to data Building scalable data-driven apps without learning distributed systems concepts is hard Users want to continue using their apps even with low or no connectivity
  • 7. Build Powerful Data Driven Apps With AppSync Real-time Collaboration Offline Programming Model with Sync Get Only the Data You Need Own Your Data Fine-grained Access Control
  • 8. Apps You Can Build With AppSync Real-time Apps - Dashboard - Leaderboard - Field service apps Chat Apps Apps with Complex Data Structures and Types Geo Apps
  • 9. Offline/Realtime use cases • Users expect data immediately - Banking alerts - News stories - Multi-player games - Chat applications - Shared whiteboards - AR/VR experiences - Document collaboration • Users expect data availability offline - Financial transactions - News articles - Games - Messaging (pending chat) - Document collaboration
  • 10. Let’s simplify by comparing with a more well-understood approach
  • 11. I have a web and mobile app, and a data source Data API Gateway Lambda Using API Gateway and Lambda is one approach for performing DB operations
  • 12. What is GraphQL? • Open, declarative data-fetching specification • != Graph database • Use NoSQL, Relational, HTTP, etc. Traditional data-fetching GraphQL /posts /postInfo /postJustTitle /postsByAuthor /postNameStartsWithX /commentsOnPost
  • 13. How does GraphQL work? { "id": "1", "name": "Get Milk", “priority": "1" }, { "id": “2", "name": “Go to gym", “priority": “5" },… type Query { getTodos: [Todo] } type Todo { id: ID! name: String description: String priority: Int duedate: String } query { getTodos { id name priority } } Model data with application schema Client requests what it needs Only that data is returned
  • 14. What are the GraphQL benefits? • Rapid prototyping and iteration • Introspection • Co-location of data requirements & application views - Implementations aren’t encoded in the server • Data behavior control - Batching, request/response and real-time • Bandwidth optimization (N+1 problem)
  • 15. Can you do … with GraphQL? • Realtime? YES • Batching? YES • Pagination? YES • Relations? YES • Aggregations? YES • Search? YES • Offline? YES
  • 16. How does AWS AppSync work?
  • 17. GraphQL Subscriptions • Near Realtime updates of data • Event based mode, triggered by Mutations - Scalable model, designed as a platform for common use-cases • Can be used with ANY data source in AppSync - Lambda, DynamoDB, Elasticsearch mutation addPost( id:123 title:”New post!” author:”Nadia”){ id title author } data: [{ id:123, title:”New Post!” author:”Nadia” }]
  • 18. Client experience and configuration • Offline is a write-through “Store” - Persistent storage mediums back the client “normalized cache” - Local Storage for web - SQLite on hybrid/native platforms • SQLite database can be preloaded - Hydrate after installing from AppStore • Offline client can be configured - Wifi only vs. wifi & carrier • Queries automatically persist offline • Mutations are an “optimistic write” - Control offline UI updates with “optimistic response” - Update views/lists when editing/adding data offline
  • 19. Offline mutations Jane Version : 2 Updated Document Jane Version : 2 Updated Document Version : 3 Updated Document Version : 1 New Document Time John John Jane goes offline Jane comes back online Version : 4 Updated Document John Jane
  • 20. Conflict Resolution and synchronization Conflict resolution in the cloud 1. Server wins 2. Silent reject 3. Custom logic (AWS Lambda) - Optimistic version check - Extend with your own checks Optional • Client callback for Conflict Resolution is still available as a fallback { "version" : "2017-02-28", "operation" : "PutItem", "key" : { "id" : { "S" : "1" } }, "condition" : { "expression" : "attribute_not_exists(id)" } } Example: Check that an ID doesn’t already exist: "condition" : { "expression" : "someExpression" "conditionalCheckFailedHandler" : { "strategy" : "Custom", "lambdaArn" : "arn:..." } } Run Lambda if version wrong:
  • 21. Images and rich content type S3Object { bucket: String! key: String! region: String! } input S3ObjectInput { bucket: String! key: String! region: String! localUri: String! } type Profile { name: String! profilePic: S3Object! } type Mutation { updatePhoto(name: String!, profilePicInput: S3ObjectInput!): Profile }
  • 22. Service Cost per month • Free Tier lasts for first 12 months • Don’t forget to add Data Transfer + Database • Always review the AWS Pricing Page for latest pricing Free Tier Standard Cost Queries 250,000 $4 / million Real-time Updates 250,000 $2 / million Real-time Connection-minutes 600,000 $0.08 / million * US Pricing, as of December 1, 2017
  • 23. Pricing Example (all numbers per month) • Chat application with 2,500 users • Average user connects for 1,500 minutes • Sends 1,000 and Receives 1,000 messages • 2.5M queries and 2.5M real-time updates AppSync Query 2.5M x $4/million = $10.00 AppSync Real-time 2.5M x $2/million = $5.00 AppSync Minutes 2,500 x 1,500 x $0.08/million = $0.30 Data Transfer 1KB x 2.5M = 2.4GB x $0.09 = $0.21 DynamoDB Database Free Tier (as long as store < 25Gb) Total $15.51