Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
CircuitBreakerの適用
Search
Yoshitomo Hayashi
February 28, 2017
1.8k
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
CircuitBreakerの適用
Yoshitomo Hayashi
February 28, 2017
More Decks by Yoshitomo Hayashi
See All by Yoshitomo Hayashi
Ameba DSPのOpen-Auctionにおける入札戦略
yyhayashi303
2
3k
進化する配信ロジックとDSP戦略
yyhayashi303
1
170
モブプロ導入で見えてきた効果@オレシカナイト
yyhayashi303
1
1.2k
CTRオンライン予測システムのアーキテクチャ
yyhayashi303
2
4.5k
Featured
See All Featured
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
37
6.6k
Are puppies a ranking factor?
jonoalderson
2
4k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
12
1.3k
Reflections from 52 weeks, 52 projects
jeffersonlam
356
21k
Docker and Python
trallard
47
4.2k
From π to Pie charts
rasagy
1
380
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
123
22k
Kristin Tynski - Automating Marketing Tasks With AI
techseoconnect
PRO
0
530
Navigating Weather and Climate Data
rabernat
0
540
A Modern Web Designer's Workflow
chriscoyier
699
190k
Navigating Algorithm Shifts & AI Overviews - #SMXNext
aleyda
1
1.6k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
47
8.3k
Transcript
CircuitBreakerの適用 サイバーエージェント 林 欣朋
目次 • CircuitBreakerの説明 • 障害発生時のハンドリング • 運用・監視として使うCircuitBreaker • まとめ
CircuitBreakerとは Service-A Down Service-B Service-C マイクロサービスで繋がるシステム Service-Cがダウンした場合、障害が連鎖する Timeout Timeout
CircuitBreakerとは Service-A Down Service-B Service-C CircuitBreakerがService-Cの異常を検知し、経路を遮断することで障害の連鎖を防 ぐ Circuit Breaker
マーティン・ファウラー氏のブログ( https://martinfowler.com/bliki/CircuitBreaker.html) OSSの実装 - Java - https://github.com/Netflix/Hystrix - https://github.com/Comcast/jrugged -
Scala - https://github.com/FaKod/Circuit-Breaker-for-Scala - Ruby - https://github.com/wsargent/circuit_breaker/tree/master CircuitBreakerとは
CircuitBreakerのステータス • CLOSED ◦ リモートサービスへのリクエストを実行出来る • OPEN ◦ OPENの間はリモートサービスへのリクエストを実行出来ない •
HALF_OPEN ◦ リモートサービスへのリクエストを再試行し、成功した場合はステータスをリセットする
ステータスの遷移 HALF_OPEN CLOSED OPEN リクエストが失敗した場合 一定期間後HALF_OPEN へ 再試行が失敗した場合 再試行が成功した場合 初期状態
インターフェース interface CircuitBreaker { // リクエスト可能な場合にtrueを返す Boolean allowRequest(); // 処理が正常終了したことを記録する
void onSuccess(); // 処理が異常終了したことを記録する void onFailure(); }
使用例 if (circuitBreaker.allowRequest()) { try { // invoke remote service
circuitBreaker.onSuccess(); } catch (Exception e) { circuitBreaker.onFailure(); } } else { // CircuitBreaker OPEN }
設定値 // 処理を開始する最小リクエスト数 private Integer requestVolumeThreshold; // OPENとなるエラー率 private Integer
errorThresholdPercentage; // エラー率をチェックするデータの期間 private Integer checkDurationSecond; // OPENからHALF_OPENとなるまでの期間 private Integer openDurationSecond;
ステータスの遷移 HALF_OPEN CLOSED OPEN 直近30秒間のリクエストでエラー率が 50%を超えた場合 30秒間はOPEN その後HALF_OPENに 初期状態 再試行の結果、エラー率が
50%を超えた場合 再試行の結果、エラー率が 50%を下回った場合
CircuitBreaker作動イメージ Service-A Down Service-B Service-C 計測したエラー率からService-Cの異常を検知し、経路を遮断することで障害の連鎖 を防ぐ Circuit Breaker エラー率
> 50%
障害発生時のハンドリング① 例)ターゲティングServiceがダウンした場合 ターゲティングは出来ないので、ターゲティング設定がある広告は候補から除外して 処理を継続する
障害発生時のハンドリング② 例)リタゲの実績やフリークエンシーが取得できない場合 • リタゲ設定のある広告は除外して処理を継続する • フリークエンシーキャップ設定のある広告は除外して処理を継続する
障害発生時のハンドリング③ 例)ランキング用の広告の実績(imp/click)が取得できない場合 • ランダムで配信する • 予測CTRが使える場合は予測CTRでのランキングにする
監視を入れる あるサービスが復数のサービスと連携している時に、経路毎にCircuitBreakerの監 視があると、どこで問題が起きているのかがいち早くわかる。
ステータスを運用ツールから変更できる 運用ツールからCircuitBreakerのステータスを任意で変更できると、あるサービスへ の通信だけを止めたいといった運用が簡単に出来るようになる。
まとめ • CircuitBreakerを入れることで障害の連鎖を防ぐことが出来る • 障害発生時のハンドリングはそもそもちゃんとやっておく • 監視や運用のツールとしても使えるので有用