SlideShare une entreprise Scribd logo
1  sur  40
Télécharger pour lire hors ligne
MICROSERVICE
WEBSITES
Gustaf Nilsson Kotte
@gustaf_nk
Mobile devices
The problem
How can we develop a website with multiple teams?
Different business units need to make a website together
that should feel like “one website” for the end-user.
Example: Retail domain
Products, Shopping cart, Checkout, Recommendations, Reviews,
User profile, Editorial content, etc...
The problem
Decentralized services but centralized web?
Frontend
Bottleneck
Services should have their own frontend!
Stefan Tilkov et al, “Self-Contained Systems”
Frontend Frontend FrontendFrontend
Autonomy → Continuous delivery
Decentralized governance
An option for teams to choose different tools
→ heterogeneous/plural/diverse system
High rate of change on the frontend
Allows the system to evolve over time
James Lewis & Martin Fowler, “Microservices: Decentralized Governance”
Addy Osmani, “JavaScript Start-up Performance”
Mobile device performance
Constraints (need to support)
Continuous delivery
Decentralized governance
Good performance on mobile devices
Microservice Websites
Mobile devices
Analysis
INTEGRATION USE CASE
Shopping cart
How can we reuse the shopping cart between
different parts of the web site?
“Many-to-one”
Multiple teams – one shopping cart
INTEGRATION USE CASE
Landing page
The web site’s landing page is the page with the
most amount of traffic and many business units
want to be represented there.
“One-to-many”
Multiple teams – one landing page
Integrating on...
What (data/code/content)
When (build/run)
Where (client/server)
Cartesian product → 12 combinations
Let’s go through them!
Analysis
What × when × where
What? When? Where?
Data (APIs) Build Client
Server
Run Client
Server
Code (JavaScript, PHP, etc) Build Client
Server
Run Client
Server
Content (HTML) Build Client
Server
Run Client
Server
What × when × where
What × when × where
What? When? Where?
Data (APIs) Build Client No reuse at all, only API usage
Server
Run Client
Server
Code (JavaScript, PHP, etc) Build Client
Server
Run Client
Server
Content (HTML) Build Client
Server
Run Client
Server
What × when × where
What × when × where
What? When? Where?
Data (APIs) Build Client No reuse at all, only API usage
Server
Run Client
Server
Code (JavaScript, PHP, etc) Build Client No continuous delivery. No diversity + mobile performance.
Server
Run Client
Server
Content (HTML) Build Client
Server
Run Client
Server
What × when × where
What × when × where
What? When? Where?
Data (APIs) Build Client No reuse at all, only API usage
Server
Run Client
Server
Code (JavaScript, PHP, etc) Build Client No continuous delivery. No diversity + mobile performance.
Server
Run Client No diversity + mobile performance.
Server N/A
Content (HTML) Build Client
Server
Run Client
Server
What × when × where
What × when × where
What? When? Where?
Data (APIs) Build Client No reuse at all, only API usage
Server
Run Client
Server
Code (JavaScript, PHP, etc) Build Client No continuous delivery. No diversity + mobile performance.
Server
Run Client No diversity + mobile performance.
Server N/A
Content (HTML) Build Client
Server
Run Client
Server
What × when × where
What × when × where
What? When? Where?
Data (APIs) Build Client No reuse at all, only API usage
Server
Run Client
Server
Code (JavaScript, PHP, etc) Build Client No continuous delivery. No diversity + mobile performance
Server
Run Client No diversity + mobile performance.
Server N/A
Content (HTML) Build Client N/A
Server “Static page fragments” – ok, but limited amount of use cases
Run Client
Server
What × when × where
What × when × where
What? When? Where?
Data (APIs) Build Client No reuse at all, only API usage
Server
Run Client
Server
Code (JavaScript, PHP, etc) Build Client No continuous delivery. No diversity + mobile performance.
Server
Run Client No diversity + mobile performance.
Server N/A
Content (HTML) Build Client N/A
Server “Static page fragments” – ok, but limited amount of use cases
Run Client Client-side transclusion
Server Server-side transclusion
What × when × where
What? When? Where?
Data (APIs) Build Client No reuse at all, only API usage
Server
Run Client
Server
Code (JavaScript, PHP, etc) Build Client No continuous delivery. No diversity + mobile performance.
Server
Run Client No diversity + mobile performance.
Server N/A
Content (HTML) Build Client N/A
Server “Static page fragments” – ok, but limited amount of use cases
Run Client Client-side transclusion
Server Server-side transclusion
What × when × whereWhat × when × where
Mobile devices
Transclusion
Transclusion
“transclusion is the inclusion of part or all of an electronic document
into one or more other documents by hypertext reference” (Wikipedia: Transclusion)
Producer
Expose a fragment resource, "/retail/shopping-cart/"
Consumer
Include the fragment declaratively, similar to <img src="..." />
Transclusion can be used both on server and client
Examples: Edge-Side Includes (server) and <h-include> (client)
Edge Side Includes (server)
<-- Include the shopping cart component -->
<esi:include src="/retail/shopping-cart/" />
ESI 1.0 proposal submitted to W3C 2001
CDN support: Akamai, Fastly
On-premise support: Varnish, Squid, nodesi, etc
<h-include> (client)
<h-include src="/retail/shopping-cart/"></h-include>
Custom Elements version of hinclude.js (by Mark Nottingham, 2006)
Difference: interface and transitive includes
HTTP/2 → Bundles multiple xhr requests into one
Both support refresh()
ESI (server)
+ SEO
+ JS/CSS in responses works as usual
+ Initial performance
+ Cross-domain requests
- Extra infrastructure investment
- Dev perspective (+ i.e. nodesi)
- No streamed responses ⇒ blocking
- Performance sensitive (+ timeouts)
- No header forwarding (+ configuration)
Server transclusion vs client transclusion
h-include (client)
- No SEO
- No loading of JS/CSS in responses
- Delay before xhr requests arrive
- No cross-domain requests (unless CORS)
- If no initial width/height, page will “jump”
+ No extra infrastructure investment
+ No extra dev setup
+ Async ⇒ non-blocking
+ Responses are rendered when they arrive
+ Headers work as usual in browsers
ESI and h-include together (1)
// Refresh-only h-include
var proto = Object.create(HIncludeElement.prototype);
proto.attachedCallback = function() { /* do nothing */ };
document.registerElement('h-include-refresh-only', {
prototype: proto,
});
⇒ <h-include-refresh-only src="...">REFRESHABLE CONTENT HERE</h-include-refresh-only>
Allows us to wrap the ESI fragment response in an h-include-refresh-only
⇒ server-side initial content with client-side refreshes
ESI and h-include together (2)
// Lazy-loading with hunt.js
window.addEventListener('load', function() {
// For these elements...
hunt(document.getElementsByTagName('h-include-refresh-only'), {
// ...when they’re almost in the viewport...
offset: 400,
// ...load them!
in: function() {
this.refresh();
},
});
});
Constraints (need to support)
Continuous delivery
Decentralized governance
Good performance on mobile devices
Rules for integration
Transclude server-side resources
Microservice Websites
Mobile devices
Client-side
dependencies
Shopping cart HTML, check!
But, what about...
Additional client-side behavior? (JavaScript)
Design? (CSS)
How to import service dependencies
Still need cache busting (i.e. /retail/shopping-cart/scripts-aef419.js)
Server-side transclusion works well here
Client-side transclusion require either 1) HTTP redirects, or 2) “loaders” like little-loader for JS and loadCSS
for CSS. Both options are less performant than using server-side transclusion, because of extra client/server
roundtrips.
<head>
...
<!-- Include shopping cart resources (cache-busting-as-a-service) -->
<esi:include src="/retail/shopping-cart/stylesheets/" />
...
</head>
<body>
...
<-- Include the shopping cart component -->
<esi:include src="/retail/shopping-cart/" />
…
<esi:include src="/retail/shopping-cart/scripts/" />
</body>
Load dependencies (before transclusion)
<head>
...
<!-- Include shopping cart resources (cache-busting-as-a-service) -->
<link rel="stylesheet" src="/retail/shopping-cart/style-ffc864.css" />
...
</head>
<body>
...
<-- Include the shopping cart component -->
<div class="shopping-cart">Hello, shopping cart</div>
...
<script src="/retail/shopping-cart/scripts-aef419.js"></script>
</body>
Load dependencies (after transclusion)
Client-side dependencies: JavaScript
No assumptions of consuming services’ client-side dependencies
⇒ Vanilla JS + polyfills (neither are “free”, so use both with care)
Custom Elements simplifies the lifecycle of components
https://github.com/WebReflection/document-register-element (5 KB)
Client-side dependencies: CSS
Disclaimer: I’m not a CSS expert
Large-scale CSS development is hard (but what’s the alternative?)
Styleguide
Namespacing/components/responsive/flexible
Good news: others have this problem too (i.e. “multi-team SPAs”)
Small global dependency for resets and typography (optional)
Constraints (need to support)
Continuous delivery
Decentralized governance
Good performance on mobile devices
Rules for integration
Transclude server-side resources
No global client-side dependencies
Microservice Websites
Mobile devices
Summary
Services should have their own frontend!
Frontend Frontend FrontendFrontend
Integration: Transclusion
Constraints (need to support)
Continuous delivery
Decentralized governance (otherwise: “occasional” rewrites)
Good performance on mobile devices
Rules for integration (free to use JS frameworks internally, but not for exported fragments)
Transclude server-side resources
No global client-side dependencies
Microservice Websites
Further resources
Microservice Websites, Gustaf Nilsson Kotte
Microservices, James Lewis & Martin Fowler
Self-Contained Systems, Stefan Tilkov et al.
Architecture Without an End State, Michael Nygard
JavaScript Start-up Performance, Addi Osmani
Also, this is a great book:
I’ll happily chat on twitter: @gustaf_nk

