Share
Embed
Scaling Frontend Architectures with Micro Frontends
London Software Craftsmanship Community
SQUER Solutions
June 19, 2020
Transcript
63 slides
-
@duffleit Scaling Architectures with Micro Frontends London Software Craftsmanship Community
David Leitner - @duffleit -
@duffleit “microservices are small and focused on one thing to
be autonomous.” -
@duffleit Why autonomous? ✔ Independent Deployments ✔ Distinct Operations ✔
Technology Agnostic ✔ Model around Business Domains ✔ Small Interface Surface ✔ Parallel development -
@duffleit Disclaimer: That's fine in 80 % of the cases.
SPA API Gateway Microservice Microservice Microservice DB DB DB -
@duffleit Microservice API Gateway SPA Microservice Microservice DB DB DB
❌ Independent Deployments ❌ Distinct Operations ❌ Technology Agnostic ❌ Small Interface Surface ❌ Parallel development Frontend Monolith -
@duffleit Microservice API Gateway SPA Microservice Microservice DB DB DB
SPA API Gateway Micro Frontends -
@duffleit μService Ordering μService DB μService μService DB DB Catalogue
Profile μService DB DB Hyperlink Hyperlink -
@duffleit ✔ Independent Deployments ✔ Distinct Operations ✔ Technology Agnostic
✔ Small Interface Surface ✔ Model around Business Domains ✔ Parallel development Based on the assumption to have fully verticalized systems. μService Ordering μService DB μService μService DB DB Catalogue Profile μService DB DB Hyperlink Hyperlink Approach 1: Hyperlink Connected Applications -
@duffleit Approach 1: Hyperlink Connected Applications μService Ordering μService DB
μService μService DB DB Catalogue Profile μService DB DB Hyperlink Hyperlink Dashboard Hyperlink μService DB ⛔ Overfetching ⛔ Overrequesting -
@duffleit Approach 1: Hyperlink Connected Applications with Backend for Frontends
μService Ordering μService DB μService μService DB DB Catalogue Profile μService DB DB Hyperlink Hyperlink Dashboard Hyperlink μService DB BFF Service BFF Service BFF Service BFF Service https://samnewman.io/patterns/architectural/bff/ Presentation Process Flow Domain Logic Data Presentation Process Flow Domain Logic Data -
@duffleit Approach 1: Hyperlink Connected Applications with GraphQL μService Ordering
μService DB μService μService DB DB Catalogue Profile μService DB DB Hyperlink Hyperlink Dashboard Hyperlink μService DB GraphQL Presentation Process Flow Domain Logic Data -
@duffleit μService Ordering μService DB μService μService DB DB Catalogue
Profile μService DB DB Hyperlink Hyperlink Dashboard Hyperlink μService DB View Aggregation Layer Horizontal Layer Ripple Effect -
@duffleit Only works on a very coarse grained level. Ordering
Catalogue Hyperlink Hyperlink Dashboard -
@duffleit Dashboard Profile Profile μService DB Catalogue μService DB Catalogue
Ordering Ordering μService DB Dashboard μService DB -
@duffleit Dashboard Profile Catalogue Ordering Ordering Catalogue Hyperlink Hyperlink Dashboard
All this are “Micro Frontends” One “Micro Frontend” per page. 2...n Micro Frontends per page. -
@duffleit Dashboard Profile Catalogue Ordering Ordering Catalogue Hyperlink Hyperlink Dashboard
All this are “Micro Frontends” One “Micro Frontend” per page. 2...n Micro Frontends per page. -
@duffleit Repository Build & Deploy Server Browser Composed Application Micro
Frontend Build Time Integration Server Side Integration Runtime Integration -
@duffleit Repository Build & Deploy Server Browser Mono Repo package.json
Composed Application Micro Frontend Build Time Integration MonoRepo ✔ Allows extensive code sharing and reuse. ✔ No Version Conflicts and burden with distributing libraries Angular Workspaces -
@duffleit Repository Build & Deploy Server Browser Composed Application Micro
Frontend Build Time Integration ❌ Independent Deployments ❌ Distinct Operations ❌ Technology Agnostic ✔ Small Interface Surface ✔ Model around Business Domains ✔ Parallel development -
@duffleit Product Product Product new Product Product Page Product Page
Product Page Product Page Static Files Scully Rebuild -
@duffleit Repository Build & Deploy Server Browser Composed Application Micro
Frontend Build Time Integration ❌ Independent Deployments ❌ Distinct Operations ❌ Technology Agnostic ✔ Small Interface Surface ✔ Model around Business Domains ✔ Parallel development -
@duffleit Repository Build & Deploy Server Browser Composed Application Micro
Frontend Server Side Integration e.g. Project Mosaic -
@duffleit Based on the concept of Server Side Includes or
Edge Side Includes -
@duffleit Tailor is a Layout Server header fragment μService account
fragment μService catalogue fragment μService maps your request to a template checkout-template.html ... dashboard.template.html profile-template.html -
@duffleit Repository Build & Deploy Server Browser Composed Application Micro
Frontend Server Side Integration ✔ Independent Deployments ✔ Distinct Operations ✔ Technology Agnostic ✔ Small Interface Surface ✔ Model around Business Domains ✔ Parallel development -
@duffleit Repository Build & Deploy Server Browser Composed Application Micro
Frontend Runtime Integration Aggregating UI Routing, Templates, Lazy Loading Meta-SPA-Router -
@duffleit Meta Framework Isolation & Composition Routing Messaging & Shared
State Frontend 1 Frontend N ... -
@duffleit Isolation & Composition Routing Messaging & Shared State Frontend
1 Frontend N ... Option 1: One shared Framework Option 2: Independent “Framework” -
@duffleit Isolation & Composition Routing Messaging & Shared State Frontend
1 Frontend N ... Module Federation with Webpack 5 (in beta.17) Option 1: E-Commerce One shared Framework -
@duffleit Remote Remote Host Container Module Module Module Container Module
Module Module Container Module Module Module fetch from `company.com/remote1` fetch from `company.com/remote2` -
@duffleit Isolation & Composition Routing Messaging & Shared State Frontend
1 Frontend N ... Option 2: Banking Independent “Framework” Compiler Why “Framework”? -
@duffleit Isolation & Composition Routing Messaging & Shared State Frontend
1 Frontend N ... Option 2: Banking Independent “Framework” Isolation & Composition Routing Messaging & Shared State Frontend 1 Frontend N ... Option 1: E-Commerce One shared Framework -
@duffleit Repository Build & Deploy Server Browser Composed Application Micro
Frontend ✔ Independent Deployments ✔ Distinct Operations ✔ Technology Agnostic ✔ Small Interface Surface ✔ Model around Business Domains ✔ Parallel development Runtime Integration -
@duffleit Server Browser Runtime Integration Longliving App State in the
frontend & verticals need to interact with each other. Server Side Integration Request Response Model Interactions between different Verticals are done on the Backend. -
@duffleit 1 Micro-Frontend per Page Hyperlink Integration n Micro-Frontends per
Page Buildtime Integration Server Side Integration Runtime Integration -
@duffleit Complexities: • UI/UX Consistency • Shared State • Resilience
• Tracing/Analytics • Offline-First • ... ✔ Independent Deployments ✔ Distinct Operations ✔ Technology Agnostic ✔ Model around Business Domains ✔ Small Interface Surface ✔ Parallel development -
@duffleit 1 Micro-Frontend per Page Hyperlink Integration n Micro-Frontends per
Page Buildtime Integration Serverside Integration Runtime Integration -
@duffleit Mix and Match Landing Shop Ordering hyperlink hyperlink <!–-
SSIs --> <!--#include … --> <!--#include … --> APP SHELL Header Footer -
@duffleit Everything that can go wrong will go wrong. The
Final Secret: Murphy’s law