scalable and cost effective systems architecture on aws

46
AWSで実現する スケーラブルでコスト効率の良いシステム構成 Amazon Web Services Japan K.K. ソリューションアーキテクト 篠原 英治 2017年12⽉4⽇ @ Bullet Live! #2

Upload: eiji-shinohara

Post on 23-Jan-2018

210 views

Category:

Technology


9 download

TRANSCRIPT

Page 1: Scalable and Cost Effective Systems Architecture on AWS

AWSで実現するスケーラブルでコスト効率の良いシステム構成

Amazon Web Services Japan K.K.ソリューションアーキテクト 篠原 英治2017年12⽉4⽇ @ Bullet Live! #2

Page 2: Scalable and Cost Effective Systems Architecture on AWS

■ ⾃⼰紹介

w/ @werner - Amazon CTO

Eiji Shinohara (篠原 英治)§ Twitter: @shinodogg§ Blog: shinodogg.com

AWS Solutions Architect§ Market: AdTech & Startup

Graduate Part-Time Student§ University of Tsukuba MBA-IB

新宿界隈に棲息しています J§ 2002 – 2010: ⻄新宿§ 2010 – 2016: 初台§ 2016 – 現在: 東中野

Page 3: Scalable and Cost Effective Systems Architecture on AWS

AWSのインフラストラクチャについてTuesday Night Live with Peter DeSantis

https://www.youtube.com/watch?v=dfEcd3zqPOA

Page 4: Scalable and Cost Effective Systems Architecture on AWS

リージョンやAZについて詳細に解説

https://www.youtube.com/watch?v=dfEcd3zqPOA

AWSのインフラストラクチャについて

Page 5: Scalable and Cost Effective Systems Architecture on AWS

AWSのネットワークや仮想化についても⾔及してるのでレイヤー低めの⽅は是⾮ご覧ください!

https://www.youtube.com/watch?v=dfEcd3zqPOA

AWSのインフラストラクチャについて

Page 6: Scalable and Cost Effective Systems Architecture on AWS

ご案内することの多いベーシックなテッパン構成

EC2

S3

RDS Standby

EC2Auto Scaling

CloudFront

AZ-1 AZ-2

§ EC2にWebサーバ§ ALBで複数のAZに負荷分散§ Auto Scalingでアクセスが

多い⽇も安⼼§ RDS MultiAZで可⽤性向上§ 画像や動画はS3から配信

§ CDNでキャッシュ

ALB

Page 7: Scalable and Cost Effective Systems Architecture on AWS

AWS Elastic Beanstalkでサクっと構築

EC2

S3

RDS Standby

EC2Auto Scaling

CloudFront

AZ-1 AZ-2

§ ウィザードに従って構築§ Ruby on RailsやPHPなど

の馴染みのプログラミング⾔語やDockerが選べる

§ CLI(ebコマンド)でデプロイ(blue-green, rolling)

§ .ebextensionsで⾼度なカスタマイズ

§ いざという時はSSH§ eb ssh便利

ALB

Page 8: Scalable and Cost Effective Systems Architecture on AWS

AWS Elastic Beanstalkでサクっと構築

EC2

S3

RDS Standby

EC2Auto Scaling

CloudFront

AZ-1 AZ-2

§ ウィザードに従って構築§ Ruby on RailsやPHPなど

の馴染みのプログラミング⾔語やDockerが選べる

§ CLI(ebコマンド)でデプロイ(blue-green, rolling)

§ .ebextensionsで⾼度なカスタマイズ

§ いざという時はSSH§ eb ssh便利

ALB

この辺のお話は、この後の• タイレルシステムズ さん と• バレットグループ さん から

詳細にご紹介いただけると思います!

Page 9: Scalable and Cost Effective Systems Architecture on AWS

テッパン構成が良さそうなのは分かるんだけど…

そもそもRubyで開発するにはどうしたらイイの…?LinuxとかWindowsサーバーに馴染みがないんだけど最近AWS LambdaとかDockerってよく聞くけど…TwitterやFacebookでAWS関連の凄い構成の記事がシェアされてるけど、まだそこまでの規模じゃない…

Page 10: Scalable and Cost Effective Systems Architecture on AWS

AWS Cloud9

https://www.youtube.com/watch?v=nFKVzEAm-ts&t=4786s

Page 11: Scalable and Cost Effective Systems Architecture on AWS

AWS Cloud9でコードを書こう!

ブラウザ上でコードが書ける統合開発環境• 2010年に創業、2016年にAmazonに買収され、

2017年にAWSのサービスとしてお披露⽬

Page 12: Scalable and Cost Effective Systems Architecture on AWS

AWS Cloud9でコードを書こう!

ブラウザ上でコードが書ける統合開発環境• 2010年に創業、2016年にAmazonに買収され、

