Immutable Infrastructure in nanapi

32
Immutable Infrastructure in nanapi 2015-04-09 nanapi TechLunch 遠山 (@vexus2)

Transcript of Immutable Infrastructure in nanapi

Page 1: Immutable Infrastructure in nanapi

Immutable Infrastructure in nanapi

2015-04-09 nanapi TechLunch 遠山 晃(@vexus2)

Page 2: Immutable Infrastructure in nanapi

自己紹介

• 遠山 晃 / @vexus2

• リードエンジニア

• GitNote絶賛開発中!!

Page 3: Immutable Infrastructure in nanapi

Immutable Infrastructure?

Page 4: Immutable Infrastructure in nanapi

Immutable Infrastructureとは

• 「その状態を変更できないインフラ構成」

• 稼働中のサーバに対して変更を加えない、という概念

• 変更する場合には新規でサーバを構築させ、既存のものと入れ替える

Page 5: Immutable Infrastructure in nanapi

メリット

• サーバ構成のコード管理/構築が自動化できる

• 全てのサーバが同じ状態であることが担保

• ロールバックが容易に可能

Page 6: Immutable Infrastructure in nanapi

構成要素

Page 7: Immutable Infrastructure in nanapi

AutoScaling

• サーバの負荷などに合わせて自動的にスケールアウト・スケールインする仕組み

Page 8: Immutable Infrastructure in nanapi

Blue-GreenDeployment

• スタンバイサーバにデプロイを行い、デプロイ完了後にLBの向き先をスタンバイ⇔アクティブ切り替えるデプロイ手法

• 問題が起こった際は再度切り替えることでロールバック可能

Page 9: Immutable Infrastructure in nanapi

Users Router

WebServer Application Database

Green server Green Server Green DB

Blue-GreenDeployment

Page 10: Immutable Infrastructure in nanapi

Users Router

WebServer Application Database

Green server Green Server Green DB

Blue server Blue Server Blue DB

Blue-GreenDeployment

Page 11: Immutable Infrastructure in nanapi

Users Router

WebServer Application Database

Green server Green Server Green DB

Blue server Blue Server Blue DB

Blue-GreenDeployment

Page 12: Immutable Infrastructure in nanapi

Users Router

WebServer Application Database

Green server Green Server Green DB

Blue server Blue Server Blue DB

Blue-GreenDeployment

Page 13: Immutable Infrastructure in nanapi

Users Router

WebServer Application Database

Blue server Blue Server Blue DB

Blue-GreenDeployment

Page 14: Immutable Infrastructure in nanapi
Page 15: Immutable Infrastructure in nanapi

Dockerとは

• コンテナベースの仮想化ソフトウェア

• (ホストベースの仮想化にはLinux KVMなど)

• カーネル部分をホストOSと一部共有するためリソース使用量が少ない

• imageのポータビリティ性が高い

Page 16: Immutable Infrastructure in nanapi

nanapi?

Page 17: Immutable Infrastructure in nanapi
Page 18: Immutable Infrastructure in nanapi
Page 19: Immutable Infrastructure in nanapi

“Container based Blue-Green Deployment”

Page 20: Immutable Infrastructure in nanapi

FrontProxy

Application Servers

Rails Container

Rails Container

Rails Container

DeployServer

Page 21: Immutable Infrastructure in nanapi

FrontProxy

Application Servers

Rails Container

Rails Container

Rails Container

DeployServer Deploy

Page 22: Immutable Infrastructure in nanapi

FrontProxy

Application Servers

Rails Container

Rails Container

Rails Container

Rails Container

Rails Container

Rails Container

DeployServer Deploy

Page 23: Immutable Infrastructure in nanapi

FrontProxy

Application Servers

Rails Container

Rails Container

Rails Container

Rails Container

Rails Container

Rails Container

DeployServer

Page 24: Immutable Infrastructure in nanapi

FrontProxy

Application Servers

Rails Container

Rails Container

Rails Container

Rails Container

Rails Container

Rails Container

DeployServer Switch

Page 25: Immutable Infrastructure in nanapi

FrontProxy

Application Servers

Rails Container

Rails Container

Rails Container

Rails Container

Rails Container

Rails Container

DeployServer Switch

Page 26: Immutable Infrastructure in nanapi

FrontProxy

Application Servers

Rails Container

Rails Container

Rails Container

Rails Container

Rails Container

Rails Container

DeployServer Switch

Page 27: Immutable Infrastructure in nanapi

FrontProxy

Application Servers

Rails Container

Rails Container

Rails Container

Rails Container

Rails Container

Rails Container

DeployServer

Page 28: Immutable Infrastructure in nanapi

FrontProxy

Application Servers

Rails Container

Rails Container

Rails Container

Rails Container

Rails Container

Rails Container

DeployServer Cleanup

Page 29: Immutable Infrastructure in nanapi

FrontProxy

Application Servers

Rails Container

Rails Container

Rails Container

DeployServer Cleanup

Page 30: Immutable Infrastructure in nanapi

CbBGDのメリット

• デプロイのたびにインスタンスを倍にする必要がない

• デザイン修正や文言修正程度の軽微なリリースが気軽に出来る

• デプロイ毎のインスタンス初期化処理がスキップ出来るため高速

Page 31: Immutable Infrastructure in nanapi

CbBGDのデメリット

• BlueGreenの向き先はポート番号で管理しているので若干煩雑

• デプロイの際一時的にコンテナが倍立ち上がるのでマシンスペックがそれなりに必要

• FrontProxy自体はImmutableではない

Page 32: Immutable Infrastructure in nanapi

Thank You!