Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Hystrix Warstories
Search
Benjamin Wilms
April 21, 2016
Programming
0
49
Hystrix Warstories
Hystrix Warstories slides from our talk @ JAX 2016
Benjamin Wilms
April 21, 2016
Tweet
Share
More Decks by Benjamin Wilms
See All by Benjamin Wilms
Chaos Engineering @ Spring I/O 2019 Barcelona
mrbw
1
390
Chaos Engineering - W-JAX 2018
mrbw
0
290
Chaos Engineering - AWS Community Days 2018
mrbw
0
690
Chaos Engineering @ JUG Bonn
mrbw
0
130
Chaos Engineering @ Microservices Meetup Berlin
mrbw
0
97
Spring Cloud Netf
mrbw
1
140
Hysterie in verteilten Systemen - Hystrix im Einsatz
mrbw
0
290
Resilience mit Hystrix: Fehlertoleranz statt Hochverfügbarkeit
mrbw
0
210
Hystrix @ Vaadin Meetup Düsseldorf
mrbw
0
51
Other Decks in Programming
See All in Programming
Milestoner
bkuhlmann
1
410
Ruby Function Composition
bkuhlmann
1
330
educure_カリキュラム生操作マニュアル.pdf
linew_official
0
730
はてなにおける CSS Modules、及び CSS Modules に足りないもの / CSS Modules in Hatena, and CSS Modules missing parts
mizdra
7
920
効率化に挑戦してみたらモバイル開発が少し快適になった話
ryunakayama
0
130
Java 22 Overview
kishida
1
180
Tailwind CSSを本気でカスタマイズする方法
fsubal
13
5.2k
FigmaとPHPで作る1ミリたりとも表示崩れしない最強の帳票印刷ソリューション
ttskch
43
19k
ONE WEDGE_company_guide
1wedge_one
0
470
Compose-View Interop in Practice (mDevCamp 2024)
stewemetal
0
120
Ruby Pattern Matching
bkuhlmann
0
920
冗長なエラーログを削減し、スタックトレースを手に入れる / Reducing Verbose Error Logs and Obtaining Stack Traces
upamune
0
480
Featured
See All Featured
A Modern Web Designer's Workflow
chriscoyier
689
190k
How to name files
jennybc
65
93k
Building an army of robots
kneath
300
41k
The Power of CSS Pseudo Elements
geoffreycrofte
60
5k
The Cult of Friendly URLs
andyhume
74
5.7k
Happy Clients
brianwarren
92
6.4k
Reflections from 52 weeks, 52 projects
jeffersonlam
345
19k
The Illustrated Children's Guide to Kubernetes
chrisshort
31
46k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
226
51k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
78
42k
Designing for Performance
lara
601
67k
Mobile First: as difficult as doing things right
swwweet
216
8.6k
Transcript
Hystrix Warstories_ Benjamin Wilms, Felix Braun
2 Agenda
3 Agenda Hystrix Einführung Resilience Patterns Praxis 1: Hystrix Erfahrungen
Demo Praxis 2: Hystrix und Legacy Backends Advanced Features
4 About us Benjamin Wilms Felix Braun Senior Agile IT-Consultant
www.codecentric.de blog.codecentric.de Senior IT-Consultant
5 Hystrix Introduction
6
7 99,99 %
8 Bei 30 abhängigen µServices: 99,7 %
9 2 Stunden und 15 Minuten Downtime pro Monat
10 Welche Features bietet Hystrix?
11
12
13 Hello World public class CommandHelloWorld extends HystrixCommand<String> { private
final String name; public CommandHelloWorld(String name) { super(HystrixCommandGroupKey.Factory.asKey("ExampleGroup")); this.name = name; } @Override protected String run() { return "Hello " + name; } }
14 Hello World public class CommandHelloWorld extends HystrixCommand<String> { [...]
@Override protected String run() { return getLocalizedHello(name); } @Override protected String getFallback(){ return "Hello " + name; } }
15 8 Resilience Patterns
16 Pattern • Timeout (Hystrix) • Bulkheads (Hystrix) • Circuit
Breaker (Hystrix) • Steady State • Fail Fast • Handshaking • Test harness • Decoupling middleware
17 Real World #1
18 “Architektur”
19 Gewonnene Erfahrungen
20 Funktioniert
21 Gewonnene Erfahrung Laufzeit- Konfiguration
22 Gewonnene Erfahrung Exception Wrapping Flickr: Jessica Spengler
23 Gewonnene Erfahrung Gut geschnitten? Flickr: Roger
24 Gewonnene Erfahrung Viel Schreibarbeit….
25 Java 8 new LambdaHystrixCmd<> ("PingCmd",() -> getPing(), () ->
"pong");
26 Java 8 public class LambdaHystrixCommand<T> extends HystrixCommand<T> { private
Supplier<T> runSupplier; private Supplier<T> fallbackSupplier; public LambdaHystrixCommand(String cmdkey, Supplier<T> runSup, Supplier<T> fallbackSup) { [...] } @Override protected T run() throws Exception { return runSupplier.get();} @Override protected T getFallback() { return fallbackSupplier.get();} }
27 Annotationsbasiert: Spring Cloud / hystrix-javanica @HystrixCommand(fallbackMethod=“defaultUser“) public User getUserById(String
id) { return userResource.getUserById(id); }
28 Integration Day
29 Integration Day
30 Hystrix Dashboard
31 Quo Vadis Hystrix Dashboard?
32 Hystrix Dashboard
33 New Visualization at Netflix
34 Real World #2
35 24/7 Kundenportal Flickr: Jessica Spengler
36 geplante Ausfallzeiten
37 ungeplante Ausfallzeiten
38 Legacy Backend via Hystrix
39 Demo-Anwendung
40 Sender & Receiver Transport (SRT)
41 Demo-Architektur
42 Demo-Architektur
43 Hystrix & Archaius
44 Hystrix & Archaius • dynamic & typed • thread
safe • polling framework • callback mechanism • dynamic configuration
45 Hystrix & Archaius • AWS Dynamo DB • Apache
ZooKeeper • CoreOS etcd
46 CoreOS etcd • Distributed key value store • REST
API • Cluster ready
47 Architektur
48 Archaius & etcd // Config fallback (config.properties) and Etcd
configuration compositeConfig = new ConcurrentCompositeConfiguration(); ClasspathPropertiesConfiguration.initialize(); // File based config // CoreOS Etcd service configuration etcdConfigSource = new EtcdConfigurationSource(etcd, "/hystrix/"); etcdConfig = new DynamicWatchedConfiguration(etcdConfigSource); compositeConfig.addConfiguration(etcdConfig,"etcd dynamic override config"); ConfigurationManager.install(compositeConfig);
49 Chaos Monkey
50 Chaos Monkey
51 Simian Army
52 Archaius & etcd Timeouts Exceptions
53 Archaius & etcd curl -L -X PUT http://etcd:2379/v2/keys/hystrix/chaos.monkey.active -d
value=true
54 Archaius & etcd DynamicBooleanProperty chaosMonkeyActive = DynamicPropertyFactory.getInstance(). getBooleanProperty("chaos.monkey.active", false);
chaosMonkeyActive.get();
55 Demo Hystrix Configuration via etcd
56 Spring Cloud Netflix & Spring Boot @SpringBootApplication @EnableCircuitBreaker @EnableHystrixDashboard
@Import(ArchaiusConfiguration.class) public class TransportServiceAppl { public static void main(String[] args) { SpringApplication.run(TransportServiceApp.class, args); } }
57 new HystrixCmd<>(“DemoCmd", () -> showLiveDemo(), () -> showFallbackVideo() );
58 Demo Zusammenfassung
59 Zusammenfassung • Chaos Monkey aktiviert • Remote Services konfiguriert
• Hystrix Timeouts gesetzt • Hystrix Circuit Breaker open/close • Hystrix Fallbacks deaktiviert
60 Advanced Features
61 Request Collapsing
62 Request Caching
63 Request Caching • Caching auf Request-Ebene (HystrixRequestContext) • Aktiviert
durch implementieren von HystrixCommand.getCacheKey()
64 Cache-Example @GET @Path("/cacheTest/{name}") public void cacheTest(@PathParam("name") String name) {
try (HystrixRequestContext context = HystrixRequestContext.initializeContext()) { for (int i = 0; i < 3; i++) { LambdaHystrixCommand<String> pingCmd = new LambdaHystrixCommand<>( „CacheCmd", „CacheCmdCache",() -> getPing(name), () -> "pong"); String result = pingCmd.execute(); System.out.println(i + ": " + result + " is from cache: " + pingCmd.isResponseFromCache()); }} }
65 Cache-Example @GET @Path("/cacheTest/{name}") public void cacheTest(@PathParam("name") String name) {
try (HystrixRequestContext context = HystrixRequestContext.initializeContext()) { for (int i = 0; i < 3; i++) { LambdaHystrixCommand<String> pingCmd = new LambdaHystrixCommand<>( „CacheCmd", „CacheCmdCache",() -> getPing(name), () -> "pong"); String result = pingCmd.execute(); System.out.println(i + ": " + result + " is from cache: " + pingCmd.isResponseFromCache()); }} }
66 Cache-Example @GET @Path("/cacheTest/{name}") public void cacheTest(@PathParam("name") String name) {
try (HystrixRequestContext context = HystrixRequestContext.initializeContext()) { for (int i = 0; i < 3; i++) { LambdaHystrixCommand<String> pingCmd = new LambdaHystrixCommand<>( „CacheCmd", „CacheCmdCache",() -> getPing(name), () -> "pong"); String result = pingCmd.execute(); System.out.println(i + ": " + result + " is from cache: " + pingCmd.isResponseFromCache()); }} }
67 GitHub Demo-Projekt unter: github.com/MrBW/hystrix-warstories-applications
68 Danke. Fragen?
69