66
Frontend Architektur für Microservices Thomas Kruse trion development GmbH www.trion.de

Frontend Architektur für Microservices - trion …...2019/11/06  · für Microservices Thomas Kruse trion development GmbH Training - Beratung - Entwicklung Kubernetes Spring Boot

  • Upload
    others

  • View
    12

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Frontend Architektur für Microservices - trion …...2019/11/06  · für Microservices Thomas Kruse trion development GmbH Training - Beratung - Entwicklung Kubernetes Spring Boot

Frontend Architekturfür Microservices

Thomas Krusetrion development GmbH

www.trion.de

Page 2: Frontend Architektur für Microservices - trion …...2019/11/06  · für Microservices Thomas Kruse trion development GmbH Training - Beratung - Entwicklung Kubernetes Spring Boot

Training - Beratung - Entwicklung

Kubernetes Spring Boot Angular

ReactJavaDocker

Page 3: Frontend Architektur für Microservices - trion …...2019/11/06  · für Microservices Thomas Kruse trion development GmbH Training - Beratung - Entwicklung Kubernetes Spring Boot

● Entwickler, Trainer, Berater

○ @everflux

○ www.trion.de

● Java User Group Münster

● Frontend Freunde Münster

Thomas Kruse

Page 4: Frontend Architektur für Microservices - trion …...2019/11/06  · für Microservices Thomas Kruse trion development GmbH Training - Beratung - Entwicklung Kubernetes Spring Boot

Wo stehen wir …

… und wie kamen wir da hin?

Page 5: Frontend Architektur für Microservices - trion …...2019/11/06  · für Microservices Thomas Kruse trion development GmbH Training - Beratung - Entwicklung Kubernetes Spring Boot

1970 - Zentrale Großrechner

Page 6: Frontend Architektur für Microservices - trion …...2019/11/06  · für Microservices Thomas Kruse trion development GmbH Training - Beratung - Entwicklung Kubernetes Spring Boot

1970 - Nutzer: Experten

Page 7: Frontend Architektur für Microservices - trion …...2019/11/06  · für Microservices Thomas Kruse trion development GmbH Training - Beratung - Entwicklung Kubernetes Spring Boot

1970 - Architektur: Monolithisch

Zentrale Datenbank

UI (Host Masken)

Linearer Programmfluss Geschäftslogik

Page 8: Frontend Architektur für Microservices - trion …...2019/11/06  · für Microservices Thomas Kruse trion development GmbH Training - Beratung - Entwicklung Kubernetes Spring Boot

1990 - Schichtenarchitektur

Nutzer haben PCs

Anwendungen werden komplexer

Professionalisierung / OO

Rich Clients / separiertes Frontend

Page 9: Frontend Architektur für Microservices - trion …...2019/11/06  · für Microservices Thomas Kruse trion development GmbH Training - Beratung - Entwicklung Kubernetes Spring Boot

1990 - Organisation

Page 10: Frontend Architektur für Microservices - trion …...2019/11/06  · für Microservices Thomas Kruse trion development GmbH Training - Beratung - Entwicklung Kubernetes Spring Boot

2000 - Modularisierung im Backend

Komplexität steigt

Größenordnungen mehr Nutzer durch Web

Team Aufteilung:Framework-/FachentwicklerInfrastruktur / Betrieb

Page 11: Frontend Architektur für Microservices - trion …...2019/11/06  · für Microservices Thomas Kruse trion development GmbH Training - Beratung - Entwicklung Kubernetes Spring Boot

Anforderungen aus Architektursicht

Komplexität beherschen

Wartbarkeit, Erweiterbarkeit

Entwickler finden / skalieren können

Analysierbarkeit / Verständlichkeit

Hohe Entwicklungsgeschwindigkeit Gewichtung je nach Kontext

Page 12: Frontend Architektur für Microservices - trion …...2019/11/06  · für Microservices Thomas Kruse trion development GmbH Training - Beratung - Entwicklung Kubernetes Spring Boot

2010 - Microservices

Cloud

Agile / autonome Teams

Technologische Freiheit

Mobile Nutzer / APIs

Page 13: Frontend Architektur für Microservices - trion …...2019/11/06  · für Microservices Thomas Kruse trion development GmbH Training - Beratung - Entwicklung Kubernetes Spring Boot

Microservices...

… einfach Microfrontends dazu?

Page 14: Frontend Architektur für Microservices - trion …...2019/11/06  · für Microservices Thomas Kruse trion development GmbH Training - Beratung - Entwicklung Kubernetes Spring Boot

done.

