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
mruby-ipvs
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
rrreeeyyy
May 08, 2014
Research
750
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
もう一度考える SRE チームの作り方・育て方 / Rethinking SRE #1: Building and Growing SRE Teams
rrreeeyyy
6
1.2k
Reliability in the Age of AI: Engineering for AI Velocity
rrreeeyyy
0
210
Rethinking Incident Response: Context-Aware AI in Practice - Incident Buddy Edition -
rrreeeyyy
0
280
Rethinking Incident Response: Context-Aware AI in Practice
rrreeeyyy
3
2.6k
Incident Response Practices: Waroom's Features and Future Challenges
rrreeeyyy
0
340
An Efficient Incident Response Training with AI / SRE NEXT 2024 Sponsor Session
rrreeeyyy
1
6.3k
カンファレンスから見る SRE トレンド 2024 / SRE Trends from Conferences in 2024 #SRE_Findy
rrreeeyyy
4
2.7k
信頼性の育て方 / mackerel-meetup-15
rrreeeyyy
10
3k
SRE の歩き方・進め方 / sre-walk-through-procedure
rrreeeyyy
0
9k
Other Decks in Research
See All in Research
ハードウェア研究で国際トップ会議を目指す!IROS 2027での論文採択を目指して
ayatokanada
6
3.8k
Physical AIでモデリングはどう変わるか/How Physical AI Will Change Modeling
stktu
0
180
[IR Reading 2026春 論文紹介] LLM-based Listwise Reranking under the Effect of Positional Bias (ECIR 2026) /IR-Reading-2026-Spring
koheishinden
PRO
0
420
[最先端NLP勉強会2026] Agentic Rubrics as Contextual Verifiers for SWE Agents
rfujii
1
360
Claude Code × autoresearch 実践
mathbullet
0
270
「AIとWhyを深堀る」をAIと深堀る
iflection
0
620
PHTalks Bengaluru - SSRF When All Else Fails
dk999
0
1.1k
IA for theory
gpeyre
1
420
最先端NLP 2026 論文紹介: Wait, Wait, Wait... Why Do Reasoning Models Loop? / SNLP Paper Review: Wait, Wait, Wait... Why Do Reasoning Models Loop?
tkng
0
230
Visual SLAM未来予測 / Future Prediction in Visual SLAM
koide3
1
1k
超効率化への挑戦:1bit LLMの現状と展望
yumaichikawa
0
710
Research Engineerという仕事 / Research Engineering: Bridging Research and Business
chck
1
320
Featured
See All Featured
Designing for Timeless Needs
cassininazir
1
480
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
PRO
202
76k
Public Speaking Without Barfing On Your Shoes - THAT 2023
reverentgeek
1
560
Done Done
chrislema
186
16k
Reality Check: Gamification 10 Years Later
codingconduct
0
2.3k
Prompt Engineering for Job Search
mfonobong
0
450
sira's awesome portfolio website redesign presentation
elsirapls
0
410
The SEO Collaboration Effect
kristinabergwall1
1
560
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
254
22k
How Fast Is Fast Enough? [PerfNow 2025]
tammyeverts
3
880
Statistics for Hackers
jakevdp
799
230k
Visualization
eitanlees
152
17k
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 などの自動化ソフトウェアが活躍