Share
Embed
Pragmatic Real-Time API design and DevOps with AWS Amplify
In this presentation, I will discuss about the challenges that modern-day developers face and how to overcome them using real-time API design and DevOps.
Manoj Fernando
August 13, 2019
Transcript
29 slides
-
© 2019, Amazon Web Services, Inc. or its Affiliates. All
rights reserved. CHENNAI -
© 2019, Amazon Web Services, Inc. or its Affiliates. All
rights reserved. Pragmatic Real-Time API design and DevOps with AWS Amplify MANOJ FERNANDO - 99X TECHNOLOGY | 10/08/2019 -
© 2019, Amazon Web Services, Inc. or its Affiliates. All
rights reserved. About Me Twitter @mjmrz YouTube https://www.youtube.com/c/cloudtutorials Website https://thecloudtutorials.com Cloud trainer on YouTube Blogger Tech Lead at 99X Technology, Sri Lanka CTO at Whatif AS, Norway -
© 2019, Amazon Web Services, Inc. or its Affiliates. All
rights reserved. Did you know? Delay User Reaction 0 - 100ms Instant J 100 – 300ms Feel sluggish K 300 – 1000ms Machine is working… K 1s+ Mental context switch L 10s+ I’ll come back later… L -
© 2019, Amazon Web Services, Inc. or its Affiliates. All
rights reserved. Developer Challenges -
© 2019, Amazon Web Services, Inc. or its Affiliates. All
rights reserved. Developer Challenges Data requirements vary across devices and become harder when multiple users share data Users want instant access to data Users want to continue using their apps even with low or no connectivity Building scalable data- driven apps without learning distributed systems concepts is hard -
© 2019, Amazon Web Services, Inc. or its Affiliates. All
rights reserved. GraphQL -
© 2019, Amazon Web Services, Inc. or its Affiliates. All
rights reserved. What is GraphQL? • Open declarative data-fetching specification • Resources defined by the GraphQL schema • Client sends the query, the server orchestrates data • Multiple transport support (HTTP, MQTT over WebSocket) • Efficient (Network bandwidth) • Self documenting -
© 2019, Amazon Web Services, Inc. or its Affiliates. All
rights reserved. REST API /albums /albums/1 /albums/1/photos /albums/1/photos/100 /graphql GraphQL API AWS AppSync -
© 2019, Amazon Web Services, Inc. or its Affiliates. All
rights reserved. type Query { listAlbums: [Albums] } type Album { id: ID! title: String pictures: [Picture] } Type Picture { id: ID! file: S3Object } query { listAlbums { title pictures { id } } } [{ “title”: “re:Invent 2019”, “pictures”: [ { “id”:”100” }, { “id”:”101” }] }, { “title”: “AWS Community Day”, “pictures”: [ { “id”:”100” }, { “id”:”101” }] }, ...] Model data with application schema Client requests what’s needed Only requested data is returned -
© 2019, Amazon Web Services, Inc. or its Affiliates. All
rights reserved. Schema type Query { listAlbums: [Albums] } type Mutation { createAlbum(input: CreateAlbumInput!): Album } type Subscription { onCreateAlbum: Album @aws_subscribe(mutations: ["createAlbum"]) } type Album { id: ID! title: String pictures: [Picture] } type Picture { id: ID! file: S3Object } -
© 2019, Amazon Web Services, Inc. or its Affiliates. All
rights reserved. How does GraphQL work? Schema Resolver s Data Source -
© 2019, Amazon Web Services, Inc. or its Affiliates. All
rights reserved. What can GraphQL do? Aggregations – YES Search – YES Offline – YES Realtime – YES Pagination – YES Batching – YES Relations – YES -
© 2019, Amazon Web Services, Inc. or its Affiliates. All
rights reserved. Developer Challenges Data requirements vary across devices and become harder when multiple users share data Users want instant access to data Users want to continue using their apps even with low or no connectivity Building scalable data- driven apps without learning distributed systems concepts is hard -
© 2019, Amazon Web Services, Inc. or its Affiliates. All
rights reserved. AWS AppSync -
© 2019, Amazon Web Services, Inc. or its Affiliates. All
rights reserved. What is AWS AppSync? • Managed GraphQL service with real-time capabilities and offline programming model • Enterprise level security • Connect to resources in your AWS account • Served your data in real-time or offline • Automatic conflict resolution in the cloud -
© 2019, Amazon Web Services, Inc. or its Affiliates. All
rights reserved. How does AppSync work? -
© 2019, Amazon Web Services, Inc. or its Affiliates. All
rights reserved. How to create an AppSync API? • AWS Amplify CLI (Recommended) • AppSync Console • SAM/CloudFormation/CDK/Serverless Framework -
© 2019, Amazon Web Services, Inc. or its Affiliates. All
rights reserved. AWS Amplify -
© 2019, Amazon Web Services, Inc. or its Affiliates. All
rights reserved. What is Amplify Framework? Easy-to-use Library Powerful CLI Beautiful UI Components Amplify Console -
© 2019, Amazon Web Services, Inc. or its Affiliates. All
rights reserved. Amplify CLI • Create/Update/Delete cloud resources • Generate client side code to communicate with AppSync API • Manage multiple cloud environments • Provide powerful GraphQL schema transformations -
© 2019, Amazon Web Services, Inc. or its Affiliates. All
rights reserved. GraphQL Transform – (Directives) @model @searchable @connection @auth @function @versioned -
© 2019, Amazon Web Services, Inc. or its Affiliates. All
rights reserved. type Album @model @searchable @auth(rules: [{ allow: owner }]) { id: ID! title: String owner: String pictures: [Picture] @connection(name: "AlbumPictures") } type Picture @model @auth(rules: [{ allow: owner }]) { id: ID! name: String owner: String file: S3Object album: Album @connection(name: "AlbumPictures") } GraphQL Transform – (Example) -
© 2019, Amazon Web Services, Inc. or its Affiliates. All
rights reserved. Amplify Client Libraries AWS AppSync SDK • Integrates with Apollo client • Works with queries, mutations, and subscriptions • Built in offline support • Supports offline helpers for GraphQL operations Amplify GraphQL Client • Light-weight Client • Works with queries, mutations and subscriptions • Does NOT support offline -
© 2019, Amazon Web Services, Inc. or its Affiliates. All
rights reserved. Demo -
© 2019, Amazon Web Services, Inc. or its Affiliates. All
rights reserved. https://github.com/mjzone/photoalbum-demo -
© 2019, Amazon Web Services, Inc. or its Affiliates. All
rights reserved. Thank You! -
© 2019, Amazon Web Services, Inc. or its Affiliates. All
rights reserved. 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 -
© 2019, Amazon Web Services, Inc. or its Affiliates. All
rights reserved. Pricing