Contenu connexe

Tendances

App fabric hybrid computing
App fabric   hybrid computingApp fabric   hybrid computing
App fabric hybrid computing
Hammad Rajjoub
 

Tendances (20)

Microservices with Apache Camel, Docker and Fabric8 v2
Microservices with Apache Camel, Docker and Fabric8 v2Microservices with Apache Camel, Docker and Fabric8 v2
Microservices with Apache Camel, Docker and Fabric8 v2
 
Kentico CMS
Kentico CMSKentico CMS
Kentico CMS
 
ACTIVE SERVER PAGES BY SAIKIRAN PANJALA
ACTIVE SERVER PAGES BY SAIKIRAN PANJALAACTIVE SERVER PAGES BY SAIKIRAN PANJALA
ACTIVE SERVER PAGES BY SAIKIRAN PANJALA
 
Real-world #microservices with Apache Camel, Fabric8, and OpenShift
Real-world #microservices with Apache Camel, Fabric8, and OpenShiftReal-world #microservices with Apache Camel, Fabric8, and OpenShift
Real-world #microservices with Apache Camel, Fabric8, and OpenShift
 
Asp
AspAsp
Asp
 
Joomla! Scalable Enterprise Deployments with AWS
Joomla! Scalable Enterprise Deployments with AWSJoomla! Scalable Enterprise Deployments with AWS
Joomla! Scalable Enterprise Deployments with AWS
 
