33
“Das Frontend ist ja dann trivial” - Microservices und Web-Frontends Matthias Reuter & Michael Bruns Darmstadt, 22.06.2017

“Das Frontend ist ja dann trivial” - Microservices und Web ... · Microservices und Web-Frontends Matthias Reuter & Michael Bruns Darmstadt, 22.06.2017 › Software developer

  • Upload
    others

  • View
    2

  • Download
    0

Embed Size (px)

Citation preview

Page 1: “Das Frontend ist ja dann trivial” - Microservices und Web ... · Microservices und Web-Frontends Matthias Reuter & Michael Bruns Darmstadt, 22.06.2017 › Software developer

“Das Frontend ist ja dann trivial” -Microservices und Web-Frontends

Matthias Reuter & Michael Bruns Darmstadt, 22.06.2017

Page 2: “Das Frontend ist ja dann trivial” - Microservices und Web ... · Microservices und Web-Frontends Matthias Reuter & Michael Bruns Darmstadt, 22.06.2017 › Software developer

› Software developer and architect

› Built quite a bit of waipu.tv

2

Michael Brunsinovex GmbH

› Frontend developer

› I build stuff for the Internet

Matthias Reuterinovex GmbH

Microservices und Web-Frontends - Matthias Reuter & Michael Bruns

Page 3: “Das Frontend ist ja dann trivial” - Microservices und Web ... · Microservices und Web-Frontends Matthias Reuter & Michael Bruns Darmstadt, 22.06.2017 › Software developer

3

Microservices?!

AuthRegistration PlayoutEPG Recording

Users Streaming

......

ThirdParty

...

Microservices und Web-Frontends - Matthias Reuter & Michael Bruns

Page 4: “Das Frontend ist ja dann trivial” - Microservices und Web ... · Microservices und Web-Frontends Matthias Reuter & Michael Bruns Darmstadt, 22.06.2017 › Software developer

› Abstract problem split into small solutions

› Monolith would simply be too hard to handle

› Large portions of the application don’t need to know about the rest of the application

› Load peaks on small parts of the application are expected

4Microservices und Web-Frontends - Matthias Reuter & Michael Bruns

Why Microservices?

Page 5: “Das Frontend ist ja dann trivial” - Microservices und Web ... · Microservices und Web-Frontends Matthias Reuter & Michael Bruns Darmstadt, 22.06.2017 › Software developer

› Independent deployment

› Different people with different backgrounds and skills

› Polyglott development

› Most important: We, i.e. the whole team, wanted to do it!

5Microservices und Web-Frontends - Matthias Reuter & Michael Bruns

Why Microservices?

Page 6: “Das Frontend ist ja dann trivial” - Microservices und Web ... · Microservices und Web-Frontends Matthias Reuter & Michael Bruns Darmstadt, 22.06.2017 › Software developer

6Microservices und Web-Frontends - Matthias Reuter & Michael Bruns

That’s it. Microservices are great.You can go home now, the frontend is easy.

Or isn’t it?!

Page 7: “Das Frontend ist ja dann trivial” - Microservices und Web ... · Microservices und Web-Frontends Matthias Reuter & Michael Bruns Darmstadt, 22.06.2017 › Software developer

7Microservices und Web-Frontends - Matthias Reuter & Michael Bruns

Every Service has its own Frontend

Page 8: “Das Frontend ist ja dann trivial” - Microservices und Web ... · Microservices und Web-Frontends Matthias Reuter & Michael Bruns Darmstadt, 22.06.2017 › Software developer

› web-commons› css/› js/› assets/

fonts/ images/

› templates/

8Microservices und Web-Frontends - Matthias Reuter & Michael Bruns

Every Service has its own FrontendNPM package for common code

web-commons

Auth

CDN

RegistrationSelf-care

Page 9: “Das Frontend ist ja dann trivial” - Microservices und Web ... · Microservices und Web-Frontends Matthias Reuter & Michael Bruns Darmstadt, 22.06.2017 › Software developer

"dependencies": { "web-commons": "git+ssh://[email protected]/ bs/web-commons.git#v1.7.3"}

9Microservices und Web-Frontends - Matthias Reuter & Michael Bruns

Every Service has its own FrontendAdd NPM package to dependencies via git tag

Page 10: “Das Frontend ist ja dann trivial” - Microservices und Web ... · Microservices und Web-Frontends Matthias Reuter & Michael Bruns Darmstadt, 22.06.2017 › Software developer

✔ Scalability✔ Independent deployment

➖ Code duplication➖ Bad for caching➖ Pages with content from several services➖ Generalists vs. specialists

10

Every Service has its own Frontend

Microservices und Web-Frontends - Matthias Reuter & Michael Bruns

Page 11: “Das Frontend ist ja dann trivial” - Microservices und Web ... · Microservices und Web-Frontends Matthias Reuter & Michael Bruns Darmstadt, 22.06.2017 › Software developer

