Diese Präsentation wurde erfolgreich gemeldet.
Wir verwenden Ihre LinkedIn Profilangaben und Informationen zu Ihren Aktivitäten, um Anzeigen zu personalisieren und Ihnen relevantere Inhalte anzuzeigen. Sie können Ihre Anzeigeneinstellungen jederzeit ändern.

Serverless in-action

53 Aufrufe

Veröffentlicht am

Serverless technologies and capabilities are here and are accessible now more than ever.
The power of infinite scale and system capabilities has never been more accessible. This also affects traditional front end development as serverless technologies allow for easy construction of backend support for any frontend with ease and simplicity.

In this talk, we will demonstrate how to build a fully functional Graphql endpoint for FE applications using Apollo Server and Client libraries, utilizing different cloud providers. We will also demonstrate the usage of Servless.com framework to set up the required infrastructure as code to simplify and support this setup

The video of the presentation (Hebrew):
https://youtu.be/8ba4cpdtK-8

Veröffentlicht in: Software
  • Als Erste(r) kommentieren

  • Gehören Sie zu den Ersten, denen das gefällt!

Serverless in-action

  1. 1. Serverless in Action Getting serious with serverless and GraphQL
  2. 2. Who am I? Assaf Gannon Full Stack Developer since 2000 Work @ Tikal assaf@tikalk.com
  3. 3. The Challenge Implement a shopping cart for an e-commerce site Infinite scale Easy to maintain
  4. 4. Bonus Requirements Easy and fun to develop Easy to maintain Cheap setup costs
  5. 5. Required Functionality Add and Store Items the user is interested in Remove Items Display the cart at checkout
  6. 6. Possible Solution: Function-Based Serverless System
  7. 7. Why Serverless?
  8. 8. A Plethora of Possibilities • Processing / Business logic (Functions) • Storage • DataBase • Authentication • Logging • Monitoring • Machine Learning • CI/CD
  9. 9. Cheap Setup Costs Most services have a Free-Tier Pay as you go No commitment required
  10. 10. What can I do with it?
  11. 11. Literally anything… Stream processing CRUD operations BigData analysis High scale serving
  12. 12. Architecture Considerations Reactive Distributed Architecture Stateless execution Short computation periods
  13. 13. How do I get it Done?
  14. 14. Decision Checklist Cloud Provider Required Services Service Providers
  15. 15. Decision Checklist Cloud Provider - Google Cloud Required Services - API Gateway, DB Service Providers - Google Cloud Functions, Atlas MongoDB
  16. 16. The Chosen Stack
  17. 17. serverless.com A Framework for developing & deploying serverless architecture Supports: AWS, Google Cloud Platform, Azure, OpenWhisk, Kubless, Cloudflare
  18. 18. Apollo A set of frameworks to make GraphQL more accessible Apollo Server Apollo Client Apollo Engine https://www.apollographql.com
  19. 19. Atlas MongoDB Hosted MongoDB Cloud Service Supported on Google Cloud, Azure and AWS Free tier for sandbox and development
  20. 20. Let’s get started..
  21. 21. 1. Install Serverless CLI npm i -g serverless
  22. 22. 2. Create a service template serverless create --template google-nodejs --path gql-endpoint
  23. 23. Set Google Cloud Credentials https://serverless.com/framework/doc s/providers/google/guide/credentials/
  24. 24. First Deploy
  25. 25. First Deploy
  26. 26. Offline work fast to run and test changes Easy to debug and log Cheap :)
  27. 27. // Used for local development only - keep clear of any logic const express = require('express'); const { ApolloServer } = require('apollo-server-express'); const typeDefs = require('./schema'); const resolvers = require('./resolvers'); const server = new ApolloServer({ typeDefs, resolvers, playground: true, introspection: true, }); const app = express(); server.applyMiddleware({ app }); app.listen({ port: 4000 }, () => console.log(`🚀 Server ready at http://localhost:4000${server.graphqlPath}`) ); // Google-Cloud-Function handlers const { ApolloServer } = require('apollo-server-cloud-functions'); const typeDefs = require('./schema'); const resolvers = require('./resolvers'); const server = new ApolloServer({ typeDefs, resolvers, playground: true, introspection: true, }); exports.graphql = server.createHandler(); Local server (Express) Serverless function handler Using an Express Server
  28. 28. Things to prepare for production
  29. 29. Add Deployment Stages > serverless deploy --state prod
  30. 30. Service Configuration Use .env file to keep sensitive information Use variables inside serverless.yml for fine grained configurations - see docs for more details.
  31. 31. Secure Your Endpoint Enable limited `cors` Add Authentication exports.handler = server.createHandler({ cors: { origin: ‘your-domain.com’, credentials: true, }, });
  32. 32. Test Your Code Separate logical code from platform specific code Create Integration tests for the endpoint
  33. 33. Other Considerations Avoid Decision Paralysis Be aware of Buyers Remorse Don’t fall in love with services
  34. 34. Summary Serverless is a powerful approach No silver bullets - Keep an open mind Automate as much as possible Keep a tight monitor on costs
  35. 35. Q&A
  36. 36. Thanks For Listening! Keep in Touch: assaf@tikalk.com

×