ColdFusion in Transit action
ColdFusion in Transit actionColdFusion in Transit action
ColdFusion in Transit action
 
Introduction to ASP.NET MVC
Introduction to ASP.NET MVCIntroduction to ASP.NET MVC
Introduction to ASP.NET MVC
 
Ch. x web performance
Ch. x web performanceCh. x web performance
Ch. x web performance
 
Building Quality into the AEM Publication Workflow with Active Standards by D...
Building Quality into the AEM Publication Workflow with Active Standards by D...Building Quality into the AEM Publication Workflow with Active Standards by D...
Building Quality into the AEM Publication Workflow with Active Standards by D...
 
Introduction ASP
Introduction ASPIntroduction ASP
Introduction ASP
 
single page application
single page applicationsingle page application
single page application
 
App fabric hybrid computing
App fabric   hybrid computingApp fabric   hybrid computing
App fabric hybrid computing
 
Drive dam
Drive damDrive dam
Drive dam
 
Content migration for sitecore
Content migration for sitecoreContent migration for sitecore
Content migration for sitecore
 
Progressive Web Apps
Progressive Web AppsProgressive Web Apps
Progressive Web Apps
 
Single page applications with backbone js
Single page applications with backbone jsSingle page applications with backbone js
Single page applications with backbone js
 
Integrating Microservices with Apache Camel
Integrating Microservices with Apache CamelIntegrating Microservices with Apache Camel
Integrating Microservices with Apache Camel
 
Powering GIS Operations with ColdFusion
Powering GIS Operations with ColdFusionPowering GIS Operations with ColdFusion
Powering GIS Operations with ColdFusion
 
