[awsマイスターシリーズ]amazon simple storage service (s3)
TRANSCRIPT
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
AWSマイスターシリーズ
Amazon Simple Storage Service (Amazon S3)
2013.03.27
アマゾンデータサービスジャパン株式会社
ソリューションアーキテクト 北迫 清訓
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
2
今日のAgenda
Amazonがもつストレージサービス
Amazon S3とは?
Amazon S3の基本
Amazon S3の新機能
Amazon S3のTips
まとめ
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
3
AWSストレージサービスのゴール
お客様がデータを安心して預けられる、サービスの提供
• データが安全に保管されている
• データが取りたい時に常に取得可能
• データを保存したい時に常に保存可能
• データが誰がいつアクセス出来るかを完璧にコントロールできる
• データ保存が低価格で実現できる
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
4
AWSストレージサービス
S3
安価かつ高い耐久性を持つオンラインストレージサービス
Glacier
超安価かつ高い耐久性を持つコールドストレージサービス
StorageGateway
オンプレミス環境と連携したバックアップ&ストレージサービス
EBS
仮想サーバ(Amazon EC2)にマウントできる共有ディスクサービス
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
5
Amazon S3とは? Amazon S3はWeb時代のストレージ
ユーザはデータを安全にどこからでも保存可能
AWSの主力サービスの1つ。2006年から開始
開発者が“Webスケール”なコンピューティングを可能にするよう設計された • 高いスケーラビリティ
• 高い信頼性・堅牢性
• セキュア
• 高速
• 低価格
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
6
Amazon S3は、データ保存の基盤
東京リージョン
3か所以上で 自動複製
S3
バケット
高い耐久性で データ失わない:
99.999999999%
世界中の8拠点から選択
データセンターA
データ置くだけ。インフラ、電源、
気にしない。 容量無制限。
データセンターB
データセンターC
ファイル(バイナリ、 テキスト、画像、動画)
保存するデータは、自動で暗号化する
ことも可能
安価な従量課金
例:1GB/月 – 約10円
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
7
Amazon S3の用語
バケット • オブジェクト置場。最大100/アカウント。名前がユニークな必
要あり
オブジェクト • Amazon S3に置くファイルでURLによるアドレスが付与。バ
ケット内には無制限にオブジェクトを置くことが可能。1オブジェクトのサイズは5TBまで
キー • オブジェクト毎に付与される一意なキー
ACL
• アクセスコントロールリスト
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
8
Amazon S3のネームスペース
Amazon S3
バケット バケット
オブジェクト オブジェクト オブジェクト オブジェクト
バケット
オブジェクト オブジェクト
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
9
Amazon S3 –実例にあてはめてみる -
Amazon S3
mculver-images media.mydomain.com
Beach.jpg img1.jpg img2.jpg 2009/maui/sun.jpg
public.blueorigin.com
Installer.msi img/pic1.jpg
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
10
Amazon S3のコンセプト
Durable(堅牢であること)
Available (いつでも利用可能であること)
Scalable (スケールすること)
Secure (安全であること)
Fast (高速に動くこと)
Simple (シンプルに使えること)
Cost Effective (低コストであること)
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
11
Durable(堅牢であること)
データを失わない設計
• データを3箇所以上にレプリケーション
• 障害検知とデータ修復
99.999999999%の堅牢性
• 3つ以上同時にDCが消失しない限りデータを失わない
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
12
Available(常に利用可能なこと)
常に利用可能なように設計
• 99.9%可用性SLA、実際はほぼ100%
計画停止無し
全世界からどの地域でもインターネット経由で利用可能
• 異なる8つのリージョンから選択
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
13
Scalable(スケールすること)
論理的には無限にスケールする
どれだけのファイルでも保存可能
• 1バイトから、いくらでも保存可能
• 1つのファイルサイズは最大5TBまで
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
14
Secure(安全であること)
全ての通信はSSL暗号化
認証・認可機能を持つ
• ACLベース/ポリシーベース
• ユーザアクセスコントロール
暗号化機能を持つ
• サーバサイド/クライアントサイド暗号化
ログ機能
認定・認証の取得 • ISO27001/PCI-DSS/SOC1など
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
15
Fast(高速であること)
ピーク時最大85万リクエスト/秒
常に安定したレイテンシ
世界8か所にリージョン展開
• 最も近い場所を利用可能
専用線で直結も可能
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
16
Simple(シンプルに使えること)
ファイルのPUT/GET/DELETE/LIST
• これだけ。とってもシンプル
• データサイズも数も気にしなくてよい
サードパーティツールでFTPライクに利用
SDKで様々な言語からすぐに利用可能
PutObjectRequest putObjectRequest = new PutObjectRequest(bucketName, key, file); PutObjectResult result = this.client.putObject(putObjectRequest);
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
17
Cost Effective(低コストなこと)
従量課金で使った分だけお支払い
初期費用もいらない
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
18
Amazon S3の価格 ストレージ料金
データ転送料金
スタンダード 低冗長化※
最初の1TB/月 $0.100/GB $0.080/GB
次の49TB/月 $0.085/GB $0.068/GB
次の450TB/月 $0.075/GB $0.060/GB
次の500TB/月 $0.070/GB $0.056/GB
次の4PB/月 $0.065/GB $0.052/GB
次の5PB/月 $0.060/GB $0.044/GB
リクエストタイプ 価格
PUT,COPY,POST,LISTリクエスト
$0.01 1,000リクエストあたり
削除リクエスト Free
GETおよびその他リクエスト
$0.01 10,000リクエストあたり
転送方向 価格
IN 全てのデータ転送「IN」 $0.000/GB
OUT 最初の1GB/月 $0.000/GB
10TBまで/月 $0.201/GB
次の40TB/月 $0.158/GB
次の100TB/月 $0.137/GB
次の350TB/月 $0.127/GB
350TB/月以上 お問い合わせ
2013年1月時点の東京リージョン価格表
※低冗長化ストレージ(RRS) 2拠点への複製により堅牢性が99.99%
同一リージョン内でのデータ転送は無料
リクエスト料金
[価格例] データ格納 • 1TB 約9,500円/月
Webホスティング (20MB程度のWebサイトで月間10万PV)
• 約2,000円/月
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
19
Amazon S3の機能
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
20
Amazon S3の機能
マルチパートアップロード
Webサイト機能
バージョニング
サーバアクセスログ
S3セキュリティ機能
データの暗号化
オブジェクトの期限付き保存
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
21
Amazon S3マルチパートアップロード
巨大なオブジェクトを複数のチャンクに分割してアップロード
• 各チャンク < 5GB
• チャンクがアップロードされたら、 単一オブジェクトに結合
• 自動で結合する場合
• 自分で分割→結合
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
22
Amazon S3 Webサイト機能
静的なWebサイトのホスティングをS3で!
• ファイルをアップロードして、Website機能をON!
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
23
Amazon S3バージョニング 全てのオブジェクトのバージョン管理下におき保存、検索、リストアが可能。バージョニング中はオブジェクトは削除されない。
Amazon S3でよくみる光景はユーザアクションによるデータ消失。こういった事態から重要なデータを保護する。ただし課金はバージョニング分かかる
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
24
Amazon S3サーバアクセスロギング
Amazon S3バケットへアクセスログを保存
• デフォルトでは出力しない
API/SDKで設定可能
アクセスログのデリバリではチャージしていない
• ログの保存ではチャージ。ただしいつでも削除可能
• アクセスログへのアクセスについては若干のチャージ
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
25
Amazon S3の認証機構
Amazon S3を含む全AWSサービスでセキュリティは最優先事項
認証のないアクセスからはデータは確実に保護
オブジェクトは全てフルコントロール可能
特定ユーザに対して権限を与えることも勿論可能
How?
• AWS Identity and Access Management(IAM) ポリシー
• バケットポリシー
• ACL
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
26
AWS Identity and Access Management (IAM)
アカウント内で複数ユーザを作成し、セキュリティクレデンシャルや権限を付与する事が可能
• S3のバケットにオブジェクトのPUT/LIST/GETなど
IAMで出来る事:
• ユーザレベルでのコントロール
• S3に対してのお客様要件にあわせた操作の制御
アクセスポリシー言語を記述する
• JSON format
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
27
Amazon S3バケットポリシー
Amazon S3バケットレベルのポリシーベースのコントロール
バケットオーナーだけが適用可能
• バケットレベルでのAllow/Deny
• バケット内のオブジェクトの権限のDeny
• バケットオーナーがオブジェクトオーナーだった場合のみオブジェクトに適切な権限を与える
アクセスポリシー言語を記述する
• JSON format
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
28
バケットポリシーの一例
例:
• ユーザ(1-22-333-4444, 3-55-678-9100)に“mybucket” (arn:aws:s3:::mybucket/*“,)というバケットに対してGETリクエストの発行を許可
{ "Version":"2008-10-17",
"Id":"aaaa-bbbb-cccc-dddd",
"Statement" : [
{ "Effect":"Allow",
"Sid":"1",
"Principal" : {
"AWS":["1-22-333-4444","3-55-678-9100"]
},
"Action":["s3:GetObject*"],
"Resource":"arn:aws:s3:::mybucket/*",
}
]
}
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
29
Amazon S3 Access Control List
バケットからオブジェクトへのコントロール
バケットのACLをオブジェクトは継承しない
作成と適用はいつでも可能
100個ACLは作成可能: • Owner
• Any AWS account
• Anyone
パーミッション: • READ – Object or bucket
• WRITE – Create, overwrite, delete objects in bucket
• READ_ACP – Read ACL for bucket or object
• WRITE_ACP – Overwrite ACL for bucket or object
• FULL_CONTROL – All of the above
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
30
データの暗号化
サーバサイド暗号化
クライアントサイド暗号化
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
31
サーバサイド暗号化
AmazonS3Client client = new AmazonS3Client(credentials); client.setEndpoint("s3-ap-northeast-1.amazonaws.com"); PutObjectRequest putRequest = new PutObjectRequest( "shot6jp", “S3に置くファイル名", new File(“実際のファイル")); ObjectMetadata objectMetadata = new ObjectMetadata(); objectMetadata.setServerSideEncryption( ObjectMetadata.AES_256_SERVER_SIDE_ENCRYPTION); putRequest.setMetadata(objectMetadata); PutObjectResult result = client.putObject(putRequest);
• マネージメントコンソールから実施する • GUIツールで実施する • コードで実施する
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
32
クライアントサイド暗号化
KeyPairGenerator generator = KeyPairGenerator.getInstance("RSA"); generator.initialize(512); KeyPair keyPair = generator.generateKeyPair(); EncryptionMaterials encryptionMaterials = new EncryptionMaterials(keyPair); AmazonS3EncryptionClient client = new AmazonS3EncryptionClient(credentials, encryptionMaterials); client.setEndpoint("s3-ap-northeast-1.amazonaws.com"); PutObjectResult ret = client.putObject( “バケット名”, “S3上のファイル名”, new File(“現状ファイル"));
• GUIツールで実施する • コードで実施する
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
33
オブジェクトの期限付き保存
バケット単位でオブジェクトの生存期間を指定可能
• Prefix単位
• 期間・日付で指定可能
http://bit.ly/A9dE0b
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
34
Amazon S3の新機能
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
35
CORSサポート
CORS(Cross Origin Resource Support)
• クロスドメインでリソース取得が可能
• より簡単にリソースの共有が可能に
WebサイトAバケット データバケット
WebサイトAがオリジンなら
データをGETさせますよ
ブラウザ
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
36
Webページリダイレクト
Amazon S3でWebページのリダイレクトが可能になりました
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
37
Webページリダイレクト
リダイレクトルールを渡して、条件を満たす場合のみリダイレクト • キーのプレフィックスを一部変更
• 削除したディレクトリから別ページへ
• HTTPエラーコードで
<RoutingRules> <RoutingRule> <Condition> <KeyPrefixEquals>images/</KeyPrefixEquals> </Condition> <Redirect> <ReplaceKeyWith>index.html</ReplaceKeyWith> </Redirect> </RoutingRule> </RoutingRules>
imagesにマッチしたら、 index.htmlにリダイレクト
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
38
S3-Glacier連携機能
S3に格納されたファイルを自動的にGlacierに退避
AWSで安価な階層化ストレージを実現
• ルールベースで一定期間が経過したS3上のファイルを自動的にGlacierに退避
• インデックス情報はS3で管理
• 簡単な画面操作でGlacierに退避されたファイルをS3上に取出し可能 (3-5時間)
• Glacierに退避されると格納コストが1/10に
Upload 自動 Archive
メタデータ
Bucket (ルール設定)
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
39
ルートドメイン設定
S3のWebサイトでもWWW等のホスト名なしルートドメインが利用可能に
• S3+Route53で利用可能
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
40
S3を上手に使うには?
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
Amazon S3のパフォーマンスをあげるコツ
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
42
Amazon S3をうまく使うコツ (パフォーマンス)
大前提:ほとんどのケースでは普通に使ってもらえばいいだけ。
大量にオブジェクトを保存したり、取得したりする場合のみコツが必要
• キー名はとても大事。キー名の先頭を散らす
• 先頭2、3をハッシュ値にするだけで十分スケールする
• Amazon S3のパーティション分割
• 当然バケットが違えば更にスケール
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
43
Amazon S3をうまく使うコツ
秒間数百以上のPUTをする場合には、エラーコードに注意
• 503が返ってきたらクライアント側でも送信側でも少し軽減する(エクスポネンシャルバックオフ)
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
44
Amazon S3のよくある利用例
コンテンツの保存と配信 • メディア・エンターテイメントのコンテンツ
• ソフトウェアの配信
大規模データ分析のストレージ・データオリジナル
• オンラインストレージ
• アプリケーションそのもののストレージ
バックアップやディザスタリカバリ。低価格かつ安心のテープの代替
• サーバのバックアップ
• 個人的なバックアップ
• 複数端末での共有
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
45
AWSの各サービス自体もユーザ
AWSサービスの中心にS3がある
S3
EC2 EBS
EMR Dynamo DB
… …
… …
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
46
Amazon S3のサードパーティツール例
様々なサードパーティツールが存在する
• CloudBerry
• TNT Drive
• s3cmd
• s3fs
用法を守って正しくお使いください
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
47
Amazon S3を通じて実現したいこと
お客様がデータを安心して預けられる、サービスの提供
• Amazon S3上のデータは常に安全に保管
• Amazon S3内データはいつでも取得可能
• Amazon S3内データを常に保存可能
• Amazon S3内へのデータアクセスは完璧にコントロールできる
• データ保存が低価格で実現できる
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
48
参考文献
Amazon S3
• http://aws.amazon.com/jp/s3/
Amazon S3 Getting Started Guide
• http://docs.amazonwebservices.com/AmazonS3/latest/gsg/
Amazon S3 Developer Guide
• http://docs.amazonwebservices.com/AmazonS3/latest/dev/
Amazon Web Services Japan blog
• http://aws.typepad.com/aws_japan/
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
49