Page 15: Frontend Architektur für Microservices - trion …...2019/11/06  · für Microservices Thomas Kruse trion development GmbH Training - Beratung - Entwicklung Kubernetes Spring Boot

Es gibt da noch den Anwender

Anwender sind keine Experten

Hohe Erwartungen an UX

Einheitliche Bedienkonzepte

Keine Medienbrüche / Integriertes UI

Flüssige Anwendung

Unterstützung statt Formulare

Page 16: Frontend Architektur für Microservices - trion …...2019/11/06  · für Microservices Thomas Kruse trion development GmbH Training - Beratung - Entwicklung Kubernetes Spring Boot

vs.

Page 17: Frontend Architektur für Microservices - trion …...2019/11/06  · für Microservices Thomas Kruse trion development GmbH Training - Beratung - Entwicklung Kubernetes Spring Boot

Beispiel: Reservierung Sitzplatz

AircraftParameter

LegBooking Bonus

Page 18: Frontend Architektur für Microservices - trion …...2019/11/06  · für Microservices Thomas Kruse trion development GmbH Training - Beratung - Entwicklung Kubernetes Spring Boot

Beispiel: Reservierung Sitzplatz

AircraftParameter

LegBooking Bonus

!

Page 19: Frontend Architektur für Microservices - trion …...2019/11/06  · für Microservices Thomas Kruse trion development GmbH Training - Beratung - Entwicklung Kubernetes Spring Boot

Beispiel: Reservierung Sitzplatz

AircraftParameter

LegBooking Bonus

UI Microservice

Page 20: Frontend Architektur für Microservices - trion …...2019/11/06  · für Microservices Thomas Kruse trion development GmbH Training - Beratung - Entwicklung Kubernetes Spring Boot

Backend for Frontend

Verlagerung von Verantwortlichkeiten in Service

Optimierte API / Format je Frontend

Technische Entkopplung

Aufbereitete Ansicht für den Nutzer

Page 21: Frontend Architektur für Microservices - trion …...2019/11/06  · für Microservices Thomas Kruse trion development GmbH Training - Beratung - Entwicklung Kubernetes Spring Boot

Backend for Frontend

Zu wessen Domäne gehört das BFF

Anforderungen von Frontend Team

APIs durch Business Teams

Der nächste Monolith?

Page 22: Frontend Architektur für Microservices - trion …...2019/11/06  · für Microservices Thomas Kruse trion development GmbH Training - Beratung - Entwicklung Kubernetes Spring Boot

Frontend als Integration

Option: Cross-Funktionale Teams

HTTP/JSON API mit Browser Anwendung

Page 23: Frontend Architektur für Microservices - trion …...2019/11/06  · für Microservices Thomas Kruse trion development GmbH Training - Beratung - Entwicklung Kubernetes Spring Boot

Browser Anwendung (SPA)

Browser ist Plattform

Produktive Entwicklung mit passendem Framework

Ermöglicht sehr gutes UX

Der Monolith im Browser?

Page 24: Frontend Architektur für Microservices - trion …...2019/11/06  · für Microservices Thomas Kruse trion development GmbH Training - Beratung - Entwicklung Kubernetes Spring Boot

Modularisierung und Wiederverwendung

UI Komponenten, (JavaScript) Services

Module für höherwertige Bausteine

Kopplung an Framework bringt Vorteile

Umfangreiche Anwendung konzeptionell zerlegen

Separate Systeme / Anwendungen

Page 25: Frontend Architektur für Microservices - trion …...2019/11/06  · für Microservices Thomas Kruse trion development GmbH Training - Beratung - Entwicklung Kubernetes Spring Boot

Self contained Systems (SCS)

Page 26: Frontend Architektur für Microservices - trion …...2019/11/06  · für Microservices Thomas Kruse trion development GmbH Training - Beratung - Entwicklung Kubernetes Spring Boot

Self contained Systems (SCS)

Guter Schnitt essentiell (DDD)

System durch ein Team verantwortet

Vorgaben im Unternehmenskontext sinnvoll

Kommunikation bei Systemgrenze: Asynchron

Page 27: Frontend Architektur für Microservices - trion …...2019/11/06  · für Microservices Thomas Kruse trion development GmbH Training - Beratung - Entwicklung Kubernetes Spring Boot

Anforderungen des Nutzers

Einstiegspunkte

Übergreifende Navigation

Kontextspezifische Navigation

Keine Brüche im Prozess

Page 28: Frontend Architektur für Microservices - trion …...2019/11/06  · für Microservices Thomas Kruse trion development GmbH Training - Beratung - Entwicklung Kubernetes Spring Boot