11Microservices und Web-Frontends - Matthias Reuter & Michael Bruns

Single Page Application!

Page 12: “Das Frontend ist ja dann trivial” - Microservices und Web ... · Microservices und Web-Frontends Matthias Reuter & Michael Bruns Darmstadt, 22.06.2017 › Software developer

12Microservices und Web-Frontends - Matthias Reuter & Michael Bruns

Single Page Application

AuthRegistrationSelf-care

REST API

Page 13: “Das Frontend ist ja dann trivial” - Microservices und Web ... · Microservices und Web-Frontends Matthias Reuter & Michael Bruns Darmstadt, 22.06.2017 › Software developer

› Backend supports old and new API› in parallel› for a while

Via Path:https://auth.waipu.tv/api/v3/login

Via Header:Accept: application/vnd.waipu.auth-v3+json

13Microservices und Web-Frontends - Matthias Reuter & Michael Bruns

Single Page ApplicationAPI changes - Backend solution

Page 14: “Das Frontend ist ja dann trivial” - Microservices und Web ... · Microservices und Web-Frontends Matthias Reuter & Michael Bruns Darmstadt, 22.06.2017 › Software developer

login() .then(function (res) { userName = res.userName; });

14Microservices und Web-Frontends - Matthias Reuter & Michael Bruns

Single Page ApplicationAPI changes - Frontend solution

Page 15: “Das Frontend ist ja dann trivial” - Microservices und Web ... · Microservices und Web-Frontends Matthias Reuter & Michael Bruns Darmstadt, 22.06.2017 › Software developer

login() .then(function (res) { userName = res.user.name; });

15Microservices und Web-Frontends - Matthias Reuter & Michael Bruns

Single Page ApplicationAPI changes - Frontend solution

Page 16: “Das Frontend ist ja dann trivial” - Microservices und Web ... · Microservices und Web-Frontends Matthias Reuter & Michael Bruns Darmstadt, 22.06.2017 › Software developer

login() .then(function (res) { return res.user ? res : { user: { name: res.userName } }; }) .then(function (res) { userName = res.user.name; });

16Microservices und Web-Frontends - Matthias Reuter & Michael Bruns

Single Page ApplicationAPI changes - Frontend solution

Page 17: “Das Frontend ist ja dann trivial” - Microservices und Web ... · Microservices und Web-Frontends Matthias Reuter & Michael Bruns Darmstadt, 22.06.2017 › Software developer

✔ Scalability✔ Code duplication✔ Good for caching✔ Pages with content from

several services✔ Generalists vs. specialists

17Microservices und Web-Frontends - Matthias Reuter & Michael Bruns

Single Page Application

➖ Independent Deployment➖ Initial page load time➖ Dependency on JS➖ Sequence of requests

Page 18: “Das Frontend ist ja dann trivial” - Microservices und Web ... · Microservices und Web-Frontends Matthias Reuter & Michael Bruns Darmstadt, 22.06.2017 › Software developer

18Microservices und Web-Frontends - Matthias Reuter & Michael Bruns

Single Page Application

Auth

Sequence of requests

Subscription

Recording

EPG

Page 19: “Das Frontend ist ja dann trivial” - Microservices und Web ... · Microservices und Web-Frontends Matthias Reuter & Michael Bruns Darmstadt, 22.06.2017 › Software developer

19Microservices und Web-Frontends - Matthias Reuter & Michael Bruns

Backend for Frontend

Auth

Sequence of requests

Subscription

Recording

EPG

BFF

Page 20: “Das Frontend ist ja dann trivial” - Microservices und Web ... · Microservices und Web-Frontends Matthias Reuter & Michael Bruns Darmstadt, 22.06.2017 › Software developer

20Microservices und Web-Frontends - Matthias Reuter & Michael Bruns

Backend for Frontend

Auth

Reusable concept

Subscription

Recording

EPG

BFF BFF

Page 21: “Das Frontend ist ja dann trivial” - Microservices und Web ... · Microservices und Web-Frontends Matthias Reuter & Michael Bruns Darmstadt, 22.06.2017 › Software developer

✔ Scalability✔ All the benefits of an SPA✔ Sequence of requests✔ Server-side rendering!

✔ Initial page load time✔ Dependency on JS

21Microservices und Web-Frontends - Matthias Reuter & Michael Bruns

Backend for Frontend

➖ Independent Deployment➖ API changes

Page 22: “Das Frontend ist ja dann trivial” - Microservices und Web ... · Microservices und Web-Frontends Matthias Reuter & Michael Bruns Darmstadt, 22.06.2017 › Software developer

22Microservices und Web-Frontends - Matthias Reuter & Michael Bruns

Server-side Includes

Subscription

Recording

User