2017年にAWSのサービスとしてお披露⽬

まずは、⻄海岸のリージョンでmm

Page 13: Scalable and Cost Effective Systems Architecture on AWS

AWS Cloud9でコードを書こう!

デフォルトのままミニマムな設定で• 後から簡単に捨てたり変えたりできるのがクラウドの良さ

Page 14: Scalable and Cost Effective Systems Architecture on AWS

AWS Cloud9でコードを書こう!

ちょっとだけお待ちいただければすぐ始められます!

Page 15: Scalable and Cost Effective Systems Architecture on AWS

AWS Cloud9でコードを書こう!

RubyでHello World!• hello.rbを作ってRunしただけ。⾯倒なインストール⼀切なし!

Page 16: Scalable and Cost Effective Systems Architecture on AWS

Cloud9で書いたコードをAWS Lambdaにデプロイ

PythonでAWS LambdaでHello World!

Page 17: Scalable and Cost Effective Systems Architecture on AWS

デプロイされたLambdaファンクションをテスト実⾏

引数にHello, World, ! を設定して実⾏

Page 18: Scalable and Cost Effective Systems Architecture on AWS

サーバレスアーキテクチャ

InternetMobile apps AWS Lambda

functions

AWS

API Gateway

AmazonDynamoDB

慣れればこういう構成がサクっと作れるように• Linuxの⿊い画⾯触らなくても⼤丈夫• 夜中に叩き起こされてApache再起動とかしなくてもいい

Page 19: Scalable and Cost Effective Systems Architecture on AWS

サーバレスを扱った書籍もあります

※ マネジメントコンソールのUIが変更になっています&今後改定をしていく予定ですhttps://www.amazon.co.jp/dp/B071FZL2RZ/

Page 20: Scalable and Cost Effective Systems Architecture on AWS

とは⾔え発注元の要件等でサーバーが必要な場合もあるAmazon Lightsail§ Simple Virtual Private Servers on AWS

Page 21: Scalable and Cost Effective Systems Architecture on AWS

Amazon Lightsailウィザードに従って起動するだけ

Page 22: Scalable and Cost Effective Systems Architecture on AWS

Amazon LightsailSSH接続も簡単

Page 23: Scalable and Cost Effective Systems Architecture on AWS

Amazon Lightsailネットワークの設定も簡単§ Lightsail load balancersによってSSL/TLS 証明書も!

• ランディングページやコーポレートサイトをサクっと

Page 24: Scalable and Cost Effective Systems Architecture on AWS

Docker containerDockerのFounderのソロモンさんのインタビュー

http://shinodogg.com/?p=6368

http://www.binpress.com/blog/2015/02/17/podcast-28-solomon-hykes-docker/

Page 25: Scalable and Cost Effective Systems Architecture on AWS

Docker containerLightning Talks at PyCon 2013§ Dockerをオープンソース化する前に何百⼈の前でリーク!

https://www.youtube.com/watch?v=wW9CAH9nSLs

オフィスの外で初めて⼈に⾒せるよ的なこと話しながら今となっては皆さまお馴染みの『 docker run 』

Page 26: Scalable and Cost Effective Systems Architecture on AWS

Docker containerThe future of Linux Containers at PyCon 2013§ dotCloudのUnder the Hoodを⾒せてやるぜ!§ ⽴ち⾒が出るほど満員(男だらけ)の会場を完全にロック

https://www.youtube.com/watch?v=wW9CAH9nSLs

Page 27: Scalable and Cost Effective Systems Architecture on AWS

Docker containerThe future of Linux Containers at PyCon 2013§ ⾃信満々なプレゼンの中でのタイポとか臨場感あってグッとくる

https://www.youtube.com/watch?v=wW9CAH9nSLs

Page 28: Scalable and Cost Effective Systems Architecture on AWS

Docker containerDATADOGさんによると凄い勢いで採⽤が進んでいる

https://www.datadoghq.com/docker-adoption/

Page 29: Scalable and Cost Effective Systems Architecture on AWS

Docker on AWSAWS Fargateローンチ!

EC2と同じような感覚(AutoScaling的にも)でDockerコンテナをAWS上に起動できるようになりました!

https://www.youtube.com/watch?v=8i82i9QYUGs

Page 30: Scalable and Cost Effective Systems Architecture on AWS

AWS FargateでDockerをはじめよう!Nginxのコンテナを簡単に動かす

https://qiita.com/riywo/items/b223bdad2b3ae3bebf55

Page 31: Scalable and Cost Effective Systems Architecture on AWS

AWS FargateでDockerをはじめよう!Nginxのコンテナを簡単に動かす

Page 32: Scalable and Cost Effective Systems Architecture on AWS

AWS FargateでDockerをはじめよう!Nginxのログを確認する

