A High-Performance Solution To Microservices UI Composition
-
Upload
alexey-gravanov -
Category
Internet
-
view
231 -
download
5
Transcript of A High-Performance Solution To Microservices UI Composition
![Page 1: A High-Performance Solution To Microservices UI Composition](https://reader035.fdocuments.in/reader035/viewer/2022081512/58a1a87f1a28abe6468b5c33/html5/thumbnails/1.jpg)
www.autoscout24.com
www.autoscout24.com | www.thoughtworks.com
A High-Performance Solution To Microservices UI CompositionNDC Oslo | June 8, 2016 | Arif Wider & Alexey Gravanov
![Page 2: A High-Performance Solution To Microservices UI Composition](https://reader035.fdocuments.in/reader035/viewer/2022081512/58a1a87f1a28abe6468b5c33/html5/thumbnails/2.jpg)
AutoScout24
2
PL
S
RUS
UA
RO
CZ
D
NL
B
FA
HRI
E
BG
TR
17countries
2.4m+cars & motos
~3bpage impressions
per month
![Page 3: A High-Performance Solution To Microservices UI Composition](https://reader035.fdocuments.in/reader035/viewer/2022081512/58a1a87f1a28abe6468b5c33/html5/thumbnails/3.jpg)
MotivationProject Tatsu
![Page 4: A High-Performance Solution To Microservices UI Composition](https://reader035.fdocuments.in/reader035/viewer/2022081512/58a1a87f1a28abe6468b5c33/html5/thumbnails/4.jpg)
4
Project TatsuFrom a .NET Monolith to AWS-hosted Microservices
![Page 5: A High-Performance Solution To Microservices UI Composition](https://reader035.fdocuments.in/reader035/viewer/2022081512/58a1a87f1a28abe6468b5c33/html5/thumbnails/5.jpg)
Project Tatsu: Goals
5
• Reduce time to market
• Release new features quickly (for test or production)
• Enable teams to innovate independently
![Page 6: A High-Performance Solution To Microservices UI Composition](https://reader035.fdocuments.in/reader035/viewer/2022081512/58a1a87f1a28abe6468b5c33/html5/thumbnails/6.jpg)
Autonomous Teams, Loosely Coupled Services
6
Allow for cross-functional teams that are able to independently create, improve, and run their services.
Avoid tight coupling as much as possible!
![Page 7: A High-Performance Solution To Microservices UI Composition](https://reader035.fdocuments.in/reader035/viewer/2022081512/58a1a87f1a28abe6468b5c33/html5/thumbnails/7.jpg)
Don't Compromise Page Performance
7
• Achieve PageSpeed Insights score of 95+
• Strive for low latency
• Benefit from caching whenever possible
tricky to combine with high team autonomy
![Page 8: A High-Performance Solution To Microservices UI Composition](https://reader035.fdocuments.in/reader035/viewer/2022081512/58a1a87f1a28abe6468b5c33/html5/thumbnails/8.jpg)
Breaking the MonolithThe API Gateway Pattern
8
![Page 9: A High-Performance Solution To Microservices UI Composition](https://reader035.fdocuments.in/reader035/viewer/2022081512/58a1a87f1a28abe6468b5c33/html5/thumbnails/9.jpg)
API Gateway Pattern: AutoScout24 Homepage
9
![Page 10: A High-Performance Solution To Microservices UI Composition](https://reader035.fdocuments.in/reader035/viewer/2022081512/58a1a87f1a28abe6468b5c33/html5/thumbnails/10.jpg)
API Gateway Pattern
10
HomeHeader/Footer
Ads
API Gateway
Mobileapps
Great for page performance :)
![Page 11: A High-Performance Solution To Microservices UI Composition](https://reader035.fdocuments.in/reader035/viewer/2022081512/58a1a87f1a28abe6468b5c33/html5/thumbnails/11.jpg)
API Gateway Pattern: Drawbacks
11
HomeHeader/Footer
Ads
API Gateway
Mobileapps
no truly independent vertical feature releases
because of “UI monolith“
Bad for team autonomy :(
![Page 12: A High-Performance Solution To Microservices UI Composition](https://reader035.fdocuments.in/reader035/viewer/2022081512/58a1a87f1a28abe6468b5c33/html5/thumbnails/12.jpg)
Breaking the Monolith The UI Composition Pattern
12
![Page 13: A High-Performance Solution To Microservices UI Composition](https://reader035.fdocuments.in/reader035/viewer/2022081512/58a1a87f1a28abe6468b5c33/html5/thumbnails/13.jpg)
UI Composition Pattern
13
HomeAds
Header/Footer
one service = one vertical slice
Great for team autonomy :)
![Page 14: A High-Performance Solution To Microservices UI Composition](https://reader035.fdocuments.in/reader035/viewer/2022081512/58a1a87f1a28abe6468b5c33/html5/thumbnails/14.jpg)
Challenges of UI Composition
14
• Combine HTML
• Let services deliver their own styles and JavaScript
• Page structure must not break page performance
• Request latency needs to stay low
• Independent and integration testing of UI components
Tricky for page performance!
![Page 15: A High-Performance Solution To Microservices UI Composition](https://reader035.fdocuments.in/reader035/viewer/2022081512/58a1a87f1a28abe6468b5c33/html5/thumbnails/15.jpg)
First AttemptVarnish & ESI
![Page 16: A High-Performance Solution To Microservices UI Composition](https://reader035.fdocuments.in/reader035/viewer/2022081512/58a1a87f1a28abe6468b5c33/html5/thumbnails/16.jpg)
Varnish & ESI
16
![Page 17: A High-Performance Solution To Microservices UI Composition](https://reader035.fdocuments.in/reader035/viewer/2022081512/58a1a87f1a28abe6468b5c33/html5/thumbnails/17.jpg)
ESI Include
17
<html> <head> <title>AutoScout24</title> <!-- CSS of page --> <link rel="stylesheet" href="/assets/home/ebacb8194-main.min.css" /> </head> <body> <!-- ESI include of header --> <esi:include src="http://content.as24.com/fragment/header_de_DE" /> Lorem ipsum....
<!-- JavaScript of page --> <script src="/assets/home/66ee72f9-main.min.js"></script> </body></html>
![Page 18: A High-Performance Solution To Microservices UI Composition](https://reader035.fdocuments.in/reader035/viewer/2022081512/58a1a87f1a28abe6468b5c33/html5/thumbnails/18.jpg)
ESI Include Resolved
18
<html> <head> <title>AutoScout24</title> <!-- CSS of page --> <link rel="stylesheet" href="/assets/home/ebacb8194-main.min.css" /> </head> <body> <!-- CSS of fragment --> <link rel="stylesheet" href="http://content.as24.com/assets/08ffaf28-main.min.css" />
<ul><li>Home</li><li>Search</li><li>Sell</li></ul>
<!-- JavaScript of fragment --> <script src="http://content.as24.com/assets/26ed612f-main.min.js"></script>
Lorem ipsum.... <!-- JavaScript of page --> <script src="/assets/home/66ee72f9-main.min.js"></script> </body></html>
Bad page speed :(
![Page 19: A High-Performance Solution To Microservices UI Composition](https://reader035.fdocuments.in/reader035/viewer/2022081512/58a1a87f1a28abe6468b5c33/html5/thumbnails/19.jpg)
Multiple ESI Includes
19
<html> <head> <title>AutoScout24</title> <!-- CSS of page --> <link rel="stylesheet" href="/assets/home/ebacb8194-main.min.css" />
<!-- ESI include for header CSS --> <esi:include src="http://content.example.com/fragment/header_styles" /> </head> <body> <!-- ESI include for header --> <esi:include src="http://content.example.com/fragment/header_de_DE" />
Lorem ipsum.... <!-- JavaScript for page --> <script src="/assets/home/66ee72f9-main.min.js"></script>
<!-- ESI include for header JavaScript --> <esi:include src="http://content.example.com/fragment/header_scripts" /> </body></html>
![Page 20: A High-Performance Solution To Microservices UI Composition](https://reader035.fdocuments.in/reader035/viewer/2022081512/58a1a87f1a28abe6468b5c33/html5/thumbnails/20.jpg)
Multiple ESI Includes Resolved
20
<html> <head> <title>AutoScout24</title> <!-- CSS for page --> <link rel="stylesheet" href="/assets/home/ebacb8194-main.min.css" />
<!-- CSS for header --> <link rel="stylesheet" href="http://content.example.com/assets/08ffaf28-main.css" /> </head> <body> <ul><li>Home</li><li>Search</li><li>Sell</li></ul>
Lorem ipsum.... <!-- JavaScript for page --> <script src="/assets/home/66ee72f9-main.min.js"></script>
<!-- JavaScript for header --> <script src="http://content.example.com/assets/26ed612f-main.js"></script> </body></html>
Asset version inconsistency :(
![Page 21: A High-Performance Solution To Microservices UI Composition](https://reader035.fdocuments.in/reader035/viewer/2022081512/58a1a87f1a28abe6468b5c33/html5/thumbnails/21.jpg)
Varnish & ESI: Issues
21
• Bad page performance because of page structure
• Attempts to optimize the page structure led to increased complexity regarding the asset handling
• High burden on the content providing teams
• Combining assets with ESI adds complexity
• AWS ELB as Varnish backend wasn’t working
![Page 22: A High-Performance Solution To Microservices UI Composition](https://reader035.fdocuments.in/reader035/viewer/2022081512/58a1a87f1a28abe6468b5c33/html5/thumbnails/22.jpg)
Requirements for a better solution
22
• References to asset URIs need to be included in HTML snippet
• Therefore post-processing of references is required
• Support for combined assets
• Support for inlining CSS/JS
• Support for shared cache between instances
![Page 23: A High-Performance Solution To Microservices UI Composition](https://reader035.fdocuments.in/reader035/viewer/2022081512/58a1a87f1a28abe6468b5c33/html5/thumbnails/23.jpg)
JigsawHow to solve it
![Page 24: A High-Performance Solution To Microservices UI Composition](https://reader035.fdocuments.in/reader035/viewer/2022081512/58a1a87f1a28abe6468b5c33/html5/thumbnails/24.jpg)
Jigsaw Components
24
![Page 25: A High-Performance Solution To Microservices UI Composition](https://reader035.fdocuments.in/reader035/viewer/2022081512/58a1a87f1a28abe6468b5c33/html5/thumbnails/25.jpg)
Request Flow
25
![Page 26: A High-Performance Solution To Microservices UI Composition](https://reader035.fdocuments.in/reader035/viewer/2022081512/58a1a87f1a28abe6468b5c33/html5/thumbnails/26.jpg)
Request Flow
26
![Page 27: A High-Performance Solution To Microservices UI Composition](https://reader035.fdocuments.in/reader035/viewer/2022081512/58a1a87f1a28abe6468b5c33/html5/thumbnails/27.jpg)
Request Flow
27
![Page 28: A High-Performance Solution To Microservices UI Composition](https://reader035.fdocuments.in/reader035/viewer/2022081512/58a1a87f1a28abe6468b5c33/html5/thumbnails/28.jpg)
Request Flow
28
![Page 29: A High-Performance Solution To Microservices UI Composition](https://reader035.fdocuments.in/reader035/viewer/2022081512/58a1a87f1a28abe6468b5c33/html5/thumbnails/29.jpg)
Request Flow
29
![Page 30: A High-Performance Solution To Microservices UI Composition](https://reader035.fdocuments.in/reader035/viewer/2022081512/58a1a87f1a28abe6468b5c33/html5/thumbnails/30.jpg)
Pages
30
are publicly accessible
get called from the client
include fragments
could be cacheable
define contracts
are parts of a page
get called from Nginx SSI
could include fragments
should be cacheable
adhere to contracts
Fragments
![Page 31: A High-Performance Solution To Microservices UI Composition](https://reader035.fdocuments.in/reader035/viewer/2022081512/58a1a87f1a28abe6468b5c33/html5/thumbnails/31.jpg)
SSI Include
31
<html> <head> <title>AutoScout24</title> <!-- Minified and combined css used by this page (not by the fragments) --> <link rel="stylesheet" href="/assets/home/ebacb8194-main.min.css" /> </head> <body> <!--#include virtual="/headerservice/fragment/header_de_DE" --> Lorem ipsum.... <!-- Minified and combined javascript used by this page --> <script type="text/javascript" src="/assets/home/66ee72f9-main.min.js"></script> </body> </html>
![Page 32: A High-Performance Solution To Microservices UI Composition](https://reader035.fdocuments.in/reader035/viewer/2022081512/58a1a87f1a28abe6468b5c33/html5/thumbnails/32.jpg)
SSI Include Resolved
32
<html> <head> <title>AutoScout24</title> <!-- Minified and combined css used by this page (not by the fragments) --> <link rel="stylesheet" href="/assets/home/ebacb8194-main.min.css" /> </head> <body> <head> <!-- Minified and combined css used by this fragment --> <link rel="stylesheet" href="/assets/headerservice/08ffaf28-main.min.css" /> </head> <ul><li>Home</li><li>Search</li><li>Sell</li></ul> <script type="text/javascript" src="/assets/headerservice/26ed612f-main.js"></script> Lorem ipsum.... <!-- Minified and combined javascript used by this page --> <script type="text/javascript" src="/assets/home/66ee72f9-main.min.js"></script> </body> </html>
![Page 33: A High-Performance Solution To Microservices UI Composition](https://reader035.fdocuments.in/reader035/viewer/2022081512/58a1a87f1a28abe6468b5c33/html5/thumbnails/33.jpg)
ngx_pagespeed: combine heads
33
<html> <head> <title>AutoScout24</title> <!-- Minified and combined css used by this page (not by the fragments) --> <link rel="stylesheet" href="/assets/home/ebacb8194-main.min.css" /> <link rel="stylesheet" href="/assets/headerservice/08ffaf28-main.min.css" /> </head> <body> <ul><li>Home</li><li>Search</li><li>Sell</li></ul> <script type="text/javascript" src="/assets/headerservice/26ed612f-main.js"></script> Lorem ipsum.... <!-- Minified and combined javascript used by this page --> <script type="text/javascript" src="/assets/home/66ee72f9-main.min.js"></script> </body> </html>
![Page 34: A High-Performance Solution To Microservices UI Composition](https://reader035.fdocuments.in/reader035/viewer/2022081512/58a1a87f1a28abe6468b5c33/html5/thumbnails/34.jpg)
ngx_pagespeed: combine CSS & JS
34
<html> <head> <title>AutoScout24</title> <!-- Minified and combined css by pagespeed --> <link rel="stylesheet" href="/assets/home,,_ebacb8194-main.min.css +headerservice,,_08ffaf28-main.min.css" /> </head> <body> <ul><li>Home</li><li>Search</li><li>Sell</li></ul> Lorem ipsum.... <!-- Minified and combined js by pagespeed --> <script type="text/javascript" href="/assets/home,,_ebacb8194-main.min.js +headerservice,,_08ffaf28-main.min.js" defer async /> </body> </html>
![Page 35: A High-Performance Solution To Microservices UI Composition](https://reader035.fdocuments.in/reader035/viewer/2022081512/58a1a87f1a28abe6468b5c33/html5/thumbnails/35.jpg)
Page Performance of Composed Page
35
![Page 36: A High-Performance Solution To Microservices UI Composition](https://reader035.fdocuments.in/reader035/viewer/2022081512/58a1a87f1a28abe6468b5c33/html5/thumbnails/36.jpg)
Page Performance of Composed Page
36
![Page 37: A High-Performance Solution To Microservices UI Composition](https://reader035.fdocuments.in/reader035/viewer/2022081512/58a1a87f1a28abe6468b5c33/html5/thumbnails/37.jpg)
Caching
37
![Page 38: A High-Performance Solution To Microservices UI Composition](https://reader035.fdocuments.in/reader035/viewer/2022081512/58a1a87f1a28abe6468b5c33/html5/thumbnails/38.jpg)
Recap
38
![Page 39: A High-Performance Solution To Microservices UI Composition](https://reader035.fdocuments.in/reader035/viewer/2022081512/58a1a87f1a28abe6468b5c33/html5/thumbnails/39.jpg)
nginx Proxy Cache
39
• Caches responses from upstream services
• Respects cache headers from upstream services
• Supports cache key control via Vary Header
• AWS ElastiCache (memcached, via ngx_srcache module)
![Page 40: A High-Performance Solution To Microservices UI Composition](https://reader035.fdocuments.in/reader035/viewer/2022081512/58a1a87f1a28abe6468b5c33/html5/thumbnails/40.jpg)
Pagespeed Cache
40
• Caches generated assets
• AWS ElastiCache (memcached)
• state is externalized to AWS
• allows for stateless web server machines
• no cache synchronization
• no cold cache
![Page 41: A High-Performance Solution To Microservices UI Composition](https://reader035.fdocuments.in/reader035/viewer/2022081512/58a1a87f1a28abe6468b5c33/html5/thumbnails/41.jpg)
Jigsaw Caching of Assets
41
![Page 42: A High-Performance Solution To Microservices UI Composition](https://reader035.fdocuments.in/reader035/viewer/2022081512/58a1a87f1a28abe6468b5c33/html5/thumbnails/42.jpg)
Jigsaw Caching of Documents
42
![Page 43: A High-Performance Solution To Microservices UI Composition](https://reader035.fdocuments.in/reader035/viewer/2022081512/58a1a87f1a28abe6468b5c33/html5/thumbnails/43.jpg)
Jigsaw Caching of Documents with Vary Header
43
![Page 44: A High-Performance Solution To Microservices UI Composition](https://reader035.fdocuments.in/reader035/viewer/2022081512/58a1a87f1a28abe6468b5c33/html5/thumbnails/44.jpg)
Testing
![Page 45: A High-Performance Solution To Microservices UI Composition](https://reader035.fdocuments.in/reader035/viewer/2022081512/58a1a87f1a28abe6468b5c33/html5/thumbnails/45.jpg)
Local Testing
45
![Page 46: A High-Performance Solution To Microservices UI Composition](https://reader035.fdocuments.in/reader035/viewer/2022081512/58a1a87f1a28abe6468b5c33/html5/thumbnails/46.jpg)
Local Testing
46
Jigsaw Header
Footer
Homepage
Development machine
HeaderJigsaw
![Page 47: A High-Performance Solution To Microservices UI Composition](https://reader035.fdocuments.in/reader035/viewer/2022081512/58a1a87f1a28abe6468b5c33/html5/thumbnails/47.jpg)
Jigsaw Best Practice Analyzer
47
• Checks HTML code for anti-patterns
• defer async
• page barriers (inline scripts)
• CSS outside of <head>
• stylesheet refs with different attributes
• Can run in a deployment pipeline
![Page 48: A High-Performance Solution To Microservices UI Composition](https://reader035.fdocuments.in/reader035/viewer/2022081512/58a1a87f1a28abe6468b5c33/html5/thumbnails/48.jpg)
Things yet to be solved
48
• Authentication
• Native mobile apps
![Page 49: A High-Performance Solution To Microservices UI Composition](https://reader035.fdocuments.in/reader035/viewer/2022081512/58a1a87f1a28abe6468b5c33/html5/thumbnails/49.jpg)
Conclusion
![Page 50: A High-Performance Solution To Microservices UI Composition](https://reader035.fdocuments.in/reader035/viewer/2022081512/58a1a87f1a28abe6468b5c33/html5/thumbnails/50.jpg)
Features of the UI Composition Solution
50
• Teams are in full control of their service's UI and do not need to rely on others when changing it
• Fragments have a simple structure with head, body and script parts
• Page performance is not compromised
• Jigsaw serves as an effective cache layer
• Fragments can be tested in isolation, and in integration with other pages or fragments
• It’s live and serves thousands of requests per second flawlessly :)
![Page 51: A High-Performance Solution To Microservices UI Composition](https://reader035.fdocuments.in/reader035/viewer/2022081512/58a1a87f1a28abe6468b5c33/html5/thumbnails/51.jpg)
www.autoscout24.com
www.autoscout24.com | www.thoughtworks.com
Thank you!Questions?Contact:[email protected]@autoscout24.com (@gravanov)