how smart apis are different
play

How smart APIs are different. @berndruecker Some Service Some - PowerPoint PPT Presentation

Moving beyond request-reply: How smart APIs are different. @berndruecker Some Service Some Some Service Service Some Service But keep it local! Some Service Failure will happen. Be resilient. Accept it! Some Some Service Service


  1. Moving beyond request-reply: How smart APIs are different. @berndruecker

  2. Some Service Some Some Service Service Some Service But keep it local! Some Service Failure will happen. Be resilient. Accept it! Some Some Service Service

  3. Photo by Tookapic, available under Creative Commons CC0 1.0 license.

  4. „ There was an error while sending your boarding pass“

  5. Current situation Web-UI Me Check-in

  6. Current situation Web-UI Me Check-in Barcode Output Generator Mgmt

  7. Current situation Web-UI Me Check-in Barcode Output Generator Mgmt

  8. Current situation – the good part Circuit breaker Web-UI Me Check-in Barcode Output Generator Mgmt

  9. Current situation – the bad part Web-UI Me Check-in Barcode Output Generator Mgmt

  10. Current situation – the bad part Web-UI Me Check-in Barcode Output Generator Mgmt

  11. Current situation – the bad part Web-UI Me Check-in Barcode Output Generator Stateful Mgmt Retry

  12. We are having some technical difficulties and cannot present you your boarding pass right away. But we do actively retry ourselves, so lean back, relax and we will send it on time.

  13. Possible situation – much better! Web-UI Me Check-in Barcode Output Generator Mgmt

  14. Possible situation – much better! Web-UI Stateful Retry Me Check-in Barcode Output Generator Mgmt

  15. Warning: Contains Opinion

  16. Bernd Ruecker Co-founder and Chief T echnologist of Camunda Berlin, Germany http://berndruecker.io/ mail@berndruecker.io @berndruecker

  17. You can use a workflow engine (=durable state machine)! Check-In Barcode REST Stateful retry

  18. Want to see code? https://github.com/berndruecker/flowing-retail

  19. Client Service Provider has to implement has to implement Retry Idempotency

  20. Don‘t worry, it will happen safely – even if you loose connection. Feel free to reload this page any time!

  21. Photo by pixabay, available under Creative Commons CC0 1.0 license.

  22. Requirement: Idempotency of services! Photo by pixabay, available under Creative Commons CC0 1.0 license.

  23. Requirement: Idempotency of services! Photo by Chr.Späth , available under Public Domain.

  24. Make every service idempotent! Credit Payment Card charge Charge Credit Card Not Not idempotent cardNumber amount Generally: create Ids as soon as possible Charge Credit Card cardNumber Idempotent amount transactionId

  25. Distributed systems introduce complexity you have to tackle! Credit Payment Card REST

  26. Distributed systems

  27. It is impossible to Client Service differentiate certain Provider failure scenarios. Independant of communication style!

  28. Distributed systems introduce complexity you have to tackle! Credit Payment Card REST

  29. Distributed systems introduce complexity you have to tackle! Credit Payment Card REST Cancel charge

  30. @berndruecker Being able to implement long running services is essential for smart APIs (on a technical level)

  31. @berndruecker Example Retrieve Payment Booking Payment

  32. @berndruecker Example Retrieve Payment Credit Booking Payment Card

  33. @berndruecker Example Retrieve Payment Credit Booking Payment Card Rejected

  34. @berndruecker Example Retrieve Payment Credit Booking Payment Card Rejected If the credit Rejected card was rejected, the customer can provide new details

  35. @berndruecker Example Retrieve Payment Credit Booking Payment Card Rejected If the credit Rejected card was rejected, the customer can provide new details A few smart god services tell anemic CRUD services what to do Sam Newmann

  36. @berndruecker Who is responsible to deal with problems? Retrieve Payment Credit Booking Payment Card Payment If the credit Rejected card was received Payment rejected, the failed customer can provide new details

  37. @berndruecker Long running services Retrieve Payment Credit Booking Payment Card Payment Rejected received Payment failed Smart endpoints are potentially long-running

  38. @berndruecker Being able to implement long running services is essential for smart APIs (on a business level)

  39. Long running services require async communication

  40. Synchronous communication

  41. Synchronous communication is the crystal meth of distributed programming T odd Montgomery and Martin Thompson in “How did we end up here” at GOT O Chicago 2015

  42. Asynchronous communication Web-UI You need to monitor timeouts Me Check-in Barcode Output Generator Mgmt

  43. Workflow…

  44. Workflow…

  45. @berndruecker Being able to implement long running services makes it easy to get async

  46. Can your company leverage your hipster architecture? You need to change busi sines ess pr processes es and customer er Shutterstock expe perience ience!

  47. @berndruecker Example

  48. Example Seat Booking Reservation Payment Ticket Generation

  49. @berndruecker Example sync

  50. @berndruecker Example

  51. Weaknesses Seat Booking Reservation REST Payment Ticket Generation

  52. Weaknesses: Latency creep 300 ms 1150 + x ms Seat Booking Reservation REST 600 ms Payment 250 ms Ticket Generation

  53. Weaknesses: Availabiliy erosion Seat 99 % uptime Booking Reservation REST 96 % uptime Payment 99 % uptime Ticket Generation 99 % uptime

  54. And it is even hard to implement Seat Booking Reservation REST Payment Ticket Generation

  55. And it is even hard to implement Seat Booking Reservation REST Payment Ticket Generation

  56. T ypical pattern Simulate synchronicty by waiting (callback or polling) Seat Booking Reservation REST Payment Ticket Generation

  57. @berndruecker Redesign your business process accordingly! Sync in happy case happy case Or some interface to poll for status failure case Async response

  58. @berndruecker Redesign your business process accordingly!

  59. @berndruecker Your business processes need to be more reactive! https://www.reactivemanifesto.org/

  60. Yeah! Let‘s go reactive.

  61. Phil Calcado at QCon NYC 2019

  62. „ What the hell just happened ?“ API API API API Microservices API Standard Software API API External Services @berndruecker

  63. @berndruecker Example: order fulfillment via dash button Photo by 0xF2, available under Creative Commons BY-ND 2.0 license. https://www.flickr.com/photos/0xf2/29873149904/

  64. @berndruecker Three steps …

  65. @berndruecker (Micro-)services Checkout Shipment Payment Inventory

  66. @berndruecker Event-driven architecture Order Checkout Placed Payment Notification Received Goods Fetched Shipment Payment Inventory

  67. @berndruecker Peer-to-peer event chains Order placed Checkout Shipment Payment Inventory Goods shipped Payment Goods received fetched

  68. @berndruecker Peer-to-peer event chains Order placed Checkout Shipment Payment Inventory Goods shipped Payment Goods received fetched

  69. @berndruecker The danger is that it's very easy to make nicely decoupled systems with event notification, without realizing that you're losing sight of that larger-scale flow, and thus set yourself up for trouble in future years. https://martinfowler.com/articles/201701-event-driven.html

  70. @berndruecker The danger is that it's very easy to make nicely decoupled systems with event notification, without realizing that you're losing sight of that larger-scale flow, and thus set yourself up for trouble in future years. https://martinfowler.com/articles/201701-event-driven.html

  71. @berndruecker The danger is that it's very easy to make nicely decoupled systems with event notification, without realizing that you're losing sight of that larger-scale flow, and thus set yourself up for trouble in future years. https://martinfowler.com/articles/201701-event-driven.html

  72. @berndruecker Peer-to-peer event chains Fetch the goods before the Order payment placed Checkout Shipment Payment Inventory Goods shipped Payment Goods received fetched

  73. @berndruecker Peer-to-peer event chains Fetch the goods before the Order payment placed Checkout Shipment Payment Inventory Goods shipped Payment Goods received fetched

  74. @berndruecker What we wanted Photo by Lijian Zhang, available under Creative Commons SA 2.0 License and P..19 / CC BY-SA 4.0

  75. @berndruecker Extract the end-to-end responsibility Order placed Checkout Order Retrieve payment Payment Shipment Payment received Inventory

  76. @berndruecker Events & Commands Order Fact, placed Event Checkout happened in the past, Order immutable Retrieve payment Intend, Command Payment Want s.th. to happen Shipment Payment received Inventory

  77. @berndruecker It is not about the protocol! It can still be messaging! Order placed Checkout Order Retrieve payment Shipment Payment Inventory

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend