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

[Jean-Baptiste Clion] Microservices in Google A...

[Jean-Baptiste Clion] Microservices in Google App Engine

Presentation from GDG DevFest Ukraine 2016.
Learn more at: https://devfest.gdg.org.ua

Google Developers Group Lviv

September 10, 2016
Tweet

More Decks by Google Developers Group Lviv

Other Decks in Technology

Transcript

  1. Microservices in Google App Engine A Journey to resilience Jean-Baptiste

    Clion Founder @ Apeser | GDG Basel Founder | Google Developer Expert
  2. App Engine Blog, April 7th, 2008 The goal is to

    make easy to get started with a new app, and then make it easy to scale when that app reaches the point where it receiving significant traffic and has millions of users.
  3. Feature (2008) Behavior (Dynamic only) Deadlines 60-second deadline requests |10-minute

    for tasks Background threads Not allowed Residence Evicted from memory Startup and shutdown Instances created on demand | Turned down on idle Instance addressability Instances are anonymous Scaling Scales the number of instances automatically Free daily usage quota 28 instance-hours
  4. App Engine ecosystem services • Datastore • Task queue •

    Cron tasks • User authentication • Messaging (XMPP + Email) • URL Fetch
  5. 1. Split big problems into small pieces 2. Fault-tolerance 3.

    Horizontal scaling 4. NoSQL scalable store (With namespaces) 5. Web serving (Use HTTP protocol) App Engine Philosophy [BACKEND INTRODUCED] Justin Haugh, Google I/O 2011
  6. Feature (2011) Behavior (Backend Residents) Deadlines Requests to backends can

    run indefinitely. Background threads Allowed Residence Possible resident instances, state is preserved. Startup and shutdown Evicted on usage patterns or manually stopped Instance addressability Instances are individually addressable via URL Scaling Configure number or maximum number of instances Free daily usage quota 28 instance-hours
  7. 1. Split application in different logical components. 2. Isolated settings,

    deployments & versions. 3. Adjust instances performances & optimize costs. Modules - Replacing backends - Freedom
  8. Overview 1. Split big problems into small pieces 2. Autoscaling

    & Fault Tolerant 3. Rely on simple HTTP(S) communication. 4. NoSQL scalable & isolable storage 5. Use automated deployment processes.
  9. Microservices Breaking down an application into smaller composable pieces which

    work together. Each component is developed separately, and the application is then the sum of its constituent components.
  10. Stateless instances Data isolation Scaling on Y axis API Gateway

    Consistent Code Maturity Async HTTP communication Divide & Conquer with microservices
  11. Code maturity level consistency Your services will follow the same

    set of coding practices. Updating your practices implies to update your source code. This will keep cohesion across your solution.
  12. Frontend Products Frontend Carts Frontend Orders products existing? Products data

    cart valid? 5 8 Carts data Orders data proceed order 1 12 2 9 3 4 10 11 6 7 0 13 Different code maturity level V1. Product ID -> Long
  13. Different code maturity level Frontend Products Frontend Carts Frontend Orders

    products existing? Products data cart valid? 5 8 Carts data Orders data proceed order 1 12 2 9 3 4 10 11 6 7 0 13 V1. Product ID -> Long V2. Product ID -> String
  14. Different code maturity level V1. Product ID -> Long V2.

    Product ID -> String Frontend Products Frontend Carts Frontend Orders products existing? Products data cart valid? 5 8 Carts data Orders data proceed order 1 12 2 9 3 4 10 11 6 7 0 13
  15. Frontend Products Frontend Carts Frontend Orders products existing? Products data

    cart valid? 5 8 Carts data Orders data proceed order 1 12 2 9 3 4 10 11 6 7 0 13 Same code maturity level V2. Product ID -> String V2. Product ID -> String
  16. Scaling on Y axis You code will have a functional

    decomposition by following your business logic [Services]. Your solution will then scale on services instead of entire application. This will have a drastic positive impact on resources.
  17. Y Axis Functional decomposition Scale by splitting different things X

    Axis Horizontal duplication Scale by cloning Z Axis Data partitioning Scale by splitting similar things The Scale cube
  18. Frontend Products Frontend Orders products existing? Products data Orders data

    proceed order Frontend Carts cart valid? Carts data X Scaling - Scale entire application
  19. Frontend Products Frontend Carts Frontend Orders products existing? Products data

    cart valid? Carts data Orders data proceed order Frontend Products products existing? Products data Frontend Carts cart valid? Carts data X Scaling - Scale entire application Frontend Orders Orders data proceed order
  20. Frontend Products Frontend Carts Frontend Orders products existing? Products data

    cart valid? Carts data Orders data proceed order Frontend Products products existing? Products data Frontend Carts cart valid? Carts data Frontend Orders Orders data proceed order X Scaling - Scale entire application
  21. Frontend Products Frontend Carts Frontend Orders products existing? Products data

    cart valid? Products data Orders data proceed order Y Scaling - Scale service only
  22. products existing? Frontend Products Frontend Carts Frontend Orders products existing?

    Products data cart valid? Products data Orders data proceed order Y Scaling - Scale service only
  23. products existing? products existing? Frontend Products Frontend Carts Frontend Orders

    products existing? Products data cart valid? Products data Orders data proceed order Y Scaling - Scale service only
  24. Async HTTP communication Synchronous communications via REST or asynchron via

    message broker. Simple HTTP communications allow flexibility and interoperability between services.
  25. Stateless instances Do not persist information between requests. This will

    allow your instances to scale and increase the amount of worked produced without data inconsistencies.
  26. Frontend Products Frontend Carts Frontend Orders products existing? Products data

    cart valid? 5 8 Carts data Orders data proceed order 1 12 2 9 3 4 10 11 6 7 0 13 Stateful servers
  27. Frontend Products Frontend Carts Frontend Orders products existing? Products data

    cart valid? 5 8 Carts data Orders data proceed order 1 12 2 9 3 4 10 11 6 7 0 13 Product $30 Caching Stateful servers
  28. products existing? Frontend Products Frontend Carts Frontend Orders products existing?

    Products data cart valid? 5 8 Carts data Orders data proceed order 1 12 2 9 3 4 10 11 6 7 0 13 Product $10 Product $30 Caching Stateful servers
  29. products existing? products existing? Frontend Products Frontend Carts Frontend Orders

    products existing? Products data cart valid? 5 8 Carts data Orders data proceed order 1 12 3 4 10 11 6 7 2 9 0 13 Product $20 Product $10 Product $30 Caching Stateful servers
  30. products existing? products existing? Frontend Products Frontend Carts Frontend Orders

    products existing? Products data cart valid? 5 8 Carts data Orders data proceed order 1 12 2 9 3 4 10 11 6 7 0 13 Product $20 Product $10 Product $30 Caching Stateful servers
  31. Frontend Products Frontend Carts Frontend Orders products existing? Products data

    cart valid? 5 8 Carts data Orders data proceed order 1 12 2 9 3 4 10 11 6 7 0 13 Stateless servers Product $30
  32. products existing? Frontend Products Frontend Carts Frontend Orders products existing?

    Products data cart valid? 5 8 Carts data Orders data proceed order 1 12 2 9 3 4 10 11 6 7 0 13 Product $30 Stateless servers
  33. products existing? products existing? Frontend Products Frontend Carts Frontend Orders

    products existing? Products data cart valid? 5 8 Carts data Orders data proceed order 1 12 2 9 3 4 10 11 6 7 0 13 Product $30 Stateless servers
  34. Data isolation Each service has an isolated and independent persisted

    data set. Isolation globally reduce pressure on a single database and avoid overall collapsing due to data interdependencies.
  35. Frontend Products Frontend Carts Frontend Orders products existing? Products data

    cart valid? Carts data Orders data proceed order Non isolated datasets
  36. Frontend Products Frontend Carts Frontend Orders products existing? Products data

    cart valid? Carts data Orders data proceed order Non isolated datasets
  37. Frontend Products Frontend Carts Frontend Orders products existing? Products data

    cart valid? Carts data Orders data proceed order Non isolated datasets
  38. Frontend Products Frontend Carts Frontend Orders products existing? Products data

    cart valid? Carts data Orders data proceed order Have access to unnecessary data Non isolated datasets
  39. Frontend Products Frontend Carts Frontend Orders products existing? Products data

    cart valid? Carts data Orders data proceed order Have access to unnecessary data Code will slowly be implemented in other service. Non isolated datasets
  40. Frontend Products Frontend Carts Frontend Orders products existing? Products data

    cart valid? Carts data Orders data proceed order Have access to unnecessary data Code will slowly be implemented in other service. Non isolated datasets
  41. Frontend Products Frontend Carts Frontend Orders products existing? Products data

    cart valid? Carts data Orders data proceed order Non isolated datasets
  42. Frontend Products Frontend Carts Frontend Orders products existing? Products data

    cart valid? Carts data Orders data proceed order Non isolated datasets
  43. Frontend Products Frontend Carts Frontend Orders products existing? Products data

    cart valid? Carts data Orders data proceed order Non isolated datasets
  44. Frontend Products Frontend Carts Frontend Orders products existing? Products data

    cart valid? Carts data Orders data proceed order Non isolated datasets
  45. Frontend Products Frontend Carts Frontend Orders products existing? Products data

    cart valid? Carts data Orders data proceed order Non isolated datasets
  46. Frontend Products Frontend Carts Frontend Orders products existing? Products data

    cart valid? 5 8 Carts data Orders data proceed order 1 12 2 9 3 4 10 11 6 7 0 13 Isolated data
  47. API Gateway System single entry point, the gateway will control

    and execute the different services required by your client. It will simplify communications and avoid arbitrary API calls.
  48. Frontend Products Frontend Carts Frontend Orders products existing? Products data

    cart valid? Carts data Orders data proceed order No Api Gateway
  49. Frontend Products Frontend Carts Frontend Orders Check product Products data

    Check cart Carts data Orders data proceed order No Api Gateway 1. Call - Check product 2. Call - Check cart 3. Call - proceed order
  50. Frontend Products Frontend Carts Frontend Orders Check product Products data

    Check cart Carts data Orders data proceed order Api Gateway 1. Call - Check product 2. Call - Check cart 3. Call - proceed order Check out Proxy
  51. Overview 1. Split large problem in small dedicated modules. 2.

    Modules are low coupled to ease maintenance. 3. Rely on simple HTTP(S) communication. 4. Data isolation as best practice. 5. Use automated deployment processes.
  52. Lightweight Event-based Microservices Google Cloud Functions is a lightweight, event-based,

    asynchronous compute solution that allows you to create small, single-purpose functions that respond to cloud events without the need to manage a server or a runtime environment. CLOUD FUNCTIONS ALPHA
  53. Jean-Baptiste Clion Founder @Apeser | GDG Basel Founder | GDE

    GCP jbclion +JeanBaptisteClionBasel @JBaptisteClion