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
mruby-ipvs
Search
rrreeeyyy
May 08, 2014
Research
740
2
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
mruby-ipvs
卒業研究発表
rrreeeyyy
May 08, 2014
More Decks by rrreeeyyy
See All by rrreeeyyy
Reliability in the Age of AI: Engineering for AI Velocity
rrreeeyyy
0
120
Rethinking Incident Response: Context-Aware AI in Practice - Incident Buddy Edition -
rrreeeyyy
0
240
Rethinking Incident Response: Context-Aware AI in Practice
rrreeeyyy
3
2.5k
Incident Response Practices: Waroom's Features and Future Challenges
rrreeeyyy
0
310
An Efficient Incident Response Training with AI / SRE NEXT 2024 Sponsor Session
rrreeeyyy
1
6.2k
カンファレンスから見る SRE トレンド 2024 / SRE Trends from Conferences in 2024 #SRE_Findy
rrreeeyyy
4
2.6k
信頼性の育て方 / mackerel-meetup-15
rrreeeyyy
10
2.9k
SRE の歩き方・進め方 / sre-walk-through-procedure
rrreeeyyy
0
9k
「信頼性」を保ちつつ大規模サービスをリニューアルする / cookpad-tech-kitchen-service-embedded-sres
rrreeeyyy
11
13k
Other Decks in Research
See All in Research
Φ-Sat-2のAutoEncoderによる情報圧縮系論文
satai
4
770
CyberAgent AI Lab研修 / Social Implementation Anti-Patterns in AI Lab
chck
7
4.6k
第66回コンピュータビジョン勉強会@関東 Epona: Autoregressive Diffusion World Model for Autonomous Driving
kentosasaki
0
630
2026-01-30-MandSL-textbook-jp-cos-lod
yegusa
1
1.3k
(SIGQS17) Frasco-VS:フラグメントに基づく薬剤候補化合物選抜の量子アニーリングによる実現
keisukeyanagisawa
PRO
0
110
COFFEE-Japan PROJECT Impact Report(Uminomukou Coffee)
ontheslope
0
180
R&Dチームを起ち上げる
shibuiwilliam
1
270
AI Agentの精度改善に見るML開発との共通点 / commonalities in accuracy improvements in agentic era
shimacos
6
1.7k
セマンティック通信勉強会 6Gに向けたデバイス間効率的な通信の技術紹介・課題・今後展望
satai
3
160
The Landscape of Agentic Reinforcement Learning for LLMs: A Survey
shunk031
4
1k
「AIとWhyを深堀る」をAIと深堀る
iflection
0
480
Unified Audio Source Separation (Defense Slides)
kohei_1979
1
610
Featured
See All Featured
VelocityConf: Rendering Performance Case Studies
addyosmani
333
25k
Build your cross-platform service in a week with App Engine
jlugia
234
18k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
17k
Being A Developer After 40
akosma
91
590k
Designing Powerful Visuals for Engaging Learning
tmiket
1
410
WENDY [Excerpt]
tessaabrams
11
38k
Marketing Yourself as an Engineer | Alaka | Gurzu
gurzu
0
230
Amusing Abliteration
ianozsvald
1
200
Building the Perfect Custom Keyboard
takai
2
790
The Art of Programming - Codeland 2020
erikaheidi
57
14k
End of SEO as We Know It (SMX Advanced Version)
ipullrank
3
4.2k
The Illustrated Guide to Node.js - THAT Conference 2024
reverentgeek
1
380
Transcript
mruby を用いた Linux ロードバランサ インタフェースの実装 卒業研究最終発表 ! 中野研究室 吉川竜太 2014/2/6
背景 - ロードバランサ • サーバの負荷を分散させるシステム • クライアントからのリクエストを 複数のサーバに振り分ける • サービスの可用性・拡張性の需要の高まりに
伴い普及 • 振り分け先のサーバを定期的に確認し, 異常があれば振り分けをやめる (ヘルスチェック)
ロードバランサによる振り分け
ヘルスチェック
• Linux のロードバランサ • Linux カーネル 2.6 以降に組み込まれている • 振り分けの設定として,次のような方法がある
• C 言語のライブラリである libipvs を用いる方法 • 設定用のソフトウェアである Keepalived を用いる方法 • Keepalived を用いる方法が一般的である IP Virtual Server (IPVS)
IPVS 設定用のインタフェース • libipvs • C 言語を用いるため記述力は高い • メモリ管理や文字列操作が煩雑 •
ヘルスチェックの機能を記述するのが煩雑 • Keepalived • 設定ファイルで簡潔に記述することが可能 • 複雑な操作は出来ず,記述力が低い • ヘルスチェックの機能が限定的である
インタフェースごとの比較 記述力 ヘルスチェック 簡潔性 libipvs ◯ △ ✕ Keepalived ✕
△ ◯
目的と方針 • 目的 • IPVS の記述力・簡潔性の高いインタフェースの実装 • 方針 • 組込み向けで軽量な
Ruby である mruby を採用 • libipvs のラッパーを mruby に実装する • 実装したラッパーを使い,より簡単な構文で書ける モジュールを mruby を用いて実装
ラッパーの実装 lb = IPVS::Service.new({ 'addr' => '10.0.0.1', 'port' => 80})
web1 = IPVS::Dest.new({ 'addr' => '192.168.0.1', 'port' => 80}) lb.add_service lb.add_dest(web1) • ロードバランサ・振り分け先をインスタンスとして生成 • libipvs の関数名を mruby のメソッドとして提供 • libipvs の主な構造体の関数がほとんど利用可能
モジュールの実装 • mruby の記述力の高さを利用し,設定ファイル風の 構文で書けるモジュールを実装 • 設定ファイルの構文中に mruby
のコードを挿入可能 • 外部ライブラリを用いることで自由なヘルスチェック が可能 • 例として,Keepalived 風の構文を実装し,比較する
Keepalived の記述例 virtual_server 192.168.0.1 80 { real_server 192.168.0.2 80 {
HTTP_GET { url { path / } } } real_server 192.168.0.3 80 { } } 192.168.0.1の80番ポートに来た接続を 192.168.0.2, 192.168.0.3の80番ポートへ 振り分ける設定 HTTPのGETを用いたヘルスチェック
Keepalived の問題点 (1) virtual_server 192.168.0.1 80 { real_server 192.168.0.2 80
{ HTTP_GET { url { path / } } } real_server 192.168.0.3 80 { } } ヘルスチェックの方法が限定的 動的なサーバ追加等は出来ない Keepalivedで定められたヘルスチェックしか出来ない 状況に応じた動的なサーバ追加などは出来ない
Keepalived の問題点 (2) virtual_server 192.168.0.1 80 { real_server 192.168.0.2 80
{ HTTP_GET { url { path / } ! } real_server 192.168.0.3 80 { } } 上記設定をそのまま記述すると、 192.168.0.1を192.168.0.2に 振り分ける設定と解釈し動作 ブレースが足りないがエラーは出ない 意図しない設定で動作してしまう
本実装による記述例 (1) 192.168.0.1の80番ポートに来た接続を 192.168.0.2, 192.168.0.3の80番ポートへ 振り分ける設定 virtual_server("192.168.0.1:80") { web1 =
real_server ("192.168.0.2:80") { healthcheck {|lvs, dests| if Curl::get(web1.addr).body == nil lvs.del_dest(web1) end } } real_server("192.168.0.3:80") { } }
本実装による記述例 (2) virtual_server("192.168.0.1:80"){ web1 = real_server("192.168.0.1:80"){ healthcheck {|lvs, dests| if
Curl::get(web1.addr).body == nil lvs.del_dest(web1) end if dests.length < 2 real_server("192.168.0.4:80"){} end } } real_server("192.168.0.3:80"){ } } 外部ライブラリを使った HTTPのGETによるヘルスチェック 振り分け先が2つ未満 になったらサーバ追加 mruby のコードが そのまま書けるため 自由なヘルスチェック定義・ 動的なサーバ追加などが可能 mruby が構文チェックを行うため、 ブレースが欠けてしまった場合は実行されない
まとめ • Linuxのロードバランサである IPVS を mruby を用いて操作できるインタフェースを実装 • 記述力の高い mruby
でインタフェースを実装することに より様々な構文を定義することが可能 • 例としてKeepalived風の構文を実装し,問題点を解決 • 近日公開予定
関連研究 • ipvsadm • Linux のコマンドとして提供される IPVS のインタ フェース •
ldirectord • Keepalived と同様,設定ファイルを用いて IPVS の操 作を行うソフトウェア • mod_mruby [松本ら ’12] • mruby を用いて Web サーバ Apache の機能拡張を行 える機構を実装
なぜmrubyを使うのか • mruby • 組込み開発でも利用できる軽量 Ruby • 既存の C/C++ アプリケーションと共存可能
• ロードバランサのようなリアルタイム処理に 向いている • サーバエンジニアの業界で Ruby が流行 • Chef/Vagrant などの自動化ソフトウェアが活躍