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

Mobile Apps & APIs: Best Friends Forever (Agile...

Mobile Apps & APIs: Best Friends Forever (Agile Australia)

This talk was presented at Agile Australia 2016 (http://agileaustralia.com.au/2016/)

Mobile apps are powered by APIs, and the trend for building the backend is towards small, fast moving microservices. These granular backends aren’t always well suited to integration with mobile apps. Companies like REA, SoundCloud and Thoughtworks have been experimenting with patterns for developing Backends For Frontends (BFFs) to allow greater flexibility on both the client and the server. Stewart will talk about some of the concerns when building mobile apps and APIs and how the BFF pattern tries to address these.

Stewart Gleadow

June 21, 2016
Tweet

More Decks by Stewart Gleadow

Other Decks in Programming

Transcript

  1. $10 (in stock) BUY NOW ADD TO CART product favourites

    warehouse checkout account postal recommendations
  2. http://en.wikipedia.org/wiki/IPhone_5S Mobile apps: slow to develop, update and maintain Missing

    features in the API Rolling out updates takes a long time Dealing with backwards compatibility Many requests for simple actions
  3. Backend for frontend characteristics Stateless, no database Tuned for larger,

    cacheable responses Failure tolerant and scaleable Aggregate functionality, driven by the experience
  4. http://en.wikipedia.org/wiki/Lego Chunky vs chatty APIs Fewer requests with larger responses

    Keep responses cacheable Monitor parsing performance on older devices
  5. POST /register { username: “me”, password: “mine”, } 409 Conflict

    PROFILE SIGN IN SIGN UP Hi, Stewart LOGOUT PROFILE
  6. POST /login { username: “me”, password: “mine”, } 201 Created

    Set-Cookie: mytoken=c3Rld0ByZWEtZ3Jvd { token: “c3Rld0ByZWEtZ3Jvd” } PROFILE SIGN IN SIGN UP Hi, Stewart LOGOUT PROFILE
  7. GET /details Cookie: mytoken=c3Rld0ByZWEtZ3Jvd 200 OK { details: { name:

    “Stewart”, twitter: “@stewgleadow” } } PROFILE SIGN IN SIGN UP Hi, Stewart LOGOUT PROFILE
  8. PROFILE SIGN IN SIGN UP Hi, Stewart LOGOUT PROFILE GET

    /history Cookie: mytoken=c3Rld0ByZWEtZ3Jvd 200 OK { history: [ { item: { … } }, { item: { … } } ] }
  9. POST /register { username: “me”, password: “mine”, } 201 Created

    Set-Cookie: mytoken=c3Rld0ByZWEtZ3Jvd { details: { name: “Stewart”, twitter: “@stewgleadow” }, history: [ { item: { … } }, { item: { … } } ] } PROFILE SIGN IN SIGN UP Hi, Stewart LOGOUT PROFILE
  10. POST /register { username: “me”, password: “mine”, } 201 Created

    Set-Cookie: mytoken=c3Rld0ByZWEtZ3Jvd { details: { name: “Stewart”, twitter: “@stewgleadow” }, history: [ { item: { … } }, { item: { … } } ] } PROFILE Hi, Stewart LOGOUT PROFILE LOGIN REGISTER
  11. $10 (in stock) BUY NOW ADD TO CART product favourites

    warehouse checkout account postal recommendations
  12. $10 (in stock) BUY NOW ADD TO CART Two requests:

    1. All product information 2. Personalised Data
  13. BFF get core product details get other details in parallel

    return all transform data get product
  14. The backend for front end Fewer requests, simpler interactions Force

    logic to the backend Deal with backwards compatibility http://www.flickr.com/photos/setaou/2935943672/
  15. How many BFFs should I have? Treat technology platforms as

    a product? Treat separate audiences and feature sets as a product?
  16. http://www.flickr.com/photos/peternijenhuis/6959653638/ BFF organisational pattern Split around your concept of a

    product People problems trump technology Product teams own their experience API
  17. http://www.flickr.com/photos/jakecaptive/3205277810 Does this change how you build the apps themselves?

    Cross-platform mobile tools become less appealing Get’s you closer to continuous delivery
  18. REFERENCES • Sam Newman, Pattern: Backends For Frontends: http://samnewman.io/patterns/architectural/bff/ •

    Stewart Gleadow, Legacy To Mobile First, https://speakerdeck.com/sgleadow/legacy-to-mobile-first • Software Engineering Daily interview with Lukasz Plotnicki, Moving To Microservices At SoundCloud: http://softwareengineeringdaily.com/2016/02/04/moving-to-microservices-at- soundcloud-with-lukasz-plotnicki/ • Stewart Gleadow, Cameron Barrie, James Brett, Evolving Mobile Architectures @ Mi9: http://www.slideshare.net/sgleadow/evolving-mobilearchitectures • Lucasz Plotnicki, BFF @ SoundCloud: https://www.thoughtworks.com/insights/blog/bff-soundcloud • Jan Stenberg, A Pattern For API Backends Serving Frontends: http://www.infoq.com/news/2015/12/bff-backend-frontend-pattern • Stewart Gleadow, The Next Killer App Is Not An App: https://www.thoughtworks.com/p2magazine/issue02/mobile/ • Martin Fowler, Microservices: http://martinfowler.com/articles/microservices.html • Sam Newman, Demistifying Conways Law: http://www.thoughtworks.com/insights/blog/demystifying-conways-law • Michael Feathers, Microservices Until Macro Complexity: https://michaelfeathers.silvrback.com/microservices-until-macro-complexity • Anthony Green, What Is A Microservice And Why Does It Matter: http://www.brunton-spall.co.uk/post/2014/05/21/what-is-a-microservice-and-why-does-it-matter • Richard Clayton, Failing At Microservices: https://rclayton.silvrback.com/failing-at-microservices • Fred George, Microservices Architecture: http://yow.eventer.com/yow-2012-1012/micro-services-architecture-by-fred-george-1286 • Todd Hoff, Microservices Not A Free Lunch: http://highscalability.com/blog/2014/4/8/microservices-not-a-free-lunch.html • Martin Fowler, Strangler Application: http://martinfowler.com/bliki/StranglerApplication.html • Stewart Gleadow, No App Is An Island: https://speakerdeck.com/sgleadow/no-app-is-an-island • Sam Newman, Practical Microservices: http://www.slideshare.net/spnewman/practical-microservices-yow-2013 • Jason Goetz, REST API Design: Chunky APIs, Chatty APIs: http://www.jamasoftware.com/blog/rest-api-design/