Ce diaporama a bien été signalé.
Nous utilisons votre profil LinkedIn et vos données d’activité pour vous proposer des publicités personnalisées et pertinentes. Vous pouvez changer vos préférences de publicités à tout moment.

GraphQL API on a Serverless Environment

Tom Yitav (Co-Founder & CEO) @ CaStory:
We will talk about the use of GraphQL as an API layer and its deployment as AWS Lambda. We will see a demo of bootsrapping such a service using a CLI tool called create-graphql-app. We will also share some of the main pros and cons compared to non-serverless APIs, and benefits of going Serverless in a startup company.

  • Soyez le premier à commenter

  • Soyez le premier à aimer ceci

GraphQL API on a Serverless Environment

  1. 1. GraphQL API on Serverless Environment Tom Yitav Co-Founder & CEO, CaStory
  2. 2. • Co-Founder & CEO @ CaStory – Developing a mobile app for detecting construction errors – Exposing API using GQL, wrapping Serverless backend • Open source developer – create-graphql-app - cli tool for bootstrapping serverless gql server – redis-messaging-manager - Node.js pub-sub library – And many more..   About me                                                                                 @tomyitav
  3. 3. • New standard for data querying – Provides entities and operations schema – Natural successor to REST • Efficient data fetching in single Round trip – Resolvers can aggregate data – Conveniently wraps micro-services as single api • Flexible control over data – Allows entity fields selection   Why GraphQL??                                                                      Image by Meteor @tomyitav
  4. 4. • Stateful, traditional REST api monolith – Every server instance had 3 core tasks: • Fetching network entities with DDS protocol • Internal state management of data collections • Serving RESTful api to clients • Using docker swarm LB between clients • Internally implemented in-memory filtering logic • Filtering entities by timestamp • Filtering entities by radius from position   Use Case - architecture for serving data                      @tomyitav
  5. 5. • Performance issues – Server is loaded with many tasks – Scaling • One server could not serve all clients • Container number was limited by VMs • No "single source of truth" – Different state on some edge cases • Two clients receive different results • Lack of schema and type definitions – REST api provides schema-less JSON entity   Previous architecture drawbacks                                       @tomyitav
  6. 6. • We split the 3 core tasks to micro-services – Application state is managed in Redis store • Shared between all query servers instances • Scaled for HA, managed with Redis sentinel – Micro-service for writing network data to Redis  • Performs pub-sub communication and callbacks • Use of stateless GraphQL api – Provides entities and operations schema – Efficient data fetching in single Round trip – Allows entity fields selection   Tearing the monolith apart                                                @tomyitav
  7. 7.   The quest for the perfect api                                             @tomyitav
  8. 8.   Does it suit Serverless? (Oh Yes!)                                        • Stateless architecture – Scaling functions up and down on the fly – No websockets or "live session" with the clients • GQL resolvers can (and should) trigger other lambdas – Schema field is linked with how to fetch it – Design api as lambdas for resolving granular fields @tomyitav
  9. 9.   How can you set this up?                                                      • Use of create-graphql-app cli – Instantiates NodeJS GraphQL api – Designed to fit serverless environments • As aws lambda or docker container • Instant creation of GraphQL api – Production grade tooling • Code generation • Modular schema api – Easy as pie deployment • Installation via npm – npm install –g create-graphql-app @tomyitav
  10. 10.   Demo                                                                                      @tomyitav
  11. 11.   Today- Fully Serverless system                                                      • Use of create-graphql-app cli – Saving time of manually creating resolvers and services – Stateless API deployed on aws • Exposes database entities • Upload data to aws s3 • Trigger image processing and ML lambdas • Distributed backend algorithms as lambdas – Event driven architecture • Analyse image stream on s3 upload • Packaging python lambdas using pipenv @tomyitav

×