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
750
Chaos Engineering @ JUG Bonn
mrbw
0
140
Chaos Engineering @ Microservices Meetup Berlin
mrbw
0
120
Spring Cloud Netf
mrbw
1
170
Hysterie in verteilten Systemen - Hystrix im Einsatz
mrbw
0
320
Resilience mit Hystrix: Fehlertoleranz statt Hochverfügbarkeit
mrbw
0
230
Hystrix @ Vaadin Meetup Düsseldorf
mrbw
0
62
Other Decks in Programming
See All in Programming
Formの複雑さに立ち向かう
bmthd
1
850
第3回関東Kaggler会_AtCoderはKaggleの役に立つ
chettub
3
1k
Linux && Docker 研修/Linux && Docker training
forrep
24
4.5k
dbt Pythonモデルで実現するSnowflake活用術
trsnium
0
150
Honoのおもしろいミドルウェアをみてみよう
yusukebe
1
210
JavaScriptツール群「UnJS」を5分で一気に駆け巡る!
k1tikurisu
9
1.8k
時計仕掛けのCompose
mkeeda
1
300
第3回 Snowflake 中部ユーザ会- dbt × Snowflake ハンズオン
hoto17296
4
370
2024年のkintone API振り返りと2025年 / kintone API look back in 2024
tasshi
0
220
コミュニティ駆動 AWS CDK ライブラリ「Open Constructs Library」 / community-cdk-library
gotok365
2
120
SwiftUIで単方向アーキテクチャを導入して得られた成果
takuyaosawa
0
270
お前もAI鬼にならないか?👹Bolt & Cursor & Supabase & Vercelで人間をやめるぞ、ジョジョー!👺
taishiyade
6
4k
Featured
See All Featured
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
226
22k
The Art of Programming - Codeland 2020
erikaheidi
53
13k
Agile that works and the tools we love
rasmusluckow
328
21k
Mobile First: as difficult as doing things right
swwweet
223
9.3k
Rebuilding a faster, lazier Slack
samanthasiow
80
8.8k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
30
2.2k
Large-scale JavaScript Application Architecture
addyosmani
511
110k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
666
120k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
53k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
44
7k
Build The Right Thing And Hit Your Dates
maggiecrowley
34
2.5k
Building Applications with DynamoDB
mza
93
6.2k
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