Page 23: “Das Frontend ist ja dann trivial” - Microservices und Web ... · Microservices und Web-Frontends Matthias Reuter & Michael Bruns Darmstadt, 22.06.2017 › Software developer

23Microservices und Web-Frontends - Matthias Reuter & Michael Bruns

Server-side IncludesExample: nginx

http { server { location / { root /some/path; ssi on; } }}

Page 24: “Das Frontend ist ja dann trivial” - Microservices und Web ... · Microservices und Web-Frontends Matthias Reuter & Michael Bruns Darmstadt, 22.06.2017 › Software developer

24Microservices und Web-Frontends - Matthias Reuter & Michael Bruns

Server-side IncludesExample: nginx

<html> <body> <!--#include file="user-agent.html" --> </body></html>

user-agent.html:<p>Hey, you've got a nice user agent:</p><p><!--#echo var="HTTP_USER_AGENT" --></p>

Page 25: “Das Frontend ist ja dann trivial” - Microservices und Web ... · Microservices und Web-Frontends Matthias Reuter & Michael Bruns Darmstadt, 22.06.2017 › Software developer

✔ Scalability✔ Independent deployment✔ Code duplication✔ Good for caching✔ Pages with content from

several services

25Microservices und Web-Frontends - Matthias Reuter & Michael Bruns

Server-side Includes

➖ Generalists vs. specialists➖ Backend logic needed to

assemble page➖ Bundled CSS/JS➖ Global Styles/Scripts

Page 26: “Das Frontend ist ja dann trivial” - Microservices und Web ... · Microservices und Web-Frontends Matthias Reuter & Michael Bruns Darmstadt, 22.06.2017 › Software developer

26Microservices und Web-Frontends - Matthias Reuter & Michael Bruns

Web-Components

HTML-Imports

Shadow-DOM

Custom Elements

<waipu-rec-self-care user-id=”08154711” />

<link rel=”import” href=”https://recording.waipu.tv/comp/self-care” />

› DOM hidden from outside› Styles kept inside

Page 27: “Das Frontend ist ja dann trivial” - Microservices und Web ... · Microservices und Web-Frontends Matthias Reuter & Michael Bruns Darmstadt, 22.06.2017 › Software developer

27Microservices und Web-Frontends - Matthias Reuter & Michael Bruns

Web-Components

Recording

Subscription

User

Page 28: “Das Frontend ist ja dann trivial” - Microservices und Web ... · Microservices und Web-Frontends Matthias Reuter & Michael Bruns Darmstadt, 22.06.2017 › Software developer

✔ Scalability✔ Independent deployment✔ Good for caching✔ Pages with content from

several services✔ Generalists vs. specialists✔ Bundled CSS/JS

28Microservices und Web-Frontends - Matthias Reuter & Michael Bruns

Web-Components

➖ Code duplication➖ Depends on JavaScript

Page 29: “Das Frontend ist ja dann trivial” - Microservices und Web ... · Microservices und Web-Frontends Matthias Reuter & Michael Bruns Darmstadt, 22.06.2017 › Software developer

29Microservices und Web-Frontends - Matthias Reuter & Michael Bruns

And now for something completely different...

Page 30: “Das Frontend ist ja dann trivial” - Microservices und Web ... · Microservices und Web-Frontends Matthias Reuter & Michael Bruns Darmstadt, 22.06.2017 › Software developer

30Microservices und Web-Frontends - Matthias Reuter & Michael Bruns

MonorepoOne to rule them all

web-commons

Auth

Registration

Self-care

...

✔ Scalability✔ Independent deployment✔ No code duplication✔ No integration overhead✔ Easy code sharing

➖ Version management➖ Code once, break everywhere

Page 31: “Das Frontend ist ja dann trivial” - Microservices und Web ... · Microservices und Web-Frontends Matthias Reuter & Michael Bruns Darmstadt, 22.06.2017 › Software developer

31Microservices und Web-Frontends - Matthias Reuter & Michael Bruns

TestabilityEnd-to-end Tests

➖ Every Service has its own Frontend✔ Single Page Application✔ Backend for Frontend➖ Server-side Includes➖ Web-Components✔ Monorepo

Page 32: “Das Frontend ist ja dann trivial” - Microservices und Web ... · Microservices und Web-Frontends Matthias Reuter & Michael Bruns Darmstadt, 22.06.2017 › Software developer

32Microservices und Web-Frontends - Matthias Reuter & Michael Bruns

One final note...

Both lines have the same length ?

Don’t believe anything just because it’s written on a slide!

Page 33: “Das Frontend ist ja dann trivial” - Microservices und Web ... · Microservices und Web-Frontends Matthias Reuter & Michael Bruns Darmstadt, 22.06.2017 › Software developer

Vielen Dank

Matthias Reuter@gweax

Michael Bruns

@der_miggel

inovex GmbH

Ludwig-Erhard-Allee 6

76131 Karlsruhe