Integration der Oberflächen: Navigation

Page 29: Frontend Architektur für Microservices - trion …...2019/11/06  · für Microservices Thomas Kruse trion development GmbH Training - Beratung - Entwicklung Kubernetes Spring Boot

Integration der Oberflächen: Navigation

● Optionen zur Umsetzung der Navigation○ Startseite mit Einstiegslinks

○ Jedes System liefert Navigation

○ Infrastruktur liefert Navigation

Page 30: Frontend Architektur für Microservices - trion …...2019/11/06  · für Microservices Thomas Kruse trion development GmbH Training - Beratung - Entwicklung Kubernetes Spring Boot

Startseite mit Links

Page 31: Frontend Architektur für Microservices - trion …...2019/11/06  · für Microservices Thomas Kruse trion development GmbH Training - Beratung - Entwicklung Kubernetes Spring Boot

Demo

http://localhost:7000/

Page 32: Frontend Architektur für Microservices - trion …...2019/11/06  · für Microservices Thomas Kruse trion development GmbH Training - Beratung - Entwicklung Kubernetes Spring Boot

Jedes System liefert Navigation

● Für Benutzer keine

Systemgrenze

● Navigationsebenen

ggf. limitiert

Page 33: Frontend Architektur für Microservices - trion …...2019/11/06  · für Microservices Thomas Kruse trion development GmbH Training - Beratung - Entwicklung Kubernetes Spring Boot

Varianten

Page 34: Frontend Architektur für Microservices - trion …...2019/11/06  · für Microservices Thomas Kruse trion development GmbH Training - Beratung - Entwicklung Kubernetes Spring Boot

Jedes System liefert Navigation

● Statisch○ Build Zeit

Page 35: Frontend Architektur für Microservices - trion …...2019/11/06  · für Microservices Thomas Kruse trion development GmbH Training - Beratung - Entwicklung Kubernetes Spring Boot

Jedes System liefert Navigation

● Dynamisch○ Zur Laufzeit

● Varianten

○ HTML, zentrales Templating

(Server side rendered)

○ Daten, lokales Templating

Page 36: Frontend Architektur für Microservices - trion …...2019/11/06  · für Microservices Thomas Kruse trion development GmbH Training - Beratung - Entwicklung Kubernetes Spring Boot

Infrastruktur liefert Navigation

● Frames (deprecated)

● Server Side Includes (SSI), Edge Side Includes (ESI)

● Clientseitiger Abruf zentraler Assets○ Wird auch als Transklusion bezeichnet

Page 37: Frontend Architektur für Microservices - trion …...2019/11/06  · für Microservices Thomas Kruse trion development GmbH Training - Beratung - Entwicklung Kubernetes Spring Boot

Anforderungen des Nutzers

Einstiegspunkte

Übergreifende Navigation

Kontextspezifische Navigation

Keine Brüche im Prozess

Page 38: Frontend Architektur für Microservices - trion …...2019/11/06  · für Microservices Thomas Kruse trion development GmbH Training - Beratung - Entwicklung Kubernetes Spring Boot

Tiefe Integration

Allgemeine Funktionalität (z.B. Newsletter abonnieren)

Recherche/Korrelation: Rechnungen eines Kunden

Sprung zu spezifischem UC: Bestellung xy stornieren

Page 39: Frontend Architektur für Microservices - trion …...2019/11/06  · für Microservices Thomas Kruse trion development GmbH Training - Beratung - Entwicklung Kubernetes Spring Boot

Optionen Tiefe Integration

● Link auf Unterbereich von SCS (deep linking)

● Link mit (Rück-)Sprungziel

● Link mit Parameterübergabe

● Link mit Parameterübergabe und (Rück-)Sprungziel

● UI Fragmente (Integration on the Glass/Transklusion)

Page 40: Frontend Architektur für Microservices - trion …...2019/11/06  · für Microservices Thomas Kruse trion development GmbH Training - Beratung - Entwicklung Kubernetes Spring Boot

Link auf Unterbereich

Page 41: Frontend Architektur für Microservices - trion …...2019/11/06  · für Microservices Thomas Kruse trion development GmbH Training - Beratung - Entwicklung Kubernetes Spring Boot

Link mit (Rück-)Sprungziel

Page 42: Frontend Architektur für Microservices - trion …...2019/11/06  · für Microservices Thomas Kruse trion development GmbH Training - Beratung - Entwicklung Kubernetes Spring Boot

Link mit Parameterübergabe

