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
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
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
もう一度考える SRE チームの作り方・育て方 / Rethinking SRE #1: Building and Growing SRE Teams
rrreeeyyy
6
1.1k
Reliability in the Age of AI: Engineering for AI Velocity
rrreeeyyy
0
200
Rethinking Incident Response: Context-Aware AI in Practice - Incident Buddy Edition -
rrreeeyyy
0
270
Rethinking Incident Response: Context-Aware AI in Practice
rrreeeyyy
3
2.6k
Incident Response Practices: Waroom's Features and Future Challenges
rrreeeyyy
0
330
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.6k
信頼性の育て方 / mackerel-meetup-15
rrreeeyyy
10
3k
SRE の歩き方・進め方 / sre-walk-through-procedure
rrreeeyyy
0
9k
Other Decks in Research
See All in Research
【中間報告】国会議員の立法・政策実務を支える環境を巡る現状と課題
polipoli
0
500
医療LLMの現在地〜最新研究から社会実装までを考える〜
kento1109
1
1.7k
Cross-Media Information Spaces and Architectures
signer
PRO
0
350
Vector Map as Language: Toward Unified Remote Sensing Vector Mapping
satai
3
210
コーディングエージェントとABNを再考
hf149
2
840
Anthropic が提案する LLM の内部状態を自然言語で説明可能にした Natural Language Autoencoders / Natural Language Autoencoders Produce Unsupervised Explanations of LLM Activations
shunk031
0
190
RS-Agent: Automating Remote Sensing Tasks through Intelligent Agent
satai
3
500
Sleuthcon Keynote - How Cybercriminals (ab)use AI
fr0gger
0
300
GLIM とMegaParticles:正規分布近似の限界とタイトカップリング&パーティクルフィルタの進展 / GLIM and MegaParticles : Progress of the distribution representation in SLAM
koide3
0
750
National high-resolution cropland classification of Japan with agricultural census information and multi-temporal multi-modality datasets
satai
3
470
J-STAGEの現況と全文XML登載必須化について
xspa2012
0
160
Visual SLAM未来予測 / Future Prediction in Visual SLAM
koide3
1
940
Featured
See All Featured
How to Get Subject Matter Experts Bought In and Actively Contributing to SEO & PR Initiatives.
livdayseo
0
180
The Invisible Side of Design
smashingmag
301
52k
Exploring the relationship between traditional SERPs and Gen AI search
raygrieselhuber
PRO
2
4.3k
How to Grow Your eCommerce with AI & Automation
katarinadahlin
PRO
1
250
Unsuck your backbone
ammeep
672
58k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
25
2k
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.8k
BBQ
matthewcrist
89
10k
Done Done
chrislema
186
16k
How to make the Groovebox
asonas
2
2.4k
Impact Scores and Hybrid Strategies: The future of link building
tamaranovitovic
0
420
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
4.5k
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 などの自動化ソフトウェアが活躍