Upload
-
View
263
Download
2
Embed Size (px)
Citation preview
Immutable Infrastructure in nanapi
2015-04-09 nanapi TechLunch 遠山 晃(@vexus2)
自己紹介
• 遠山 晃 / @vexus2
• リードエンジニア
• GitNote絶賛開発中!!
Immutable Infrastructure?
Immutable Infrastructureとは
• 「その状態を変更できないインフラ構成」
• 稼働中のサーバに対して変更を加えない、という概念
• 変更する場合には新規でサーバを構築させ、既存のものと入れ替える
メリット
• サーバ構成のコード管理/構築が自動化できる
• 全てのサーバが同じ状態であることが担保
• ロールバックが容易に可能
構成要素
AutoScaling
• サーバの負荷などに合わせて自動的にスケールアウト・スケールインする仕組み
Blue-GreenDeployment
• スタンバイサーバにデプロイを行い、デプロイ完了後にLBの向き先をスタンバイ⇔アクティブ切り替えるデプロイ手法
• 問題が起こった際は再度切り替えることでロールバック可能
Users Router
WebServer Application Database
Green server Green Server Green DB
Blue-GreenDeployment
Users Router
WebServer Application Database
Green server Green Server Green DB
Blue server Blue Server Blue DB
Blue-GreenDeployment
Users Router
WebServer Application Database
Green server Green Server Green DB
Blue server Blue Server Blue DB
Blue-GreenDeployment
Users Router
WebServer Application Database
Green server Green Server Green DB
Blue server Blue Server Blue DB
Blue-GreenDeployment
Users Router
WebServer Application Database
Blue server Blue Server Blue DB
Blue-GreenDeployment
Dockerとは
• コンテナベースの仮想化ソフトウェア
• (ホストベースの仮想化にはLinux KVMなど)
• カーネル部分をホストOSと一部共有するためリソース使用量が少ない
• imageのポータビリティ性が高い
nanapi?
“Container based Blue-Green Deployment”
FrontProxy
Application Servers
Rails Container
Rails Container
Rails Container
DeployServer
FrontProxy
Application Servers
Rails Container
Rails Container
Rails Container
DeployServer Deploy
FrontProxy
Application Servers
Rails Container
Rails Container
Rails Container
Rails Container
Rails Container
Rails Container
DeployServer Deploy
FrontProxy
Application Servers
Rails Container
Rails Container
Rails Container
Rails Container
Rails Container
Rails Container
DeployServer
FrontProxy
Application Servers
Rails Container
Rails Container
Rails Container
Rails Container
Rails Container
Rails Container
DeployServer Switch
FrontProxy
Application Servers
Rails Container
Rails Container
Rails Container
Rails Container
Rails Container
Rails Container
DeployServer Switch
FrontProxy
Application Servers
Rails Container
Rails Container
Rails Container
Rails Container
Rails Container
Rails Container
DeployServer Switch
FrontProxy
Application Servers
Rails Container
Rails Container
Rails Container
Rails Container
Rails Container
Rails Container
DeployServer
FrontProxy
Application Servers
Rails Container
Rails Container
Rails Container
Rails Container
Rails Container
Rails Container
DeployServer Cleanup
FrontProxy
Application Servers
Rails Container
Rails Container
Rails Container
DeployServer Cleanup
CbBGDのメリット
• デプロイのたびにインスタンスを倍にする必要がない
• デザイン修正や文言修正程度の軽微なリリースが気軽に出来る
• デプロイ毎のインスタンス初期化処理がスキップ出来るため高速
CbBGDのデメリット
• BlueGreenの向き先はポート番号で管理しているので若干煩雑
• デプロイの際一時的にコンテナが倍立ち上がるのでマシンスペックがそれなりに必要
• FrontProxy自体はImmutableではない
Thank You!