Active server pages
Active server pagesActive server pages
Active server pages
 

Similaire à Microservice Websites – Micro CPH

Similaire à Microservice Websites – Micro CPH (20)

Workshop HTML5+PhoneGap by Ivano Malavolta
Workshop HTML5+PhoneGap by Ivano Malavolta Workshop HTML5+PhoneGap by Ivano Malavolta
Workshop HTML5+PhoneGap by Ivano Malavolta
 
Simpler Web Architectures Now! (At The Frontend 2016)
Simpler Web Architectures Now! (At The Frontend 2016)Simpler Web Architectures Now! (At The Frontend 2016)
Simpler Web Architectures Now! (At The Frontend 2016)
 
REST: So What's It All About? (SAP TechEd 2011, MOB107)
REST: So What's It All About? (SAP TechEd 2011, MOB107)REST: So What's It All About? (SAP TechEd 2011, MOB107)
REST: So What's It All About? (SAP TechEd 2011, MOB107)
 
A Simpler Web App Architecture (jDays 2016)
A Simpler Web App Architecture (jDays 2016)A Simpler Web App Architecture (jDays 2016)
A Simpler Web App Architecture (jDays 2016)
 
Angular jS Introduction by Google
Angular jS Introduction by GoogleAngular jS Introduction by Google
Angular jS Introduction by Google
 
James Turner (Caplin) - Enterprise HTML5 Patterns
James Turner (Caplin) - Enterprise HTML5 PatternsJames Turner (Caplin) - Enterprise HTML5 Patterns
James Turner (Caplin) - Enterprise HTML5 Patterns
 
POX to HATEOAS: Our Company's Journey Building a Hypermedia API
POX to HATEOAS: Our Company's Journey Building a Hypermedia APIPOX to HATEOAS: Our Company's Journey Building a Hypermedia API
POX to HATEOAS: Our Company's Journey Building a Hypermedia API
 
State of modern web technologies: an introduction
State of modern web technologies: an introductionState of modern web technologies: an introduction
State of modern web technologies: an introduction
 
HTML5: the new frontier of the web
HTML5: the new frontier of the webHTML5: the new frontier of the web
HTML5: the new frontier of the web
 
The future of web development write once, run everywhere with angular js an...
The future of web development   write once, run everywhere with angular js an...The future of web development   write once, run everywhere with angular js an...
The future of web development write once, run everywhere with angular js an...
 
The future of web development write once, run everywhere with angular.js and ...
The future of web development write once, run everywhere with angular.js and ...The future of web development write once, run everywhere with angular.js and ...
The future of web development write once, run everywhere with angular.js and ...
 
Web Development for UX Designers
Web Development for UX DesignersWeb Development for UX Designers
Web Development for UX Designers
 
Developing High Performance Web Apps - CodeMash 2011
Developing High Performance Web Apps - CodeMash 2011Developing High Performance Web Apps - CodeMash 2011
Developing High Performance Web Apps - CodeMash 2011
 
Testable client side_mvc_apps_in_javascript
Testable client side_mvc_apps_in_javascriptTestable client side_mvc_apps_in_javascript
Testable client side_mvc_apps_in_javascript
 
Progressive web apps
Progressive web appsProgressive web apps
Progressive web apps
 
PHP on Windows and on Azure
PHP on Windows and on AzurePHP on Windows and on Azure
PHP on Windows and on Azure
 
Making Of PHP Based Web Application
Making Of PHP Based Web ApplicationMaking Of PHP Based Web Application
Making Of PHP Based Web Application
 
PHP on Windows
PHP on WindowsPHP on Windows
PHP on Windows
 
PHP on Windows
PHP on WindowsPHP on Windows
PHP on Windows
 
Wordcamp Toronto Presentation
Wordcamp Toronto PresentationWordcamp Toronto Presentation
Wordcamp Toronto Presentation
 

Plus de Gustaf Nilsson Kotte

HTML Hypermedia APIs and Adaptive Web Design - jDays 2013
HTML Hypermedia APIs and Adaptive Web Design - jDays 2013HTML Hypermedia APIs and Adaptive Web Design - jDays 2013
HTML Hypermedia APIs and Adaptive Web Design - jDays 2013
Gustaf Nilsson Kotte
 