Page 43: Frontend Architektur für Microservices - trion …...2019/11/06  · für Microservices Thomas Kruse trion development GmbH Training - Beratung - Entwicklung Kubernetes Spring Boot

Einsatzbeispiel: SSO

● Microservice○ Authentifizierung (“Login”)

○ Passwort vergessen

○ Passwort ändern

○ Multi Faktor Authentifzierung

○ …

Page 44: Frontend Architektur für Microservices - trion …...2019/11/06  · für Microservices Thomas Kruse trion development GmbH Training - Beratung - Entwicklung Kubernetes Spring Boot

Link mit Parameterübergabe und (Rück-)Sprungziel

Page 45: Frontend Architektur für Microservices - trion …...2019/11/06  · für Microservices Thomas Kruse trion development GmbH Training - Beratung - Entwicklung Kubernetes Spring Boot

Herausforderungen bei Integration

● Zustand bei Anwendungswechsel

● Security○ SSO / AuthN auslagern

○ Rollen, Berechtigungen (AuthZ)

● Grundlage ist guter Schnitt○ Fragment-Mashup ist schwer handhabbar

○ Führt zu enger Kopplung

Page 46: Frontend Architektur für Microservices - trion …...2019/11/06  · für Microservices Thomas Kruse trion development GmbH Training - Beratung - Entwicklung Kubernetes Spring Boot

Zustand...

… wie funktioniert das mit modernen Anwendungen?

Page 47: Frontend Architektur für Microservices - trion …...2019/11/06  · für Microservices Thomas Kruse trion development GmbH Training - Beratung - Entwicklung Kubernetes Spring Boot

Demo

http://localhost:8080/

Angular + Spring Boot

Gemeinsame Navigation zur Build Zeit

Reloadfähig, navigierbar

Page 48: Frontend Architektur für Microservices - trion …...2019/11/06  · für Microservices Thomas Kruse trion development GmbH Training - Beratung - Entwicklung Kubernetes Spring Boot

Angular und Spring Boot

Vorgehen repräsentativ für andere SPA Frameworks

HTML5 Routing verwenden (Server-Side Rewrite Rules)

Angular Modulsystem ermöglicht große, wartbare Anwendungen

Angular Features: Crawlbar (SEO), I18N, Wiederverwendung

Wartbarkeit dank TypeScript

Gemeinsames Deployment als Option - oder Container

Page 49: Frontend Architektur für Microservices - trion …...2019/11/06  · für Microservices Thomas Kruse trion development GmbH Training - Beratung - Entwicklung Kubernetes Spring Boot

Skalierung der Entwicklung

Page 50: Frontend Architektur für Microservices - trion …...2019/11/06  · für Microservices Thomas Kruse trion development GmbH Training - Beratung - Entwicklung Kubernetes Spring Boot

Organisation

● Umsetzung mit NPM

● Artefakt Repository

● Statisch / Build-Time

● Team Organisation

○ Horizontal (Framework)

○ Vertikal (Domäne)

App1 App2 App3

Lib Lib Lib Lib Lib

Lib

Lib Lib Lib

Third-Party

Third-Party

Page 51: Frontend Architektur für Microservices - trion …...2019/11/06  · für Microservices Thomas Kruse trion development GmbH Training - Beratung - Entwicklung Kubernetes Spring Boot

Erfahrungen

Angst vor Nutzung von Frameworkfeatures (Kopplung)

Domänengrenzen hängen stark vom Zoom-Level ab

“Warenkorb” und “Artikeldarstellung”vs.

“Shop” und “Buchhaltung”vs.

“Shopping” und “Cloud”

Organisationsgrenzen geben Anwendungsdomänen vor (Conway)

Page 52: Frontend Architektur für Microservices - trion …...2019/11/06  · für Microservices Thomas Kruse trion development GmbH Training - Beratung - Entwicklung Kubernetes Spring Boot

Tips

Modellierung mit DDD bietet sich an

Prozesse dabei im Auge behalten, Domänensprünge minimieren

Frameworks bieten nicht nur Nachteile - Vorteile nutzen

Wartbarkeit hat auch etwas mit Testabdeckung zu tun

Echte Anforderungen von Scheinanforderungen trennen

Page 53: Frontend Architektur für Microservices - trion …...2019/11/06  · für Microservices Thomas Kruse trion development GmbH Training - Beratung - Entwicklung Kubernetes Spring Boot

Supporting Domains ...

… gibt es Vorschläge?

Page 54: Frontend Architektur für Microservices - trion …...2019/11/06  · für Microservices Thomas Kruse trion development GmbH Training - Beratung - Entwicklung Kubernetes Spring Boot

