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
54
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
430
Chaos Engineering - W-JAX 2018
mrbw
0
290
Chaos Engineering - AWS Community Days 2018
mrbw
0
740
Chaos Engineering @ JUG Bonn
mrbw
0
140
Chaos Engineering @ Microservices Meetup Berlin
mrbw
0
110
Spring Cloud Netf
mrbw
1
170
Hysterie in verteilten Systemen - Hystrix im Einsatz
mrbw
0
310
Resilience mit Hystrix: Fehlertoleranz statt Hochverfügbarkeit
mrbw
0
230
Hystrix @ Vaadin Meetup Düsseldorf
mrbw
0
60
Other Decks in Programming
See All in Programming
PSR-15 はあなたのための ものではない? - phpcon2024
myamagishi
0
400
Amazon Nova Reelの可能性
hideg
0
200
サーバーゆる勉強会 DBMS の仕組み編
kj455
1
300
アクターシステムに頼らずEvent Sourcingする方法について
j5ik2o
6
700
[JAWS-UG横浜 #80] うわっ…今年のServerless アップデート、少なすぎ…?
maroon1st
0
100
“あなた” の開発を支援する AI エージェント Bedrock Engineer / introducing-bedrock-engineer
gawa
3
130
Запуск 1С:УХ в крупном энтерпрайзе: мечта и реальность ПМа
lamodatech
0
950
テストコード書いてみませんか?
onopon
2
340
DevinとCursorから学ぶAIエージェントメモリーの設計とMoatの考え方
itarutomy
0
150
月刊 競技プログラミングをお仕事に役立てるには
terryu16
1
1.2k
Scaling your build logic
antalmonori
1
100
責務を分離するための例外設計 - PHPカンファレンス 2024
kajitack
9
2.4k
Featured
See All Featured
Mobile First: as difficult as doing things right
swwweet
222
9k
The World Runs on Bad Software
bkeepers
PRO
66
11k
Building a Scalable Design System with Sketch
lauravandoore
460
33k
Why Our Code Smells
bkeepers
PRO
335
57k
Making the Leap to Tech Lead
cromwellryan
133
9k
How GitHub (no longer) Works
holman
312
140k
Product Roadmaps are Hard
iamctodd
PRO
50
11k
Testing 201, or: Great Expectations
jmmastey
41
7.2k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
356
29k
Building Flexible Design Systems
yeseniaperezcruz
328
38k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
230
52k
How to train your dragon (web standard)
notwaldorf
89
5.8k
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