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
55
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
450
Chaos Engineering - W-JAX 2018
mrbw
0
300
Chaos Engineering - AWS Community Days 2018
mrbw
0
760
Chaos Engineering @ JUG Bonn
mrbw
0
150
Chaos Engineering @ Microservices Meetup Berlin
mrbw
0
130
Spring Cloud Netf
mrbw
1
180
Hysterie in verteilten Systemen - Hystrix im Einsatz
mrbw
0
330
Resilience mit Hystrix: Fehlertoleranz statt Hochverfügbarkeit
mrbw
0
240
Hystrix @ Vaadin Meetup Düsseldorf
mrbw
0
69
Other Decks in Programming
See All in Programming
SODA - FACT BOOK
sodainc
1
1.1k
イベントストーミングから始めるドメイン駆動設計
jgeem
4
870
GraphRAGの仕組みまるわかり
tosuri13
7
450
Elixir で IoT 開発、 Nerves なら簡単にできる!?
pojiro
1
150
TypeScript LSP の今までとこれから
quramy
1
510
Javaに鉄道指向プログラミング (Railway Oriented Pro gramming) のエッセンスを取り入れる/Bringing the Essence of Railway-Oriented Programming to Java
cocet33000
2
580
無関心の谷
kanayannet
0
180
アンドパッドの Go 勉強会「 gopher 会」とその内容の紹介
andpad
0
250
Javaのルールをねじ曲げろ!禁断の操作とその代償から学ぶメタプログラミング入門 / A Guide to Metaprogramming: Lessons from Forbidden Techniques and Their Price
nrslib
3
2k
既存デザインを変更せずにタップ領域を広げる方法
tahia910
1
240
Julia という言語について (FP in Julia « SIDE: F ») for 関数型まつり2025
antimon2
3
960
プロダクト開発でも使おう 関数のオーバーロード
yoiwamoto
0
160
Featured
See All Featured
Practical Orchestrator
shlominoach
188
11k
Building an army of robots
kneath
306
45k
BBQ
matthewcrist
89
9.7k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
30
2.1k
Scaling GitHub
holman
459
140k
We Have a Design System, Now What?
morganepeng
52
7.6k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
31
1.2k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
46
9.6k
Music & Morning Musume
bryan
46
6.6k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
252
21k
The Power of CSS Pseudo Elements
geoffreycrofte
77
5.8k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
48
2.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