Page 33: Scalable and Cost Effective Systems Architecture on AWS

Spot Instancesを活⽤してコストを削減しよう既にEC2をインスタンスを使っていてコスト削減したい場合、⼀番効くのがSpot Instances

https://www.slideshare.net/AmazonWebServicesJapan/aws-black-belt-online-seminar-2016-amazon-ec2-spot-instances

Page 34: Scalable and Cost Effective Systems Architecture on AWS

コスト削減に⼀番効くのがSpot Instances例) July 26, 2017 / ap-northeast-1 / Linux

On DemandReserved Instances for 1 year

Spot Instances

Spot Block

All Upfront Partial Upfront No Upfront 1h 6h

c4.large $0.126 $0.084(33%)

$0.086(32%)

$0.090(29%)

$0.029(77%)

$0.077(39%)

$0.098(22%)

m4.large $0.129 $0.081(37%)

$0.083(36%)

$0.087(32%)

$0.027(79%)

$0.101(21%)

$0.128(0.7%)

r3.large $0.20 $0.127(36%)

$0.130(35%)

$0.149(26%)

$0.031(84%)

$0.116(42%)

$0.147(26%)

Page 35: Scalable and Cost Effective Systems Architecture on AWS

コスト削減に⼀番効くのがSpot Instances例) July 26, 2017 / ap-northeast-1 / Linux

On DemandReserved Instances for 1 year

Spot Instances

Spot Block

All Upfront Partial Upfront No Upfront 1h 6h

c4.large $0.126 $0.084(33%)

$0.086(32%)

$0.090(29%)

$0.029(77%)

$0.077(39%)

$0.098(22%)

m4.large $0.129 $0.081(37%)

$0.083(36%)

$0.087(32%)

$0.027(79%)

$0.101(21%)

$0.128(0.7%)

r3.large $0.20 $0.127(36%)

$0.130(35%)

$0.149(26%)

$0.031(84%)

$0.116(42%)

$0.147(26%)

Page 36: Scalable and Cost Effective Systems Architecture on AWS

https://www.youtube.com/watch?v=UR8BI2Exkbc

Page 37: Scalable and Cost Effective Systems Architecture on AWS

C4 R3 M4R3 R3

R3 R3 R3

M4 M4

M4 M4 M4

C4 C4

C4 C4 C4

Map Service Search Service Directions Service

https://www.youtube.com/watch?v=UR8BI2Exkbc

Page 38: Scalable and Cost Effective Systems Architecture on AWS

C4

ECS Cluster

R3 M4R3 R3

R3 R3 R3

M4 M4

M4 M4 M4

C4 C4

C4 C4 C4

Map Service Search ServiceDirections Service

https://www.youtube.com/watch?v=UR8BI2Exkbc

Page 39: Scalable and Cost Effective Systems Architecture on AWS

https://www.youtube.com/watch?v=UR8BI2Exkbc

Page 40: Scalable and Cost Effective Systems Architecture on AWS

C4

ECS Cluster

R3 R3 R3

R3 R3 R3

M4

M4

M4 M4

M4 M4

C4 C4

C4 C4 C4

Map Service Search ServiceDirections Service

Spot Fleet

C4

C4

R3

R3

https://www.youtube.com/watch?v=UR8BI2Exkbc

Page 41: Scalable and Cost Effective Systems Architecture on AWS

25%より少ないインスタンス数

80-90%EC2の毎⽉のコスト削減

https://www.youtube.com/watch?v=UR8BI2Exkbc

Page 42: Scalable and Cost Effective Systems Architecture on AWS

25%より少ないインスタンス数

80-90%EC2の毎⽉のコスト削減

https://www.youtube.com/watch?v=UR8BI2Exkbc

Page 43: Scalable and Cost Effective Systems Architecture on AWS

常時決まった台数を稼働させ続けるにはReserved Instancesまとまった⾦額のRIをポチる前にまずはコレを読もう

https://www.slideshare.net/AmazonWebServicesJapan/aws-black-belt-online-seminar-2017-aws-79666227

Page 44: Scalable and Cost Effective Systems Architecture on AWS

AWSコスト最適化⼊⾨

https://www.youtube.com/watch?v=h9WIAhkKVIU

@hiroshix ⽒の講演をYoutubeで⾒ておくのもオススメ

https://d1.awsstatic.com/events/jp/2017/summit/slide/D2T2-7.e0d3cc39d897197a992e11744bf29a3c128e8e8c.pdf

Page 45: Scalable and Cost Effective Systems Architecture on AWS

AWS re:Invent 2017 ダイジェスト

https://pages.awscloud.com/reInventRecapSeminarTokyo20171219-jp.html

お時間あれば是⾮ご参加ください J

Page 46: Scalable and Cost Effective Systems Architecture on AWS