HTML Hypermedia APIs and Adaptive Web Design - RuPy
HTML Hypermedia APIs and Adaptive Web Design - RuPyHTML Hypermedia APIs and Adaptive Web Design - RuPy
HTML Hypermedia APIs and Adaptive Web Design - RuPy
Gustaf Nilsson Kotte
 
HTML Hypermedia APIs and Adaptive Web Design - Nordic APIs
HTML Hypermedia APIs and Adaptive Web Design - Nordic APIsHTML Hypermedia APIs and Adaptive Web Design - Nordic APIs
HTML Hypermedia APIs and Adaptive Web Design - Nordic APIs
Gustaf Nilsson Kotte
 
Surviving the Zombie Apocalypse of Connected devices - Jfokus 2013
Surviving the Zombie Apocalypse of Connected devices - Jfokus 2013Surviving the Zombie Apocalypse of Connected devices - Jfokus 2013
Surviving the Zombie Apocalypse of Connected devices - Jfokus 2013
Gustaf Nilsson Kotte
 
Surviving the Zombie Apocalpyse of Connected Devices
Surviving the Zombie Apocalpyse of Connected DevicesSurviving the Zombie Apocalpyse of Connected Devices
Surviving the Zombie Apocalpyse of Connected Devices
Gustaf Nilsson Kotte
 

Plus de Gustaf Nilsson Kotte (9)

Jayway Web Tech Radar 2015
Jayway Web Tech Radar 2015Jayway Web Tech Radar 2015
Jayway Web Tech Radar 2015
 
HTML Hypermedia APIs and Adaptive Web Design - jDays 2013
HTML Hypermedia APIs and Adaptive Web Design - jDays 2013HTML Hypermedia APIs and Adaptive Web Design - jDays 2013
HTML Hypermedia APIs and Adaptive Web Design - jDays 2013
 
Design Hypermedia APIs
Design Hypermedia APIsDesign Hypermedia APIs
Design Hypermedia APIs
 
HTML Hypermedia APIs and Adaptive Web Design - RuPy
HTML Hypermedia APIs and Adaptive Web Design - RuPyHTML Hypermedia APIs and Adaptive Web Design - RuPy
HTML Hypermedia APIs and Adaptive Web Design - RuPy
 
HTML Hypermedia APIs and Adaptive Web Design - reject.js
HTML Hypermedia APIs and Adaptive Web Design -  reject.js HTML Hypermedia APIs and Adaptive Web Design -  reject.js
HTML Hypermedia APIs and Adaptive Web Design - reject.js
 
HTML Hypermedia APIs and Adaptive Web Design - Nordic APIs
HTML Hypermedia APIs and Adaptive Web Design - Nordic APIsHTML Hypermedia APIs and Adaptive Web Design - Nordic APIs
HTML Hypermedia APIs and Adaptive Web Design - Nordic APIs
 
Surviving the Zombie Apocalypse of Connected devices - Jfokus 2013
Surviving the Zombie Apocalypse of Connected devices - Jfokus 2013Surviving the Zombie Apocalypse of Connected devices - Jfokus 2013
Surviving the Zombie Apocalypse of Connected devices - Jfokus 2013
 
Surviving the Zombie Apocalpyse of Connected Devices
Surviving the Zombie Apocalpyse of Connected DevicesSurviving the Zombie Apocalpyse of Connected Devices
Surviving the Zombie Apocalpyse of Connected Devices
 
Windows 8 for Web Developers
Windows 8 for Web DevelopersWindows 8 for Web Developers
Windows 8 for Web Developers
 

Dernier

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 

Dernier (20)

EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 

