Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Building resilient and scalable backends using event-driven Serverless

Building resilient and scalable backends using event-driven Serverless

Presented at Bangalore Kubernetes Meetup November 2018 -- running serverless functions on Kubernetes and triggering them on events from the database using Hasura.

Shahidh K Muhammed

November 17, 2018
Tweet

More Decks by Shahidh K Muhammed

Other Decks in Technology

Transcript

  1. shahidh_k Async architecture App Database API Event system Payment processing

    Restaurant approval Delivery assignment Async microservices 6
  2. shahidh_k Serverless $ cat index.js exports.function = (req, res) =>

    { res.json({"message": "Hello World"}); } 8 $ serverless functions deploy hello_world --trigger-http https://serverless.functions.net/hello_world $ curl https://serverless.functions.net/hello_world {"message": "Hello World"}
  3. shahidh_k Scalable! • No OPS • No VMs to manage

    • Don’t need to worry about scaling • Just write the code • Deploy • Scale for “free” Graphic Source 9
  4. shahidh_k Resilient? • Serverless functions are ephemeral • No knowledge

    of state - async • Trigger them on events • Add retries to the mix • We have resiliency 10
  5. shahidh_k Example: Food ordering app Column | Value -------------------+--------------------------------------- id

    | a705a43d-c55b-4a8a-ac16-80679bd02404 created_at | 2018-09-23 13:24:32.159024+00 user_id | eca786b6-73ae-44c7-b34f-1757af554464 is_validated | false is_paid | false is_approved | false is_agent_assigned | false 11
  6. shahidh_k Order state machine with serverless is_validated | false is_paid

    | false is_approved | false is_agent_assigned | false is_validated | true is_paid | false is_approved | false is_agent_assigned | false is_validated | true is_paid | true is_approved | false is_agent_assigned | false is_validated | true is_paid | true is_approved | true is_agent_assigned | false is_validated | true is_paid | true is_approved | true is_agent_assigned | true Checks payment New order Validate order Restaurant approval Agent assignment Completed 12
  7. shahidh_k The cost 13 App Database API Event system Payment

    processing Restaurant approval Delivery assignment Generic Event System Event system Async Serverless Fns Payment processing Restaurant approval Delivery assignment
  8. shahidh_k High level overview Database Event system Payment processing Restaurant

    approval Delivery assignment Async serverless functions A Database API layer Payment microservice Restaurant microservice Delivery microservice Synchronous logic Asynchronous logic 14
  9. shahidh_k With GraphQL • Standardised spec • All GraphQL Clients

    are compatible with all GraphQL Servers • Client implementations available for all major platforms and frameworks • Subscriptions: access to async info • Less work for the developer 18
  10. shahidh_k GraphQL & Serverless architecture 19 App Database Payment processing

    Restaurant approval Delivery assignment Mutation/Subscriptions Async serverless functions