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
420
Chaos Engineering - W-JAX 2018
mrbw
0
290
Chaos Engineering - AWS Community Days 2018
mrbw
0
730
Chaos Engineering @ JUG Bonn
mrbw
0
140
Chaos Engineering @ Microservices Meetup Berlin
mrbw
0
110
Spring Cloud Netf
mrbw
1
160
Hysterie in verteilten Systemen - Hystrix im Einsatz
mrbw
0
300
Resilience mit Hystrix: Fehlertoleranz statt Hochverfügbarkeit
mrbw
0
230
Hystrix @ Vaadin Meetup Düsseldorf
mrbw
0
58
Other Decks in Programming
See All in Programming
今年一番支援させていただいたのは認証系サービスでした
satoshi256kbyte
1
260
Scalaから始めるOpenFeature入門 / Scalaわいわい勉強会 #4
arthur1
1
330
HTTP compression in PHP and Symfony apps
dunglas
2
1.7k
MCP with Cloudflare Workers
yusukebe
2
220
Cloudflare MCP ServerでClaude Desktop からWeb APIを構築
kutakutat
1
550
SymfonyCon Vienna 2025: Twig, still relevant in 2025?
fabpot
3
1.2k
良いユニットテストを書こう
mototakatsu
8
2.6k
Semantic Kernelのネイティブプラグインで知識拡張をしてみる
tomokusaba
0
180
Асинхронность неизбежна: как мы проектировали сервис уведомлений
lamodatech
0
810
今年のアップデートで振り返るCDKセキュリティのシフトレフト/2024-cdk-security-shift-left
tomoki10
0
210
たのしいparse.y
ydah
3
120
テストコード文化を0から作り、変化し続けた組織
kazatohiei
2
1.5k
Featured
See All Featured
Fantastic passwords and where to find them - at NoRuKo
philnash
50
2.9k
Principles of Awesome APIs and How to Build Them.
keavy
126
17k
Making the Leap to Tech Lead
cromwellryan
133
9k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
251
21k
Code Review Best Practice
trishagee
65
17k
The Pragmatic Product Professional
lauravandoore
32
6.3k
Building Adaptive Systems
keathley
38
2.3k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
29
2.3k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
232
17k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
45
2.2k
Docker and Python
trallard
42
3.1k
Designing for Performance
lara
604
68k
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