Microservice Websites – Micro CPH

  • 3. How can we develop a website with multiple teams? Different business units need to make a website together that should feel like “one website” for the end-user. Example: Retail domain Products, Shopping cart, Checkout, Recommendations, Reviews, User profile, Editorial content, etc... The problem
  • 4. Decentralized services but centralized web? Frontend Bottleneck
  • 5. Services should have their own frontend! Stefan Tilkov et al, “Self-Contained Systems” Frontend Frontend FrontendFrontend Autonomy → Continuous delivery
  • 6. Decentralized governance An option for teams to choose different tools → heterogeneous/plural/diverse system High rate of change on the frontend Allows the system to evolve over time James Lewis & Martin Fowler, “Microservices: Decentralized Governance”
  • 7. Addy Osmani, “JavaScript Start-up Performance” Mobile device performance
  • 8. Constraints (need to support) Continuous delivery Decentralized governance Good performance on mobile devices Microservice Websites
  • 10. INTEGRATION USE CASE Shopping cart How can we reuse the shopping cart between different parts of the web site? “Many-to-one” Multiple teams – one shopping cart
  • 11. INTEGRATION USE CASE Landing page The web site’s landing page is the page with the most amount of traffic and many business units want to be represented there. “One-to-many” Multiple teams – one landing page
  • 12. Integrating on... What (data/code/content) When (build/run) Where (client/server) Cartesian product → 12 combinations Let’s go through them! Analysis
  • 13. What × when × where What? When? Where? Data (APIs) Build Client Server Run Client Server Code (JavaScript, PHP, etc) Build Client Server Run Client Server Content (HTML) Build Client Server Run Client Server What × when × where
  • 14. What × when × where What? When? Where? Data (APIs) Build Client No reuse at all, only API usage Server Run Client Server Code (JavaScript, PHP, etc) Build Client Server Run Client Server Content (HTML) Build Client Server Run Client Server What × when × where
  • 15. What × when × where What? When? Where? Data (APIs) Build Client No reuse at all, only API usage Server Run Client Server Code (JavaScript, PHP, etc) Build Client No continuous delivery. No diversity + mobile performance. Server Run Client Server Content (HTML) Build Client Server Run Client Server What × when × where
  • 16. What × when × where What? When? Where? Data (APIs) Build Client No reuse at all, only API usage Server Run Client Server Code (JavaScript, PHP, etc) Build Client No continuous delivery. No diversity + mobile performance. Server Run Client No diversity + mobile performance. Server N/A Content (HTML) Build Client Server Run Client Server What × when × where
  • 17. What × when × where What? When? Where? Data (APIs) Build Client No reuse at all, only API usage Server Run Client Server Code (JavaScript, PHP, etc) Build Client No continuous delivery. No diversity + mobile performance. Server Run Client No diversity + mobile performance. Server N/A Content (HTML) Build Client Server Run Client Server What × when × where
  • 18. What × when × where What? When? Where? Data (APIs) Build Client No reuse at all, only API usage Server Run Client Server Code (JavaScript, PHP, etc) Build Client No continuous delivery. No diversity + mobile performance Server Run Client No diversity + mobile performance. Server N/A Content (HTML) Build Client N/A Server “Static page fragments” – ok, but limited amount of use cases Run Client Server What × when × where
  • 19. What × when × where What? When? Where? Data (APIs) Build Client No reuse at all, only API usage Server Run Client Server Code (JavaScript, PHP, etc) Build Client No continuous delivery. No diversity + mobile performance. Server Run Client No diversity + mobile performance. Server N/A Content (HTML) Build Client N/A Server “Static page fragments” – ok, but limited amount of use cases Run Client Client-side transclusion Server Server-side transclusion What × when × where
  • 20. What? When? Where? Data (APIs) Build Client No reuse at all, only API usage Server Run Client Server Code (JavaScript, PHP, etc) Build Client No continuous delivery. No diversity + mobile performance. Server Run Client No diversity + mobile performance. Server N/A Content (HTML) Build Client N/A Server “Static page fragments” – ok, but limited amount of use cases Run Client Client-side transclusion Server Server-side transclusion What × when × whereWhat × when × where
  • 22. Transclusion “transclusion is the inclusion of part or all of an electronic document into one or more other documents by hypertext reference” (Wikipedia: Transclusion) Producer Expose a fragment resource, "/retail/shopping-cart/" Consumer Include the fragment declaratively, similar to <img src="..." /> Transclusion can be used both on server and client Examples: Edge-Side Includes (server) and <h-include> (client)
  • 23. Edge Side Includes (server) <-- Include the shopping cart component --> <esi:include src="/retail/shopping-cart/" /> ESI 1.0 proposal submitted to W3C 2001 CDN support: Akamai, Fastly On-premise support: Varnish, Squid, nodesi, etc
  • 24. <h-include> (client) <h-include src="/retail/shopping-cart/"></h-include> Custom Elements version of hinclude.js (by Mark Nottingham, 2006) Difference: interface and transitive includes HTTP/2 → Bundles multiple xhr requests into one Both support refresh()
  • 25. ESI (server) + SEO + JS/CSS in responses works as usual + Initial performance + Cross-domain requests - Extra infrastructure investment - Dev perspective (+ i.e. nodesi) - No streamed responses ⇒ blocking - Performance sensitive (+ timeouts) - No header forwarding (+ configuration) Server transclusion vs client transclusion h-include (client) - No SEO - No loading of JS/CSS in responses - Delay before xhr requests arrive - No cross-domain requests (unless CORS) - If no initial width/height, page will “jump” + No extra infrastructure investment + No extra dev setup + Async ⇒ non-blocking + Responses are rendered when they arrive + Headers work as usual in browsers
  • 26. ESI and h-include together (1) // Refresh-only h-include var proto = Object.create(HIncludeElement.prototype); proto.attachedCallback = function() { /* do nothing */ }; document.registerElement('h-include-refresh-only', { prototype: proto, }); ⇒ <h-include-refresh-only src="...">REFRESHABLE CONTENT HERE</h-include-refresh-only> Allows us to wrap the ESI fragment response in an h-include-refresh-only ⇒ server-side initial content with client-side refreshes
  • 27. ESI and h-include together (2) // Lazy-loading with hunt.js window.addEventListener('load', function() { // For these elements... hunt(document.getElementsByTagName('h-include-refresh-only'), { // ...when they’re almost in the viewport... offset: 400, // ...load them! in: function() { this.refresh(); }, }); });
  • 28. Constraints (need to support) Continuous delivery Decentralized governance Good performance on mobile devices Rules for integration Transclude server-side resources Microservice Websites
  • 30. Shopping cart HTML, check! But, what about... Additional client-side behavior? (JavaScript) Design? (CSS)
  • 31. How to import service dependencies Still need cache busting (i.e. /retail/shopping-cart/scripts-aef419.js) Server-side transclusion works well here Client-side transclusion require either 1) HTTP redirects, or 2) “loaders” like little-loader for JS and loadCSS for CSS. Both options are less performant than using server-side transclusion, because of extra client/server roundtrips.
  • 32. <head> ... <!-- Include shopping cart resources (cache-busting-as-a-service) --> <esi:include src="/retail/shopping-cart/stylesheets/" /> ... </head> <body> ... <-- Include the shopping cart component --> <esi:include src="/retail/shopping-cart/" /> … <esi:include src="/retail/shopping-cart/scripts/" /> </body> Load dependencies (before transclusion)
  • 33. <head> ... <!-- Include shopping cart resources (cache-busting-as-a-service) --> <link rel="stylesheet" src="/retail/shopping-cart/style-ffc864.css" /> ... </head> <body> ... <-- Include the shopping cart component --> <div class="shopping-cart">Hello, shopping cart</div> ... <script src="/retail/shopping-cart/scripts-aef419.js"></script> </body> Load dependencies (after transclusion)
  • 34. Client-side dependencies: JavaScript No assumptions of consuming services’ client-side dependencies ⇒ Vanilla JS + polyfills (neither are “free”, so use both with care) Custom Elements simplifies the lifecycle of components https://github.com/WebReflection/document-register-element (5 KB)
  • 35. Client-side dependencies: CSS Disclaimer: I’m not a CSS expert Large-scale CSS development is hard (but what’s the alternative?) Styleguide Namespacing/components/responsive/flexible Good news: others have this problem too (i.e. “multi-team SPAs”) Small global dependency for resets and typography (optional)
  • 36. Constraints (need to support) Continuous delivery Decentralized governance Good performance on mobile devices Rules for integration Transclude server-side resources No global client-side dependencies Microservice Websites
  • 38. Services should have their own frontend! Frontend Frontend FrontendFrontend Integration: Transclusion
  • 39. Constraints (need to support) Continuous delivery Decentralized governance (otherwise: “occasional” rewrites) Good performance on mobile devices Rules for integration (free to use JS frameworks internally, but not for exported fragments) Transclude server-side resources No global client-side dependencies Microservice Websites
  • 40. Further resources Microservice Websites, Gustaf Nilsson Kotte Microservices, James Lewis & Martin Fowler Self-Contained Systems, Stefan Tilkov et al. Architecture Without an End State, Michael Nygard JavaScript Start-up Performance, Addi Osmani Also, this is a great book: I’ll happily chat on twitter: @gustaf_nk