Beispiele

Suche / Auswahl von Geschäftspartner

Normalisierung / Validierung von Parametern

Postkorb / Nachrichten

Statusinformationen

Web Analytics

Page 55: Frontend Architektur für Microservices - trion …...2019/11/06  · für Microservices Thomas Kruse trion development GmbH Training - Beratung - Entwicklung Kubernetes Spring Boot

Andere machen es so - Google Maps

<script async defer src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&callback=initMap"></script>

Page 56: Frontend Architektur für Microservices - trion …...2019/11/06  · für Microservices Thomas Kruse trion development GmbH Training - Beratung - Entwicklung Kubernetes Spring Boot

Andere machen es so - Google Maps

<script async defer src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&callback=initMap"></script>

https://developers.google.com/maps/documentation/javascript/events

Page 57: Frontend Architektur für Microservices - trion …...2019/11/06  · für Microservices Thomas Kruse trion development GmbH Training - Beratung - Entwicklung Kubernetes Spring Boot

Widgets

iframe

script / web component

html transklusion

Page 58: Frontend Architektur für Microservices - trion …...2019/11/06  · für Microservices Thomas Kruse trion development GmbH Training - Beratung - Entwicklung Kubernetes Spring Boot

Widgets

Zugriff auf Backend transparent (inkl. Konfiguration)

Typischer Einsatz: Unidirektionaler Datenfluss nach Initialisierung

Component Varianten: Self-Contained vs. Framework-integriert

Page 59: Frontend Architektur für Microservices - trion …...2019/11/06  · für Microservices Thomas Kruse trion development GmbH Training - Beratung - Entwicklung Kubernetes Spring Boot

Verwendung Framework-Components

Beispiel: Angular Lazy-Loaded Modules

Vollständige Integration in Anwendung

Partizipiert an State-Management

Tradeoff: Kopplung an Framework

Page 60: Frontend Architektur für Microservices - trion …...2019/11/06  · für Microservices Thomas Kruse trion development GmbH Training - Beratung - Entwicklung Kubernetes Spring Boot

Isolierte Komponenten

Keine Framework Abhängigkeit

Verwendung in beliebigem Kontext

Technologie: Web Components(ggf. iframe)

Integration meist aufwändiger (DOM Eventing)

Page 61: Frontend Architektur für Microservices - trion …...2019/11/06  · für Microservices Thomas Kruse trion development GmbH Training - Beratung - Entwicklung Kubernetes Spring Boot

Web Component Frameworks

API ist low-level, Bibliothek ratsam

Polymer

Angular Elements

Page 62: Frontend Architektur für Microservices - trion …...2019/11/06  · für Microservices Thomas Kruse trion development GmbH Training - Beratung - Entwicklung Kubernetes Spring Boot

Demo

http://localhost:7000/news/

Page 63: Frontend Architektur für Microservices - trion …...2019/11/06  · für Microservices Thomas Kruse trion development GmbH Training - Beratung - Entwicklung Kubernetes Spring Boot

Agnostische Komponente ...

… kann man doch orchestrieren!

Page 64: Frontend Architektur für Microservices - trion …...2019/11/06  · für Microservices Thomas Kruse trion development GmbH Training - Beratung - Entwicklung Kubernetes Spring Boot

SPA Meta Framework / MicrofrontendsTechnologien: DOM Events, Frames, Meta-Router

Versprechen: Keine Abhängigkeit, Team-Autonomie

Realität: Eigenes Framework, Technologie-Zoo, schwer analysierbar, (~ Portal Server), Performance Impact, schwer testbar

Ggf. zur Transition, keine allgemein empfehlenswerte Zielarchitektur

Page 65: Frontend Architektur für Microservices - trion …...2019/11/06  · für Microservices Thomas Kruse trion development GmbH Training - Beratung - Entwicklung Kubernetes Spring Boot

Transklusion-Mesh Versprechen: Keine Abhängigkeit

Realität: Eigenes Framework, API schwer handhabbar, schwer analysierbar, Performance Impact, schlechte Testbarkeit

Herausforderung Security, Resilienz

Ggf. für einzelne View-Only Anreicherungen (vgl. Google Maps)

Laufzeit Monolith, Gefahr zyklischer Abhängigkeiten!

Page 66: Frontend Architektur für Microservices - trion …...2019/11/06  · für Microservices Thomas Kruse trion development GmbH Training - Beratung - Entwicklung Kubernetes Spring Boot

Danke.Fragen?

Thomas Kruse

@everflux trion.de