SlideShare a Scribd company logo
1 of 69
Download to read offline
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights
reserved.
アマゾン ウェブ サービス ジャパン株式会社
ソリューション アーキテクト
桑野 章弘
2017.12.14
【AWS Black Belt Online Seminar】
Amazon ElastiCache
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights
reserved.
自己紹介
桑野 章弘(くわの あきひろ)
ソリューションアーキテクト
主にメディア系のお客様を担当しております。
元渋谷のインフラエンジニア
好きなAWSのサービス:ElastiCache, Route53
好きなデータストア:MongoDB
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights
reserved.
内容についての注意点
• 本資料では2017年12月14日時点のサービス内容および価格についてご説明しています。最
新の情報はAWS公式ウェブサイト(http://aws.amazon.com)にてご確認ください。
• 資料作成には十分注意しておりますが、資料内の価格とAWS公式ウェブサイト記載の価格に相違が
あった場合、AWS公式ウェブサイトの価格を優先とさせていただきます。
• 価格は税抜表記となっています。日本居住者のお客様が東京リージョンを使用する場合、別途消費
税をご請求させていただきます。
• AWS does not offer binding price quotes. AWS pricing is publicly available and is subject to change
in accordance with the AWS Customer Agreement available at http://aws.amazon.com/agreement/.
Any pricing information included in this document is provided only as an estimate of usage charges
for AWS services based on certain information that you have provided. Monthly charges will be
based on your actual use of AWS services, and may vary from the estimates provided.
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights
reserved.
Agenda
• Introduction
• Amazon ElastiCache 概要
• Amazon ElastiCache アップデート
• 代表的なユースケース
• Amazon ElastiCache の料金
• まとめ
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights
reserved.
Introduction
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights
reserved.
Introduction
Amazon ElastiCache はAWS クラウドでの分散インメモ
リキャッシュ環境のセットアップ、管理、およびスケーリ
ング、冗長構成等を容易に構築することができるサービス
です
ElastiCacheの詳しい使用方法について、そして
ElastiCacheを使用した際の運用面のtipsを交えてご紹介し
ます
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights
reserved.
Amazon ElastiCache 概要
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights
reserved.
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights
reserved.
AWSが提供するデータベースサービス
完全マネージド型で、セットアップ、運用、拡張が
容易なリレーショナル・データベースサービス
Amazon RDS
Amazon DynamoDB
完全マネージド型で、高速なパフォーマンス、
シームレスな拡張性と信頼性のNoSQLサービス
Amazon Redshift
高速で管理も万全なペタバイト規模のデータウェア
ハウスサービス
Amazon ElastiCache
完全マネージド型で、セットアップ、運用、拡張が容
易なキャッシュサービス
Amazon Neptune
完全マネージド型で、高いパフォーマンス、シームレ
スな拡張性、信頼性のグラフDBサービス(Preview)
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights
reserved.
Amazon ElastiCacheとは
• フルマネージド
• キャッシュクラスタを数クリックで起動
• 可用性を向上させる機能(モニタリング、自動
障害検出、復旧、拡張、パッチ適用、バック
アップ)
• パフォーマンス
• 超高速な2種類のエンジン(memcached,
redis)をサポート
• AmazonによるRedisの機能拡張
• 高可用性と堅牢性
• セキュリティグループ、VPC対応、暗号化
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights
reserved.
他にもこんな機能
Lua スクリプト 位置情報クエリ Pub/sub
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights
reserved.
Cacheインスタンスクラスとスペック
DB Instance Class vCPU メモリ(GiB) ネットワーク
cache.t2.micro 1 0.555 低
cache.t2.small 1 1.55 低
cache.t2.medium 2 3.22 低
cache.t2.large 2 6.05 中
cache.m4.large 2 6.42 中
cache.m4.xlarge 4 14.28 高
cache.m4.2xlarge 8 29.70 高
cache.m4.4xlarge 16 60.78 高
cache.m4.10xlarge 40 154.64 10Gbps
cache.r4.large 2 12.3 最大10Gbps
cache.r4.xlarge 4 25.05 最大10Gbps
cache.r4.2xlarge 8 50.47 最大10Gbps
cache.r4.4xlarge 16 101.38 最大10Gbps
cache.r4.8xlarge 32 203.26 10Gbps
cache.r4.16xlarge 64 407 25Gbps
※表には記載していない旧世代インスタンス(cache.m3、r3)も選択可能です
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights
reserved.
Request rate
High Low
Latency
Low High
Structure
Low
High
Data volume
Low High
Amazon
RDS
Amazon S3
Amazon
Glacier
Amazon
CloudSearch and
Amazon Elasticsearch
Service
Amazon
DynamoDB
Amazon
ElastiCache
and Amazon
DynamoDB
Accelerator
(DAX)
HDFS
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights
reserved.
Amazon ElastiCache for memcached
• 特徴
• 対応バージョン 1.4.5、1.4.14、1.4.24 、1.4.33 、1.4.34
(2017.12.14現在)
• Cache Clusterという論理グループに、Cache Nodeを起動
• Cluster Group 全体のConfigration Endpointと、Cache Node単
体を表すNode Endpointの2種類のエンドポイント
• バックアップ機能(Snapshot)は持たない
• スケールアウトさせる場合はコンシステントハッシュなどを使用す
る必要がある
CacheCluster A
Configration
Endpoint
Node
Endpoint
Node
Endpoint
App
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights
reserved.
Memcached アクセス用のClient Libraryの提供
• Auto Discovery 用に対応した専用のライブラリをAWSから提供
Auto Discovery用Client Library通常アクセス用Client Library
• consistent hashingを提供
• Auto Discovery (60s毎) をノードの追加
/削除時に提供
• AWS Management Consoleから取得可
• PHP, Java, .NETに対応
Language Library
Ruby Dalli, Dalli:ElastiCache
Python Memcache Ring, django-elasticache
Node.js node-memcached
Language Library
C#/.NET ElastiCache Auto Discovery Client
PHP ElastiCache Auto Discovery Client
Java ElastiCache Auto Discovery Client
(based on spymemcached)
• Memcached ノードの追加、削除のAuto
Discoveryには未対応
• PHP、Java、.NET、C、C++、Ruby、
Python、Perl、多数の言語用のライブラ
リが存在
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights
reserved.
Auto Discovery for memcached
• DNS エイリアスとして提供され稼働しているノードリストを表示する
• 従来のクライアントの設定
• Cache Clusterの全エンドポイントを接続先として設定
• Auto Discoveryクライアント(Java, PHP, .NET)
• Cache ClusterのConfiguration EndpointはCache Clusterの ロードバランサ
(Proxy) ではなく、接続先として設定すると全ノードを自動取得・設定し、接
続する CacheCluster
Configuration Endpoint
xxx.cfg.apne1.cache.amazonaws.com
xxx.0001.apne1.cache.amazonaws.com
xxx.0002.apne1.cache.amazonaws.com
App
通常のクライアントライブラリ
App
Auto Discovery クライアントライブラリ
http://docs.aws.amazon.com/AmazonElastiCache/latest/UserGuide/AutoDiscovery.html
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights
reserved.
ElastiCache for Redis
• 特徴
• 対応バージョン: 2.8.21, 2.8.22, 2.8.23, 2.8.24, 3.2.4, 3.2.6,
3.2.10 (2017.12.14現在)
• 複数のCluster Group で構成されるReplication Group を構成
• 書き込み先を示すPrimary EndpointとCache Node単体を示す
Node Endpointの2種類のアクセス用のエンドポイント
• Multi-AZ構成の自動フェイルオーバーにも対応
• Snapshotベースでのバックアップ/リストアに対応
• Redis Clusterを使うためのcluster-mode(バージョン3.2以降)
• クライアント認証、暗号化に対応
• 対応しない機能
• CONFIG, SLAVEOFなど一部コマンドは無効化
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights
reserved.
Amazon による Redis 拡張
• ElasitiCache for Redis 2.8.22 以上
• 改善点:
Swap Memoryの最適化
同期やスナップショット中にスワップの使
用量が増加するリスクを軽減する
書き込みの動的な制限
ノードのメモリが使い尽くされてい
るときの出力バッファ管理の改善
高速なフェイルオーバ
レプリカがプライマリとの完全な再同期を
行うためにデータをフラッシュするのを避
けるため、クラスタはより速く回復します
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights
reserved.
Amazon による Redis 拡張
• OSSのRedis側へのコントリビュートも
• PSYNC2 (Redis 4.0)
• https://raw.githubusercontent.com/antirez/redis/4.0/00-RELEASENOTES
• BGSAVE (Redis 3.2)
• https://raw.githubusercontent.com/antirez/redis/3.2/00-RELEASENOTES
• MIGRATE (Redis 3.0)
• https://raw.githubusercontent.com/antirez/redis/3.0/00-RELEASENOTES
• MASTER TIMEOUT (Redis 2.8)
• https://raw.githubusercontent.com/antirez/redis/2.8/00-RELEASENOTES
• INCREASE 2Billion+ KEYS in a DATASET (Redis 2.8)
• https://raw.githubusercontent.com/antirez/redis/2.8/00-RELEASENOTES
• https://github.com/antirez/redis/issues/1814, 4114, 4250, 3926, 3899
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights
reserved.
Redis アクセス用のClient Library
• RedisにアクセスするためのライブラリはAWSから提
供していない
• 各言語用のライブラリを選択して使用する
• 各言語の主要なライブラリ
Language Library
Ruby Redis-rb, Redis objects
Python Redis-py
Node.js node-redis
C#/.NET ServiceStack.Redis
PHP phpredis
Java Jedis
Go go-redis, redigo
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights
reserved.
リードレプリカ (Replication)
• このような用途に利用可能
• 耐障害性向上(ただし、非同期レプリケーション)
• Read性能のスケールアウト
• 構成
• Replication Group内に、マスター1台、レプリカ 最大5台
• Replica の Replica は未対応
http://docs.aws.amazon.com/AmazonElastiCache/latest/UserGuide/Replication.html
http://docs.aws.amazon.com/AmazonElastiCache/latest/UserGuide/ManagingReplication.html
Availability Zone - a Availability Zone - b
CacheCluster CacheCluster CacheCluster
Replication Group
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights
reserved.
Replication構成例
• リードレプリカを複数のアベイラビリティゾーンに配置可能
• 同一AZのリードレプリカを参照し高速なデータ取得が可能
• AZ障害時のデータ保全が可能
Availability Zone - a Availability Zone - b
非同期レプリケーション
SET
GET
SET
GET
App App
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights
reserved.
フェイルオーバ
• ノード障害時は自動フェイルオーバがかかる
• ClusterModeDisable時にはPrimary EndpointのDNSのが
新しいマスターに切り替わり、壊れたサーバは可能であれば
再構成される
Availability Zone - a Availability Zone - b
非同期レプリケーション
SET
GET SET
GET
App App
Availability Zone - a Availability Zone - b
非同期レプリケーション
SET
GET
SET
GET
App App
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights
reserved.
バックアップ/リストア
• ElastiCache Redis はSnapshotを取得しS3へのバック
アップリストアが可能(自動/手動)
• SnapshotからRedisのRDBファイルを生成し、S3に
Exportする事も可能
• Cache Cluster作成時にSnapshotや、RDBファイルを
指定することも可能
S3
Snapshot Backup restore
S3
Export RDB file
Redis
EC2
Redis
restore
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights
reserved.
監視のエコシステム
• AWSに用意された各種サービスで監視の効率化/自動化
AWS
Config
Amazon
CloudWatch
AWS
CloudTrail
AWS
CloudFormation
AWS Management
Console
AWS CLI
and SDKs
alarm
Amazon
SNS
Email
Notification
AWS
Lambda
Amazon
ElastiCache
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights
reserved.
CloudWatchによるElastiCacheの監視
• 主に監視する項目
• CPUUtilization (CPU使用率)
• Memcachedの場合はマルチコアが使えるので 90% 超えでもOK
• Redisはシングルコアなのでcache.m4.xlarge(4コア)だと25% (100% / 4) が
最大値
• CacheHits/CacheMisses
• Evictions
• キャッシュメモリ不足起因のキャッシュアウト発生回数
• SwapUsage
• 低いほどいい
• メモリ使用量
• BytesUsedForCacheItems(Memcached)
• BytesUsedForCache(Redis)
• Replica Lag
• レプリケーション遅延(Redis)
http://docs.aws.amazon.com/AmazonElastiCache/latest/UserGuide/CacheMetrics.Memcached.html
http://docs.aws.amazon.com/AmazonElastiCache/latest/UserGuide/CacheMetrics.WhichShouldIMonitor.html
http://docs.aws.amazon.com/AmazonElastiCache/latest/UserGuide/CacheMetrics.html
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights
reserved.
Amazon ElastiCache
アップデート
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights
reserved.
Redis Cluster
• Redis 3.2 で Redis Cluster のサポート
• データをシャード単位に分散保存することで最大15
シャード、6TiBのデータが保存可能
• 最大2000万/秒の読み込み、450万/秒の書き込み性能
Shard A
Shard B
Shard C
各シャードに分散
してデータを保存App
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights
reserved.
Redis Cluster
• 16384 ハッシュスロット/クラスタ
• スロットはクラスタ全体のシャード分散に使われる
• Redisクラスタ対応のクライアントを使用する必要あり
• クライアントは正しいシャードにリダイレクトされる
• クライアントがマッピングを保持する
Shard A
Shard B
Shard C
各シャードに分散
してデータを保存App
Shard A = slots 0–3276
Shard B = slots 3277–9829
Shard C = slots 9830–16383
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights
reserved.
Availability Zone A
slots 0–5454 slots 5455–10909
Redis Cluster
Redis cluster—アーキテクチャ
slots 10910–16363
Availability Zone B Availability Zone C
slots 5455–10909
slots 5455–10909slots 0–5454 slots 0–5454
slots 10910–16363
slots 10910–16363
Redis cluster—multi-AZ構成
1〜15シャード
Example: 3-shard cluster,
2 read replicas
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights
reserved.
Availability Zone A
slots 0–5454
Redis Cluster
Redis cluster—アーキテクチャ
slots 10910–16363
Availability Zone B Availability Zone C
slots 5455–10909
slots 5455–10909slots 0–5454 slots 0–5454
slots 10910–16363
Shard
ReplicaReplicaPrimary
各シャード毎にプライマリノー
ドと最大5つのレプリカノードを
持つ
slots 5455–10909
slots 10910–16363
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights
reserved.
Availability Zone A
slots 0–5454 slots 5455–10909
Redis Cluster
Redis cluster—アーキテクチャ
slots 10910–16363
Availability Zone B Availability Zone C
slots 5455–10909
slots 5455–10909
Shard
ReplicaReplica Primary
各シャード毎にプライマリノー
ドと最大5つのレプリカノードを
持つ
slots 0–5454 slots 0–5454
slots 10910–16363
slots 10910–16363
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights
reserved.
Availability Zone A
slots 0–5454
Redis Cluster
Redis cluster—アーキテクチャ
slots 10910–16363
Availability Zone B Availability Zone C
slots 10910–16363
slots 10910–16363
Shard
Replica PrimaryReplica
各シャード毎にプライマリノー
ドと最大5つのレプリカノードを
持つ
slots 5455–10909 slots 0–5454
slots 5455–10909
slots 0–5454 slots 5455–10909
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights
reserved.
Availability Zone A
slots 0–5454 slots 5455–10909
Redis Cluster
slots 10910–16363
Availability Zone B Availability Zone C
slots 5455–10909 slots 5455–10909slots 0–5454 slots 0–5454
slots 10910–16363 slots 10910–16363
プライマリノードの単体障害
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights
reserved.
Availability Zone A
slots 0–5454 slots 5455–10909
Redis Cluster
プライマリノードの単体障害
slots 10910–16363
Availability Zone B Availability Zone C
slots 5455–10909 slots 5455–10909slots 0–5454 slots 0–5454
slots 10910–16363
障害緩和:
1. 自動障害検知とレプリカのマスター昇格 (~15–30 秒)
2. 障害ノードの復旧
slots 10910–16363
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights
reserved.
Availability Zone A
slots 0–5454 slots 5455–10909
Redis Cluster
プライマリの複数障害
slots 10910–16363
Availability Zone B Availability Zone C
slots 5455–10909 slots 5455–10909slots 0–5454 slots 0–5454
slots 10910–16363slots 10910–16363
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights
reserved.
Availability Zone A
slots 0–5454 slots 5455–10909
Redis Cluster
slots 10910–16363
Availability Zone B Availability Zone C
slots 5455–10909 slots 5455–10909slots 0–5454 slots 0–5454
ElastiCache の Redis拡張
• 障害自動検知とレプリカ昇格
• 障害が起きたノードを再構築する
slots 10910–16363slots 10910–16363
プライマリの複数障害
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights
reserved.
Feature Enabled Disabled
Failover 15–30 sec
(Non-DNS)
~1.5 min
(DNSベース)
Failover risk • Writes 影響は部分的
• Reads は問題なし
• Writes 全体に影響あり
• Reads は問題なし
Performance クラスタサイズに依存
(90 ノード—15ノードのプライマリ + 0–5
ノードのシャード毎のレプリカ)
6 ノード
(1 ノードのプライマリ+ 0–5 ノード
のレプリカ)
Max connections • プライマリ(65,000 x 15 = 975,000)
• レプリカ(65,000 x 75 = 4,875,000)
• プライマリ: 65,000
• レプリカ: (65,000 x 5 =
325,000)
Storage 6+ TiB 407 GB
Cost
Example: 必要なアクセ
ス 175 GB
小さいノードで並べられるがお金はDisableよ
りかかる $$
9 x cache.r3.xlarge ($0.455hr) = $4.095
hr 255.6 GB
大きなノードであればあるほどコスト
がかかる $
1 X cache.r3.8xlarge = $3.640,
237 GB
Redis cluster-mode 有効と無効の場合のまとめ
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights
reserved.
バックアップからのRedis Cluster リサイズ
• 従来の方法
• Redis Clusterのバックアップをリストアする際に
シャード数を指定してリストアすることでRedis
Clusterをリサイズする
• ダウンタイムが発生する(アプリ側で新クラスタに向け
直す)
S3
Snapshot Backup restore
S3
Export RDB file
3 Shards 5 Shards
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights
reserved.
0-5461
Shard 1 Shard 2 Shard 3
5462--10922 10923-16383
aws elasticache modify-replication-group-shard-configuration --replication-group-id r
group-id
--apply-immediately --node-group-count 5
Simple API
ダウンタイム0の Scale In || Out
Redis Cluster オンラインリサイズ
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights
reserved.
0-5461
reads/writes
Shard 1 Shard 2 Shard 3
Shard 4 Shard 5
5462--10922 10923-163830-2909,
5095-5461
5462-5783,
6876-9830
10923-14199
2910-5094,
9831--10922
No application
interruption
Uniform slot distribution across shards
5784-6875,
14200-16383
Redis Cluster オンラインリサイズ: スケールアウト
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights
reserved.
0-5461
reads/writes
Shard 1 Shard 2 Shard 3
Shard 4 Shard 5
5462--10922 10923-16383
Uniform slot distribution across shards
No Application
Interruption
Redis Cluster オンラインリサイズ: スケールイン
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights
reserved.
AWS Lambda
3 Shards
…
var params = {
ApplyImmediately: true,
NodeGroupCount: 5,
ReplicationGroupId: ‘rep-group-id’,
… }
elasticache.modifyReplicationGroupShardConfiguration(params, function(err,
data) {
if (err) console.log(err, err.stack);
else console.log(data);
}); …
5 Shards
メモリ!
大変!
Amazon
CloudWatch
Cluster Resized
AWS SNS
Redis Cluster オンラインリサイズ: CWのアラームトリガー
シャード数の
オートスケー
ルが可能に
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights
reserved.
セキュリティ強化
• 暗号化
• In-Transit: クライアントとRedis間の通
信の暗号化を行う
• At-Rest: S3とディスク上のバックアップ
を暗号化する
• 認証(コンプライアンス)
• ElastiCache for Redis は HIPAA 認証
• AWS Business Associate
Addendum(BAA)に対応
• Redis 3.2.6にて
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights
reserved.
セキュリティオーバービュー
Availability Zone BAvailability Zone A
Private SubnetPrivate Subnet
security group security group
ElastiCache Redis Cluster
security
group
Public Subnet
security
group
Public Subnet
Amazon S3
bucket
REDIS RDB
snapshot
Encryption In-Transit 3.2.6 Redis AUTH
Encryption
at REST
セキュリティ
グループによ
るNWフィルタ
バックアップ
の暗号化
Appと
ElastiCache
Redis間のやり
とりの暗号化
クライアント
認証の対応
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights
reserved.
代表的なユースケース
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights
reserved.
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights
reserved.
セッション管理 DBキャッシュ APIs
(HTTP レスポンス)
IOT
ストリームデータ
分析
(Filtering/aggregation)
Pub/sub
ソーシャル
メディア
(Sentiment analysis)
単体のDB
(Metadata store)
リーダーボード
ユースケースパターン
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights
reserved.
様々なキャッシング
クライアント
Amazon
ElastiCache
Redis
Amazon
DynamoDB
Elastic Load
Balancing
Amazon
EC2
Amazon
RDS
write-through
reads/
writes
DDB streams
mysql.lambda_async
reads/
writes
Amazon
S3
reads/writes
オブジェクトストレージ
非定型データ
リレーショナルデータ
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights
reserved.
NoSQL データベースのキャッシング
Amazon
EC2 reads/
writes
reads
MongoDB
Cluster
Cassandra
Cluster
 小さいNoSQLのインスタンス = 低コスト
 より早いデータ検索 = より良いperformance
Elasticsearch
Cluster
Clients
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights
reserved.
Amazon
EC2
reads/
writes
Amazon
ElastiCache
Redis
reads
MongoDB
Cluster
DBObject doc = collection.findOne();
Cache serialized DBObject in Redis (good)
Cache rows in Redis hash (faster/more efficient)
Cassandra
Cluster
Amazon
ElastiCache
Redis
Amazon
EC2
reads/
writes
reads
ResultSet rs = session.execute(stmt);
Cache serialized ResultSet in Redis (good)
Cache rows in Redis hash (faster/more efficient)
 小さいNoSQLのインスタンス = 低コスト
 より早いデータ検索 = より良いperformance
NoSQL データベースのキャッシング
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights
reserved.
Amazon
Kinesis
Data
Analytics
Amazon
Kinesis
Streams
Amazon
Kinesis
Data
Streams
Amazon
ElastiCache
(Redis)
整形データ
ストリーム
ストリームデータ処理
Datasources
生データ
ストリーム
Subscribers
AWS Lambda function 1
Continual data
フィルタリング/整形
Real-time
pub/sub
AWS Lambda function 2
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights
reserved.
Amazon Kinesis
DataSources
AWS Lambda
Apache Storm
on EMR
Spark
Streaming on
Amazon EMR
Amazon
Kinesis app
Amazon
EC2
AWS IoT
Amazon
ElastiCache
収集
ストア
処理
Amazon
S3
Apache Kafka
AWS
Lambda
Custom
app
Spark on
Amazon
EMR
分析
Redisを使ったビッグデータアーキテクチャ
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights
reserved.
Rules Engine
Amazon
ElastiCache
Redis
AWS
Lambda
標準対応
LambdaSNS SQS
S3 KinesisDDB
AWS
IoT devices
AWS
IoT
センサストア
IoT ソリューション
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights
reserved.
モバイルアプリケーション
Amazon API
Gateway
AWS
Lambda
Amazon
ElastiCache
Redis
GEOADD
GEORADIUS
Search points of interest
Update points of interest
https://aws.amazon.com/blogs/database/amazon-elasticache-utilizing-redis-geospatial-capabilities/
Amazon
DynamoDB
DDB streams
Amazon
EC2
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights
reserved.
アドテクノロジーアプリケーション
Clients
Advertisers
https://aws.amazon.com/caching/database-caching/
Ad network
Ad slot
Consumer
Ad slot
publishers
Ad placement
(websites/apps)
Amazon
ElastiCache
Redis
<40 ms
Clickstream
(shopping
events)
ユーザが
ページ閲覧
パブリッシャが
オークション用の
パブリック広告ス
ペースを用意
アドネット
ワークが入札
開始
入札のレスポン
スを入札者に
レスポンス
入札した勝者の
広告表示
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights
reserved.
チャットアプリケーション
https://aws.amazon.com/blogs/database/amazon-elasticache-utilizing-redis-geospatial-capabilities/
Clients
Chat apps
Application
Load Balancer
WebSockets
Amazon
ElastiCache
Redis
PubSub
Serverpersistent
connections
Elastic
Beanstalk
SUBSCRIBE chat_channel:114
PUBLISH chat_channel:114 "Hello all"
>> ["message", "chat_channel:114",
"Hello all"]
UNSUBSCRIBE chat_channel:114
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights
reserved.
• 順位表みたいなものはゲームに限らず非常によ
く使われるものだが、特にゲームはリアルタイ
ム性の高い使い方をする
• Redis sorted sets を活用することで非常に簡
単に実現可能
ZADD "leaderboard" 1201 ”Takayama”
ZADD "leaderboard" 963 " Kuwano"
ZADD "leaderboard" 1092 ”Nishitani "
ZADD "leaderboard" 1383 ”Uehara”
ZREVRANGE "leaderboard" 0 -1
1) ”Kuwano"
2) ”Nishitani"
3) ”Takayama"
4) ”Uehara”
ZREVRANK "leaderboard" ”Takayama"
(integer) 3
リアルタイムリーダーボード
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights
reserved.
例: Redisのカウンタを活用した
APIリクエストの同時接続数の上
限設定
ELB
エクスターナル
facing用 API
参考URL: http://redis.io/commands/INCR
FUNCTION LIMIT_API_CALL(APIaccesskey)
limit = HGET(APIaccesskey, “limit”)
time = CURRENT_UNIX_TIME()
keyname = APIaccesskey + ":” + time
count = GET(keyname)
IF current != NULL && count > limit THEN
ERROR ”API request limit exceeded"
ELSE
MULTI
INCR(keyname)
EXPIRE(keyname,10)
EXEC
PERFORM_API_CALL()
END
Rate Limit
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights
reserved.
Amazon ElastiCache の料金
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights
reserved.
価格
オンデマンド キャッシュノード
• 初期費用無し、時間単位の従量課金モデル
リザーブド キャッシュノード
• 予約金を支払うことで時間当たり価格を割引(最大70%節減)
• アベイラビリティゾーンの指定が不要
バックアップストレージ(Redis)
• 各クラスタに対して1つのSnapshotは無料
• 2つ以上のSnapshotから毎月 0.085 USD/GBが課金
AZ間データ転送量
• ElastiCache間の通信は課金対象外
• EC2とElastiCache間でAZを超える場合 0.01 USD/GB が課金
http://aws.amazon.com/jp/elasticache/pricing/
http://aws.amazon.com/jp/elasticache/reserved-cache-nodes/
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights
reserved.
TCO比較
• 同スペックでのEC2とElastiCacheでのTCOの比較
• Multi-AZ構成時の通信費用削減
• 運用コスト
• バックアップ
• Multi-AZ Failover構成
• Clluster構成(Node Auto Discovery, Replication環境)
• バージョンアップ/スケールアップ
オンデマンド価格(月額換算) 重度リザーブド価格(月額換算)
インスタンスタイプ EC2 ElastiCache 差額 EC2 ElastiCache 差額
t2.small $ 29 $ 38 $ 9 $ 21 $ 28 $ 7
r3.large $ 146 $ 199 $ 53 $ 95 $ 130 $ 35
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights
reserved.
まとめ
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights
reserved.
まとめ
• 既存のアプリケーションの変更を最小限に、か
つMemcached、Redisを使用したキャッシュ
クラスタの構築、運用が可能
• バックアップ、フェイルオーバ、スペックアップ、
バージョンアップ等
• Amazonで拡張されたRedisの機能も利用可能
• バックアップ改善
• レプリケーション同期最適化
• Redis Cluster対応によりスケールするKVSと
しての機能の拡充
• 暗号化対応によりセキュリティ要件の高い案件
にも対応可能
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights
reserved.
参考資料
• Performance at Scale with Amazon ElastiCache
https://d0.awsstatic.com/whitepapers/performance-at-scale-with-amazon-elasticache.pdf
• Amazon ElastiCache Document
http://aws.amazon.com/jp/documentation/elasticache/
• Amazon ElastiCache FAQ
http://aws.amazon.com/jp/elasticache/faqs/
• Amazon ElastiCache Pricing
http://aws.amazon.com/jp/elasticache/pricing/
• Memcached
http://memcached.org/
• Redis
http://redis.io/
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights
reserved.
オンラインセミナー資料の配置場所
AWS クラウドサービス活用資料集
• http://aws.amazon.com/jp/aws-jp-introduction/
AWS Solutions Architect ブログ
• 最新の情報、セミナー中の Q&A 等が掲載されています
• http://aws.typepad.com/sajp/
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights
reserved.
公式 Twitter/Facebook
AWS の最新情報をお届けします
@awscloud_jp
検索
最新技術情報、イベント情報、お役立ち情報、
お得なキャンペーン情報などを日々更新しています!
もしくは
http://on.fb.me/1vR8yWm
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights
reserved.
AWS の導入、お問い合わせのご相談
AWS クラウド導入に関するご質問、お見積り、資料請求を
ご希望のお客様は以下のリンクよりお気軽にご相談ください
https://aws.amazon.com/jp/contact-us/aws-sales/
※「AWS 問い合わせ」で検索してください
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights
reserved.

More Related Content

What's hot

What's hot (20)

AWS Black Belt Online Seminar 2017 AWS Storage Gateway
AWS Black Belt Online Seminar 2017 AWS Storage GatewayAWS Black Belt Online Seminar 2017 AWS Storage Gateway
AWS Black Belt Online Seminar 2017 AWS Storage Gateway
 
20190402 AWS Black Belt Online Seminar Let's Dive Deep into AWS Lambda Part1 ...
20190402 AWS Black Belt Online Seminar Let's Dive Deep into AWS Lambda Part1 ...20190402 AWS Black Belt Online Seminar Let's Dive Deep into AWS Lambda Part1 ...
20190402 AWS Black Belt Online Seminar Let's Dive Deep into AWS Lambda Part1 ...
 
20200617 AWS Black Belt Online Seminar Amazon Athena
20200617 AWS Black Belt Online Seminar Amazon Athena20200617 AWS Black Belt Online Seminar Amazon Athena
20200617 AWS Black Belt Online Seminar Amazon Athena
 
20190319 AWS Black Belt Online Seminar Amazon FSx for Lustre
20190319 AWS Black Belt Online Seminar Amazon FSx for Lustre20190319 AWS Black Belt Online Seminar Amazon FSx for Lustre
20190319 AWS Black Belt Online Seminar Amazon FSx for Lustre
 
20190129 AWS Black Belt Online Seminar AWS Identity and Access Management (AW...
20190129 AWS Black Belt Online Seminar AWS Identity and Access Management (AW...20190129 AWS Black Belt Online Seminar AWS Identity and Access Management (AW...
20190129 AWS Black Belt Online Seminar AWS Identity and Access Management (AW...
 
20200722 AWS Black Belt Online Seminar AWSアカウント シングルサインオンの設計と運用
20200722 AWS Black Belt Online Seminar AWSアカウント シングルサインオンの設計と運用20200722 AWS Black Belt Online Seminar AWSアカウント シングルサインオンの設計と運用
20200722 AWS Black Belt Online Seminar AWSアカウント シングルサインオンの設計と運用
 
20180704 AWS Black Belt Online Seminar Amazon Elastic File System (Amazon EFS...
20180704 AWS Black Belt Online Seminar Amazon Elastic File System (Amazon EFS...20180704 AWS Black Belt Online Seminar Amazon Elastic File System (Amazon EFS...
20180704 AWS Black Belt Online Seminar Amazon Elastic File System (Amazon EFS...
 
20190806 AWS Black Belt Online Seminar AWS Glue
20190806 AWS Black Belt Online Seminar AWS Glue20190806 AWS Black Belt Online Seminar AWS Glue
20190806 AWS Black Belt Online Seminar AWS Glue
 
20190130 AWS Black Belt Online Seminar AWS Identity and Access Management (AW...
20190130 AWS Black Belt Online Seminar AWS Identity and Access Management (AW...20190130 AWS Black Belt Online Seminar AWS Identity and Access Management (AW...
20190130 AWS Black Belt Online Seminar AWS Identity and Access Management (AW...
 
20180509 AWS Black Belt Online Seminar Amazon GuardDuty
20180509 AWS Black Belt Online Seminar Amazon GuardDuty20180509 AWS Black Belt Online Seminar Amazon GuardDuty
20180509 AWS Black Belt Online Seminar Amazon GuardDuty
 
20190731 Black Belt Online Seminar Amazon ECS Deep Dive
20190731 Black Belt Online Seminar Amazon ECS Deep Dive20190731 Black Belt Online Seminar Amazon ECS Deep Dive
20190731 Black Belt Online Seminar Amazon ECS Deep Dive
 
AWS Black Belt Online Seminar AWS Amplify
AWS Black Belt Online Seminar AWS AmplifyAWS Black Belt Online Seminar AWS Amplify
AWS Black Belt Online Seminar AWS Amplify
 
20190319 AWS Black Belt Online Seminar Amazon FSx for Windows Server
20190319 AWS Black Belt Online Seminar Amazon FSx for Windows Server20190319 AWS Black Belt Online Seminar Amazon FSx for Windows Server
20190319 AWS Black Belt Online Seminar Amazon FSx for Windows Server
 
20210316 AWS Black Belt Online Seminar AWS DataSync
20210316 AWS Black Belt Online Seminar AWS DataSync20210316 AWS Black Belt Online Seminar AWS DataSync
20210316 AWS Black Belt Online Seminar AWS DataSync
 
20190424 AWS Black Belt Online Seminar Amazon Aurora MySQL
20190424 AWS Black Belt Online Seminar Amazon Aurora MySQL20190424 AWS Black Belt Online Seminar Amazon Aurora MySQL
20190424 AWS Black Belt Online Seminar Amazon Aurora MySQL
 
20190220 AWS Black Belt Online Seminar Amazon S3 / Glacier
20190220 AWS Black Belt Online Seminar Amazon S3 / Glacier20190220 AWS Black Belt Online Seminar Amazon S3 / Glacier
20190220 AWS Black Belt Online Seminar Amazon S3 / Glacier
 
20180221 AWS Black Belt Online Seminar AWS Lambda@Edge
20180221 AWS Black Belt Online Seminar AWS Lambda@Edge20180221 AWS Black Belt Online Seminar AWS Lambda@Edge
20180221 AWS Black Belt Online Seminar AWS Lambda@Edge
 
20190723 AWS Black Belt Online Seminar AWS CloudHSM
20190723 AWS Black Belt Online Seminar AWS CloudHSM 20190723 AWS Black Belt Online Seminar AWS CloudHSM
20190723 AWS Black Belt Online Seminar AWS CloudHSM
 
20200212 AWS Black Belt Online Seminar AWS Systems Manager
20200212 AWS Black Belt Online Seminar AWS Systems Manager20200212 AWS Black Belt Online Seminar AWS Systems Manager
20200212 AWS Black Belt Online Seminar AWS Systems Manager
 
20200818 AWS Black Belt Online Seminar AWS Shield Advanced
20200818 AWS Black Belt Online Seminar AWS Shield Advanced20200818 AWS Black Belt Online Seminar AWS Shield Advanced
20200818 AWS Black Belt Online Seminar AWS Shield Advanced
 

Similar to AWS Black Belt Online Seminar 2017 Amazon ElastiCache

Similar to AWS Black Belt Online Seminar 2017 Amazon ElastiCache (20)

AWSのNoSQL入門
AWSのNoSQL入門AWSのNoSQL入門
AWSのNoSQL入門
 
20180508 AWS Black Belt Online Seminar AWS Greengrassで実現するエッジコンピューティング
20180508 AWS Black Belt Online Seminar AWS Greengrassで実現するエッジコンピューティング20180508 AWS Black Belt Online Seminar AWS Greengrassで実現するエッジコンピューティング
20180508 AWS Black Belt Online Seminar AWS Greengrassで実現するエッジコンピューティング
 
AWS Black Belt - AWS Glue
AWS Black Belt - AWS GlueAWS Black Belt - AWS Glue
AWS Black Belt - AWS Glue
 
[PGConf.ASIA 2018]Deep Dive on Amazon Aurora with PostgreSQL Compatibility
[PGConf.ASIA 2018]Deep Dive on Amazon Aurora with PostgreSQL Compatibility[PGConf.ASIA 2018]Deep Dive on Amazon Aurora with PostgreSQL Compatibility
[PGConf.ASIA 2018]Deep Dive on Amazon Aurora with PostgreSQL Compatibility
 
JAWS-UG HPC #17 - HPC on AWS @ 2019
JAWS-UG HPC #17 - HPC on AWS @ 2019JAWS-UG HPC #17 - HPC on AWS @ 2019
JAWS-UG HPC #17 - HPC on AWS @ 2019
 
20210127 AWS Black Belt Online Seminar Amazon Redshift 運用管理
20210127 AWS Black Belt Online Seminar Amazon Redshift 運用管理20210127 AWS Black Belt Online Seminar Amazon Redshift 運用管理
20210127 AWS Black Belt Online Seminar Amazon Redshift 運用管理
 
aws blackbelt amazon elasticsearch service
aws blackbelt amazon elasticsearch service aws blackbelt amazon elasticsearch service
aws blackbelt amazon elasticsearch service
 
AWS Black Belt Online Seminar AWSサービスを利用したアプリケーション開発を始めよう
AWS Black Belt Online Seminar AWSサービスを利用したアプリケーション開発を始めようAWS Black Belt Online Seminar AWSサービスを利用したアプリケーション開発を始めよう
AWS Black Belt Online Seminar AWSサービスを利用したアプリケーション開発を始めよう
 
20170809 AWS code series
20170809 AWS code series20170809 AWS code series
20170809 AWS code series
 
AWS BlackBelt Online Seminar 2017 Amazon CloudFront + AWS Lambda@Edge
AWS BlackBelt Online Seminar 2017 Amazon CloudFront + AWS Lambda@EdgeAWS BlackBelt Online Seminar 2017 Amazon CloudFront + AWS Lambda@Edge
AWS BlackBelt Online Seminar 2017 Amazon CloudFront + AWS Lambda@Edge
 
20190122 AWS Black Belt Online Seminar Amazon Redshift Update
20190122 AWS Black Belt Online Seminar Amazon Redshift Update20190122 AWS Black Belt Online Seminar Amazon Redshift Update
20190122 AWS Black Belt Online Seminar Amazon Redshift Update
 
【IVS CTO Night & Day】AWS re:Invent 2017 振り返り
【IVS CTO Night & Day】AWS re:Invent 2017 振り返り【IVS CTO Night & Day】AWS re:Invent 2017 振り返り
【IVS CTO Night & Day】AWS re:Invent 2017 振り返り
 
ATC301 AWS re:Invent 2017/11/27 - 1 Million Bids in 100ms - Using AWS to Powe...
ATC301 AWS re:Invent 2017/11/27 - 1 Million Bids in 100ms - Using AWS to Powe...ATC301 AWS re:Invent 2017/11/27 - 1 Million Bids in 100ms - Using AWS to Powe...
ATC301 AWS re:Invent 2017/11/27 - 1 Million Bids in 100ms - Using AWS to Powe...
 
Stream processing on AWS
Stream processing on AWSStream processing on AWS
Stream processing on AWS
 
AWS 主要なサービスアップデート 6/3-11/28
AWS 主要なサービスアップデート 6/3-11/28AWS 主要なサービスアップデート 6/3-11/28
AWS 主要なサービスアップデート 6/3-11/28
 
20180710 AWS Black Belt Online Seminar AWS入門者向け: AWSで実現するウェブサイトホスティング
20180710 AWS Black Belt Online Seminar AWS入門者向け: AWSで実現するウェブサイトホスティング20180710 AWS Black Belt Online Seminar AWS入門者向け: AWSで実現するウェブサイトホスティング
20180710 AWS Black Belt Online Seminar AWS入門者向け: AWSで実現するウェブサイトホスティング
 
Black Belt Online Seminar AWS Amazon RDS
Black Belt Online Seminar AWS Amazon RDSBlack Belt Online Seminar AWS Amazon RDS
Black Belt Online Seminar AWS Amazon RDS
 
AWS初心者向けWebinar RDBのAWSへの移行方法(Oracleを例に)
AWS初心者向けWebinar RDBのAWSへの移行方法(Oracleを例に)AWS初心者向けWebinar RDBのAWSへの移行方法(Oracleを例に)
AWS初心者向けWebinar RDBのAWSへの移行方法(Oracleを例に)
 
20180220 AWS Black Belt Online Seminar - Amazon Container Services
20180220 AWS Black Belt Online Seminar - Amazon Container Services20180220 AWS Black Belt Online Seminar - Amazon Container Services
20180220 AWS Black Belt Online Seminar - Amazon Container Services
 
Security Operations and Automation on AWS
Security Operations and Automation on AWSSecurity Operations and Automation on AWS
Security Operations and Automation on AWS
 

More from Amazon Web Services Japan

More from Amazon Web Services Japan (20)

202205 AWS Black Belt Online Seminar Amazon VPC IP Address Manager (IPAM)
202205 AWS Black Belt Online Seminar Amazon VPC IP Address Manager (IPAM)202205 AWS Black Belt Online Seminar Amazon VPC IP Address Manager (IPAM)
202205 AWS Black Belt Online Seminar Amazon VPC IP Address Manager (IPAM)
 
202205 AWS Black Belt Online Seminar Amazon FSx for OpenZFS
202205 AWS Black Belt Online Seminar Amazon FSx for OpenZFS202205 AWS Black Belt Online Seminar Amazon FSx for OpenZFS
202205 AWS Black Belt Online Seminar Amazon FSx for OpenZFS
 
202204 AWS Black Belt Online Seminar AWS IoT Device Defender
202204 AWS Black Belt Online Seminar AWS IoT Device Defender202204 AWS Black Belt Online Seminar AWS IoT Device Defender
202204 AWS Black Belt Online Seminar AWS IoT Device Defender
 
Infrastructure as Code (IaC) 談義 2022
Infrastructure as Code (IaC) 談義 2022Infrastructure as Code (IaC) 談義 2022
Infrastructure as Code (IaC) 談義 2022
 
202204 AWS Black Belt Online Seminar Amazon Connect を活用したオンコール対応の実現
202204 AWS Black Belt Online Seminar Amazon Connect を活用したオンコール対応の実現202204 AWS Black Belt Online Seminar Amazon Connect を活用したオンコール対応の実現
202204 AWS Black Belt Online Seminar Amazon Connect を活用したオンコール対応の実現
 
202204 AWS Black Belt Online Seminar Amazon Connect Salesforce連携(第1回 CTI Adap...
202204 AWS Black Belt Online Seminar Amazon Connect Salesforce連携(第1回 CTI Adap...202204 AWS Black Belt Online Seminar Amazon Connect Salesforce連携(第1回 CTI Adap...
202204 AWS Black Belt Online Seminar Amazon Connect Salesforce連携(第1回 CTI Adap...
 
Amazon Game Tech Night #25 ゲーム業界向け機械学習最新状況アップデート
Amazon Game Tech Night #25 ゲーム業界向け機械学習最新状況アップデートAmazon Game Tech Night #25 ゲーム業界向け機械学習最新状況アップデート
Amazon Game Tech Night #25 ゲーム業界向け機械学習最新状況アップデート
 
20220409 AWS BLEA 開発にあたって検討したこと
20220409 AWS BLEA 開発にあたって検討したこと20220409 AWS BLEA 開発にあたって検討したこと
20220409 AWS BLEA 開発にあたって検討したこと
 
202202 AWS Black Belt Online Seminar AWS Managed Rules for AWS WAF の活用
202202 AWS Black Belt Online Seminar AWS Managed Rules for AWS WAF の活用202202 AWS Black Belt Online Seminar AWS Managed Rules for AWS WAF の活用
202202 AWS Black Belt Online Seminar AWS Managed Rules for AWS WAF の活用
 
202203 AWS Black Belt Online Seminar Amazon Connect Tasks.pdf
202203 AWS Black Belt Online Seminar Amazon Connect Tasks.pdf202203 AWS Black Belt Online Seminar Amazon Connect Tasks.pdf
202203 AWS Black Belt Online Seminar Amazon Connect Tasks.pdf
 
SaaS テナント毎のコストを把握するための「AWS Application Cost Profiler」のご紹介
SaaS テナント毎のコストを把握するための「AWS Application Cost Profiler」のご紹介SaaS テナント毎のコストを把握するための「AWS Application Cost Profiler」のご紹介
SaaS テナント毎のコストを把握するための「AWS Application Cost Profiler」のご紹介
 
Amazon QuickSight の組み込み方法をちょっぴりDD
Amazon QuickSight の組み込み方法をちょっぴりDDAmazon QuickSight の組み込み方法をちょっぴりDD
Amazon QuickSight の組み込み方法をちょっぴりDD
 
マルチテナント化で知っておきたいデータベースのこと
マルチテナント化で知っておきたいデータベースのことマルチテナント化で知っておきたいデータベースのこと
マルチテナント化で知っておきたいデータベースのこと
 
機密データとSaaSは共存しうるのか!?セキュリティー重視のユーザー層を取り込む為のネットワーク通信のアプローチ
機密データとSaaSは共存しうるのか!?セキュリティー重視のユーザー層を取り込む為のネットワーク通信のアプローチ機密データとSaaSは共存しうるのか!?セキュリティー重視のユーザー層を取り込む為のネットワーク通信のアプローチ
機密データとSaaSは共存しうるのか!?セキュリティー重視のユーザー層を取り込む為のネットワーク通信のアプローチ
 
パッケージソフトウェアを簡単にSaaS化!?既存の資産を使ったSaaS化手法のご紹介
パッケージソフトウェアを簡単にSaaS化!?既存の資産を使ったSaaS化手法のご紹介パッケージソフトウェアを簡単にSaaS化!?既存の資産を使ったSaaS化手法のご紹介
パッケージソフトウェアを簡単にSaaS化!?既存の資産を使ったSaaS化手法のご紹介
 
202202 AWS Black Belt Online Seminar Amazon Connect Customer Profiles
202202 AWS Black Belt Online Seminar Amazon Connect Customer Profiles202202 AWS Black Belt Online Seminar Amazon Connect Customer Profiles
202202 AWS Black Belt Online Seminar Amazon Connect Customer Profiles
 
Amazon Game Tech Night #24 KPIダッシュボードを最速で用意するために
Amazon Game Tech Night #24 KPIダッシュボードを最速で用意するためにAmazon Game Tech Night #24 KPIダッシュボードを最速で用意するために
Amazon Game Tech Night #24 KPIダッシュボードを最速で用意するために
 
202202 AWS Black Belt Online Seminar AWS SaaS Boost で始めるSaaS開発⼊⾨
202202 AWS Black Belt Online Seminar AWS SaaS Boost で始めるSaaS開発⼊⾨202202 AWS Black Belt Online Seminar AWS SaaS Boost で始めるSaaS開発⼊⾨
202202 AWS Black Belt Online Seminar AWS SaaS Boost で始めるSaaS開発⼊⾨
 
[20220126] JAWS-UG 2022初頭までに葬ったAWSアンチパターン大紹介
[20220126] JAWS-UG 2022初頭までに葬ったAWSアンチパターン大紹介[20220126] JAWS-UG 2022初頭までに葬ったAWSアンチパターン大紹介
[20220126] JAWS-UG 2022初頭までに葬ったAWSアンチパターン大紹介
 
202111 AWS Black Belt Online Seminar AWSで構築するSmart Mirrorのご紹介
202111 AWS Black Belt Online Seminar AWSで構築するSmart Mirrorのご紹介202111 AWS Black Belt Online Seminar AWSで構築するSmart Mirrorのご紹介
202111 AWS Black Belt Online Seminar AWSで構築するSmart Mirrorのご紹介
 

AWS Black Belt Online Seminar 2017 Amazon ElastiCache

  • 1. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. アマゾン ウェブ サービス ジャパン株式会社 ソリューション アーキテクト 桑野 章弘 2017.12.14 【AWS Black Belt Online Seminar】 Amazon ElastiCache
  • 2. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 自己紹介 桑野 章弘(くわの あきひろ) ソリューションアーキテクト 主にメディア系のお客様を担当しております。 元渋谷のインフラエンジニア 好きなAWSのサービス:ElastiCache, Route53 好きなデータストア:MongoDB
  • 3. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 内容についての注意点 • 本資料では2017年12月14日時点のサービス内容および価格についてご説明しています。最 新の情報はAWS公式ウェブサイト(http://aws.amazon.com)にてご確認ください。 • 資料作成には十分注意しておりますが、資料内の価格とAWS公式ウェブサイト記載の価格に相違が あった場合、AWS公式ウェブサイトの価格を優先とさせていただきます。 • 価格は税抜表記となっています。日本居住者のお客様が東京リージョンを使用する場合、別途消費 税をご請求させていただきます。 • AWS does not offer binding price quotes. AWS pricing is publicly available and is subject to change in accordance with the AWS Customer Agreement available at http://aws.amazon.com/agreement/. Any pricing information included in this document is provided only as an estimate of usage charges for AWS services based on certain information that you have provided. Monthly charges will be based on your actual use of AWS services, and may vary from the estimates provided.
  • 4. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Agenda • Introduction • Amazon ElastiCache 概要 • Amazon ElastiCache アップデート • 代表的なユースケース • Amazon ElastiCache の料金 • まとめ
  • 5. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Introduction
  • 6. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Introduction Amazon ElastiCache はAWS クラウドでの分散インメモ リキャッシュ環境のセットアップ、管理、およびスケーリ ング、冗長構成等を容易に構築することができるサービス です ElastiCacheの詳しい使用方法について、そして ElastiCacheを使用した際の運用面のtipsを交えてご紹介し ます
  • 7. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon ElastiCache 概要
  • 8. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
  • 9. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. AWSが提供するデータベースサービス 完全マネージド型で、セットアップ、運用、拡張が 容易なリレーショナル・データベースサービス Amazon RDS Amazon DynamoDB 完全マネージド型で、高速なパフォーマンス、 シームレスな拡張性と信頼性のNoSQLサービス Amazon Redshift 高速で管理も万全なペタバイト規模のデータウェア ハウスサービス Amazon ElastiCache 完全マネージド型で、セットアップ、運用、拡張が容 易なキャッシュサービス Amazon Neptune 完全マネージド型で、高いパフォーマンス、シームレ スな拡張性、信頼性のグラフDBサービス(Preview)
  • 10. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon ElastiCacheとは • フルマネージド • キャッシュクラスタを数クリックで起動 • 可用性を向上させる機能(モニタリング、自動 障害検出、復旧、拡張、パッチ適用、バック アップ) • パフォーマンス • 超高速な2種類のエンジン(memcached, redis)をサポート • AmazonによるRedisの機能拡張 • 高可用性と堅牢性 • セキュリティグループ、VPC対応、暗号化
  • 11. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 他にもこんな機能 Lua スクリプト 位置情報クエリ Pub/sub
  • 12. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Cacheインスタンスクラスとスペック DB Instance Class vCPU メモリ(GiB) ネットワーク cache.t2.micro 1 0.555 低 cache.t2.small 1 1.55 低 cache.t2.medium 2 3.22 低 cache.t2.large 2 6.05 中 cache.m4.large 2 6.42 中 cache.m4.xlarge 4 14.28 高 cache.m4.2xlarge 8 29.70 高 cache.m4.4xlarge 16 60.78 高 cache.m4.10xlarge 40 154.64 10Gbps cache.r4.large 2 12.3 最大10Gbps cache.r4.xlarge 4 25.05 最大10Gbps cache.r4.2xlarge 8 50.47 最大10Gbps cache.r4.4xlarge 16 101.38 最大10Gbps cache.r4.8xlarge 32 203.26 10Gbps cache.r4.16xlarge 64 407 25Gbps ※表には記載していない旧世代インスタンス(cache.m3、r3)も選択可能です
  • 13. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Request rate High Low Latency Low High Structure Low High Data volume Low High Amazon RDS Amazon S3 Amazon Glacier Amazon CloudSearch and Amazon Elasticsearch Service Amazon DynamoDB Amazon ElastiCache and Amazon DynamoDB Accelerator (DAX) HDFS
  • 14. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon ElastiCache for memcached • 特徴 • 対応バージョン 1.4.5、1.4.14、1.4.24 、1.4.33 、1.4.34 (2017.12.14現在) • Cache Clusterという論理グループに、Cache Nodeを起動 • Cluster Group 全体のConfigration Endpointと、Cache Node単 体を表すNode Endpointの2種類のエンドポイント • バックアップ機能(Snapshot)は持たない • スケールアウトさせる場合はコンシステントハッシュなどを使用す る必要がある CacheCluster A Configration Endpoint Node Endpoint Node Endpoint App
  • 15. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Memcached アクセス用のClient Libraryの提供 • Auto Discovery 用に対応した専用のライブラリをAWSから提供 Auto Discovery用Client Library通常アクセス用Client Library • consistent hashingを提供 • Auto Discovery (60s毎) をノードの追加 /削除時に提供 • AWS Management Consoleから取得可 • PHP, Java, .NETに対応 Language Library Ruby Dalli, Dalli:ElastiCache Python Memcache Ring, django-elasticache Node.js node-memcached Language Library C#/.NET ElastiCache Auto Discovery Client PHP ElastiCache Auto Discovery Client Java ElastiCache Auto Discovery Client (based on spymemcached) • Memcached ノードの追加、削除のAuto Discoveryには未対応 • PHP、Java、.NET、C、C++、Ruby、 Python、Perl、多数の言語用のライブラ リが存在
  • 16. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Auto Discovery for memcached • DNS エイリアスとして提供され稼働しているノードリストを表示する • 従来のクライアントの設定 • Cache Clusterの全エンドポイントを接続先として設定 • Auto Discoveryクライアント(Java, PHP, .NET) • Cache ClusterのConfiguration EndpointはCache Clusterの ロードバランサ (Proxy) ではなく、接続先として設定すると全ノードを自動取得・設定し、接 続する CacheCluster Configuration Endpoint xxx.cfg.apne1.cache.amazonaws.com xxx.0001.apne1.cache.amazonaws.com xxx.0002.apne1.cache.amazonaws.com App 通常のクライアントライブラリ App Auto Discovery クライアントライブラリ http://docs.aws.amazon.com/AmazonElastiCache/latest/UserGuide/AutoDiscovery.html
  • 17. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. ElastiCache for Redis • 特徴 • 対応バージョン: 2.8.21, 2.8.22, 2.8.23, 2.8.24, 3.2.4, 3.2.6, 3.2.10 (2017.12.14現在) • 複数のCluster Group で構成されるReplication Group を構成 • 書き込み先を示すPrimary EndpointとCache Node単体を示す Node Endpointの2種類のアクセス用のエンドポイント • Multi-AZ構成の自動フェイルオーバーにも対応 • Snapshotベースでのバックアップ/リストアに対応 • Redis Clusterを使うためのcluster-mode(バージョン3.2以降) • クライアント認証、暗号化に対応 • 対応しない機能 • CONFIG, SLAVEOFなど一部コマンドは無効化
  • 18. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon による Redis 拡張 • ElasitiCache for Redis 2.8.22 以上 • 改善点: Swap Memoryの最適化 同期やスナップショット中にスワップの使 用量が増加するリスクを軽減する 書き込みの動的な制限 ノードのメモリが使い尽くされてい るときの出力バッファ管理の改善 高速なフェイルオーバ レプリカがプライマリとの完全な再同期を 行うためにデータをフラッシュするのを避 けるため、クラスタはより速く回復します
  • 19. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon による Redis 拡張 • OSSのRedis側へのコントリビュートも • PSYNC2 (Redis 4.0) • https://raw.githubusercontent.com/antirez/redis/4.0/00-RELEASENOTES • BGSAVE (Redis 3.2) • https://raw.githubusercontent.com/antirez/redis/3.2/00-RELEASENOTES • MIGRATE (Redis 3.0) • https://raw.githubusercontent.com/antirez/redis/3.0/00-RELEASENOTES • MASTER TIMEOUT (Redis 2.8) • https://raw.githubusercontent.com/antirez/redis/2.8/00-RELEASENOTES • INCREASE 2Billion+ KEYS in a DATASET (Redis 2.8) • https://raw.githubusercontent.com/antirez/redis/2.8/00-RELEASENOTES • https://github.com/antirez/redis/issues/1814, 4114, 4250, 3926, 3899
  • 20. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Redis アクセス用のClient Library • RedisにアクセスするためのライブラリはAWSから提 供していない • 各言語用のライブラリを選択して使用する • 各言語の主要なライブラリ Language Library Ruby Redis-rb, Redis objects Python Redis-py Node.js node-redis C#/.NET ServiceStack.Redis PHP phpredis Java Jedis Go go-redis, redigo
  • 21. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. リードレプリカ (Replication) • このような用途に利用可能 • 耐障害性向上(ただし、非同期レプリケーション) • Read性能のスケールアウト • 構成 • Replication Group内に、マスター1台、レプリカ 最大5台 • Replica の Replica は未対応 http://docs.aws.amazon.com/AmazonElastiCache/latest/UserGuide/Replication.html http://docs.aws.amazon.com/AmazonElastiCache/latest/UserGuide/ManagingReplication.html Availability Zone - a Availability Zone - b CacheCluster CacheCluster CacheCluster Replication Group
  • 22. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Replication構成例 • リードレプリカを複数のアベイラビリティゾーンに配置可能 • 同一AZのリードレプリカを参照し高速なデータ取得が可能 • AZ障害時のデータ保全が可能 Availability Zone - a Availability Zone - b 非同期レプリケーション SET GET SET GET App App
  • 23. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. フェイルオーバ • ノード障害時は自動フェイルオーバがかかる • ClusterModeDisable時にはPrimary EndpointのDNSのが 新しいマスターに切り替わり、壊れたサーバは可能であれば 再構成される Availability Zone - a Availability Zone - b 非同期レプリケーション SET GET SET GET App App Availability Zone - a Availability Zone - b 非同期レプリケーション SET GET SET GET App App
  • 24. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. バックアップ/リストア • ElastiCache Redis はSnapshotを取得しS3へのバック アップリストアが可能(自動/手動) • SnapshotからRedisのRDBファイルを生成し、S3に Exportする事も可能 • Cache Cluster作成時にSnapshotや、RDBファイルを 指定することも可能 S3 Snapshot Backup restore S3 Export RDB file Redis EC2 Redis restore
  • 25. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 監視のエコシステム • AWSに用意された各種サービスで監視の効率化/自動化 AWS Config Amazon CloudWatch AWS CloudTrail AWS CloudFormation AWS Management Console AWS CLI and SDKs alarm Amazon SNS Email Notification AWS Lambda Amazon ElastiCache
  • 26. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. CloudWatchによるElastiCacheの監視 • 主に監視する項目 • CPUUtilization (CPU使用率) • Memcachedの場合はマルチコアが使えるので 90% 超えでもOK • Redisはシングルコアなのでcache.m4.xlarge(4コア)だと25% (100% / 4) が 最大値 • CacheHits/CacheMisses • Evictions • キャッシュメモリ不足起因のキャッシュアウト発生回数 • SwapUsage • 低いほどいい • メモリ使用量 • BytesUsedForCacheItems(Memcached) • BytesUsedForCache(Redis) • Replica Lag • レプリケーション遅延(Redis) http://docs.aws.amazon.com/AmazonElastiCache/latest/UserGuide/CacheMetrics.Memcached.html http://docs.aws.amazon.com/AmazonElastiCache/latest/UserGuide/CacheMetrics.WhichShouldIMonitor.html http://docs.aws.amazon.com/AmazonElastiCache/latest/UserGuide/CacheMetrics.html
  • 27. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon ElastiCache アップデート
  • 28. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Redis Cluster • Redis 3.2 で Redis Cluster のサポート • データをシャード単位に分散保存することで最大15 シャード、6TiBのデータが保存可能 • 最大2000万/秒の読み込み、450万/秒の書き込み性能 Shard A Shard B Shard C 各シャードに分散 してデータを保存App
  • 29. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Redis Cluster • 16384 ハッシュスロット/クラスタ • スロットはクラスタ全体のシャード分散に使われる • Redisクラスタ対応のクライアントを使用する必要あり • クライアントは正しいシャードにリダイレクトされる • クライアントがマッピングを保持する Shard A Shard B Shard C 各シャードに分散 してデータを保存App Shard A = slots 0–3276 Shard B = slots 3277–9829 Shard C = slots 9830–16383
  • 30. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Availability Zone A slots 0–5454 slots 5455–10909 Redis Cluster Redis cluster—アーキテクチャ slots 10910–16363 Availability Zone B Availability Zone C slots 5455–10909 slots 5455–10909slots 0–5454 slots 0–5454 slots 10910–16363 slots 10910–16363 Redis cluster—multi-AZ構成 1〜15シャード Example: 3-shard cluster, 2 read replicas
  • 31. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Availability Zone A slots 0–5454 Redis Cluster Redis cluster—アーキテクチャ slots 10910–16363 Availability Zone B Availability Zone C slots 5455–10909 slots 5455–10909slots 0–5454 slots 0–5454 slots 10910–16363 Shard ReplicaReplicaPrimary 各シャード毎にプライマリノー ドと最大5つのレプリカノードを 持つ slots 5455–10909 slots 10910–16363
  • 32. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Availability Zone A slots 0–5454 slots 5455–10909 Redis Cluster Redis cluster—アーキテクチャ slots 10910–16363 Availability Zone B Availability Zone C slots 5455–10909 slots 5455–10909 Shard ReplicaReplica Primary 各シャード毎にプライマリノー ドと最大5つのレプリカノードを 持つ slots 0–5454 slots 0–5454 slots 10910–16363 slots 10910–16363
  • 33. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Availability Zone A slots 0–5454 Redis Cluster Redis cluster—アーキテクチャ slots 10910–16363 Availability Zone B Availability Zone C slots 10910–16363 slots 10910–16363 Shard Replica PrimaryReplica 各シャード毎にプライマリノー ドと最大5つのレプリカノードを 持つ slots 5455–10909 slots 0–5454 slots 5455–10909 slots 0–5454 slots 5455–10909
  • 34. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Availability Zone A slots 0–5454 slots 5455–10909 Redis Cluster slots 10910–16363 Availability Zone B Availability Zone C slots 5455–10909 slots 5455–10909slots 0–5454 slots 0–5454 slots 10910–16363 slots 10910–16363 プライマリノードの単体障害
  • 35. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Availability Zone A slots 0–5454 slots 5455–10909 Redis Cluster プライマリノードの単体障害 slots 10910–16363 Availability Zone B Availability Zone C slots 5455–10909 slots 5455–10909slots 0–5454 slots 0–5454 slots 10910–16363 障害緩和: 1. 自動障害検知とレプリカのマスター昇格 (~15–30 秒) 2. 障害ノードの復旧 slots 10910–16363
  • 36. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Availability Zone A slots 0–5454 slots 5455–10909 Redis Cluster プライマリの複数障害 slots 10910–16363 Availability Zone B Availability Zone C slots 5455–10909 slots 5455–10909slots 0–5454 slots 0–5454 slots 10910–16363slots 10910–16363
  • 37. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Availability Zone A slots 0–5454 slots 5455–10909 Redis Cluster slots 10910–16363 Availability Zone B Availability Zone C slots 5455–10909 slots 5455–10909slots 0–5454 slots 0–5454 ElastiCache の Redis拡張 • 障害自動検知とレプリカ昇格 • 障害が起きたノードを再構築する slots 10910–16363slots 10910–16363 プライマリの複数障害
  • 38. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Feature Enabled Disabled Failover 15–30 sec (Non-DNS) ~1.5 min (DNSベース) Failover risk • Writes 影響は部分的 • Reads は問題なし • Writes 全体に影響あり • Reads は問題なし Performance クラスタサイズに依存 (90 ノード—15ノードのプライマリ + 0–5 ノードのシャード毎のレプリカ) 6 ノード (1 ノードのプライマリ+ 0–5 ノード のレプリカ) Max connections • プライマリ(65,000 x 15 = 975,000) • レプリカ(65,000 x 75 = 4,875,000) • プライマリ: 65,000 • レプリカ: (65,000 x 5 = 325,000) Storage 6+ TiB 407 GB Cost Example: 必要なアクセ ス 175 GB 小さいノードで並べられるがお金はDisableよ りかかる $$ 9 x cache.r3.xlarge ($0.455hr) = $4.095 hr 255.6 GB 大きなノードであればあるほどコスト がかかる $ 1 X cache.r3.8xlarge = $3.640, 237 GB Redis cluster-mode 有効と無効の場合のまとめ
  • 39. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. バックアップからのRedis Cluster リサイズ • 従来の方法 • Redis Clusterのバックアップをリストアする際に シャード数を指定してリストアすることでRedis Clusterをリサイズする • ダウンタイムが発生する(アプリ側で新クラスタに向け 直す) S3 Snapshot Backup restore S3 Export RDB file 3 Shards 5 Shards
  • 40. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 0-5461 Shard 1 Shard 2 Shard 3 5462--10922 10923-16383 aws elasticache modify-replication-group-shard-configuration --replication-group-id r group-id --apply-immediately --node-group-count 5 Simple API ダウンタイム0の Scale In || Out Redis Cluster オンラインリサイズ
  • 41. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 0-5461 reads/writes Shard 1 Shard 2 Shard 3 Shard 4 Shard 5 5462--10922 10923-163830-2909, 5095-5461 5462-5783, 6876-9830 10923-14199 2910-5094, 9831--10922 No application interruption Uniform slot distribution across shards 5784-6875, 14200-16383 Redis Cluster オンラインリサイズ: スケールアウト
  • 42. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 0-5461 reads/writes Shard 1 Shard 2 Shard 3 Shard 4 Shard 5 5462--10922 10923-16383 Uniform slot distribution across shards No Application Interruption Redis Cluster オンラインリサイズ: スケールイン
  • 43. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. AWS Lambda 3 Shards … var params = { ApplyImmediately: true, NodeGroupCount: 5, ReplicationGroupId: ‘rep-group-id’, … } elasticache.modifyReplicationGroupShardConfiguration(params, function(err, data) { if (err) console.log(err, err.stack); else console.log(data); }); … 5 Shards メモリ! 大変! Amazon CloudWatch Cluster Resized AWS SNS Redis Cluster オンラインリサイズ: CWのアラームトリガー シャード数の オートスケー ルが可能に
  • 44. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. セキュリティ強化 • 暗号化 • In-Transit: クライアントとRedis間の通 信の暗号化を行う • At-Rest: S3とディスク上のバックアップ を暗号化する • 認証(コンプライアンス) • ElastiCache for Redis は HIPAA 認証 • AWS Business Associate Addendum(BAA)に対応 • Redis 3.2.6にて
  • 45. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. セキュリティオーバービュー Availability Zone BAvailability Zone A Private SubnetPrivate Subnet security group security group ElastiCache Redis Cluster security group Public Subnet security group Public Subnet Amazon S3 bucket REDIS RDB snapshot Encryption In-Transit 3.2.6 Redis AUTH Encryption at REST セキュリティ グループによ るNWフィルタ バックアップ の暗号化 Appと ElastiCache Redis間のやり とりの暗号化 クライアント 認証の対応
  • 46. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 代表的なユースケース
  • 47. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
  • 48. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. セッション管理 DBキャッシュ APIs (HTTP レスポンス) IOT ストリームデータ 分析 (Filtering/aggregation) Pub/sub ソーシャル メディア (Sentiment analysis) 単体のDB (Metadata store) リーダーボード ユースケースパターン
  • 49. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 様々なキャッシング クライアント Amazon ElastiCache Redis Amazon DynamoDB Elastic Load Balancing Amazon EC2 Amazon RDS write-through reads/ writes DDB streams mysql.lambda_async reads/ writes Amazon S3 reads/writes オブジェクトストレージ 非定型データ リレーショナルデータ
  • 50. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. NoSQL データベースのキャッシング Amazon EC2 reads/ writes reads MongoDB Cluster Cassandra Cluster  小さいNoSQLのインスタンス = 低コスト  より早いデータ検索 = より良いperformance Elasticsearch Cluster Clients
  • 51. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon EC2 reads/ writes Amazon ElastiCache Redis reads MongoDB Cluster DBObject doc = collection.findOne(); Cache serialized DBObject in Redis (good) Cache rows in Redis hash (faster/more efficient) Cassandra Cluster Amazon ElastiCache Redis Amazon EC2 reads/ writes reads ResultSet rs = session.execute(stmt); Cache serialized ResultSet in Redis (good) Cache rows in Redis hash (faster/more efficient)  小さいNoSQLのインスタンス = 低コスト  より早いデータ検索 = より良いperformance NoSQL データベースのキャッシング
  • 52. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Kinesis Data Analytics Amazon Kinesis Streams Amazon Kinesis Data Streams Amazon ElastiCache (Redis) 整形データ ストリーム ストリームデータ処理 Datasources 生データ ストリーム Subscribers AWS Lambda function 1 Continual data フィルタリング/整形 Real-time pub/sub AWS Lambda function 2
  • 53. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Kinesis DataSources AWS Lambda Apache Storm on EMR Spark Streaming on Amazon EMR Amazon Kinesis app Amazon EC2 AWS IoT Amazon ElastiCache 収集 ストア 処理 Amazon S3 Apache Kafka AWS Lambda Custom app Spark on Amazon EMR 分析 Redisを使ったビッグデータアーキテクチャ
  • 54. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Rules Engine Amazon ElastiCache Redis AWS Lambda 標準対応 LambdaSNS SQS S3 KinesisDDB AWS IoT devices AWS IoT センサストア IoT ソリューション
  • 55. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. モバイルアプリケーション Amazon API Gateway AWS Lambda Amazon ElastiCache Redis GEOADD GEORADIUS Search points of interest Update points of interest https://aws.amazon.com/blogs/database/amazon-elasticache-utilizing-redis-geospatial-capabilities/ Amazon DynamoDB DDB streams Amazon EC2
  • 56. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. アドテクノロジーアプリケーション Clients Advertisers https://aws.amazon.com/caching/database-caching/ Ad network Ad slot Consumer Ad slot publishers Ad placement (websites/apps) Amazon ElastiCache Redis <40 ms Clickstream (shopping events) ユーザが ページ閲覧 パブリッシャが オークション用の パブリック広告ス ペースを用意 アドネット ワークが入札 開始 入札のレスポン スを入札者に レスポンス 入札した勝者の 広告表示
  • 57. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. チャットアプリケーション https://aws.amazon.com/blogs/database/amazon-elasticache-utilizing-redis-geospatial-capabilities/ Clients Chat apps Application Load Balancer WebSockets Amazon ElastiCache Redis PubSub Serverpersistent connections Elastic Beanstalk SUBSCRIBE chat_channel:114 PUBLISH chat_channel:114 "Hello all" >> ["message", "chat_channel:114", "Hello all"] UNSUBSCRIBE chat_channel:114
  • 58. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. • 順位表みたいなものはゲームに限らず非常によ く使われるものだが、特にゲームはリアルタイ ム性の高い使い方をする • Redis sorted sets を活用することで非常に簡 単に実現可能 ZADD "leaderboard" 1201 ”Takayama” ZADD "leaderboard" 963 " Kuwano" ZADD "leaderboard" 1092 ”Nishitani " ZADD "leaderboard" 1383 ”Uehara” ZREVRANGE "leaderboard" 0 -1 1) ”Kuwano" 2) ”Nishitani" 3) ”Takayama" 4) ”Uehara” ZREVRANK "leaderboard" ”Takayama" (integer) 3 リアルタイムリーダーボード
  • 59. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 例: Redisのカウンタを活用した APIリクエストの同時接続数の上 限設定 ELB エクスターナル facing用 API 参考URL: http://redis.io/commands/INCR FUNCTION LIMIT_API_CALL(APIaccesskey) limit = HGET(APIaccesskey, “limit”) time = CURRENT_UNIX_TIME() keyname = APIaccesskey + ":” + time count = GET(keyname) IF current != NULL && count > limit THEN ERROR ”API request limit exceeded" ELSE MULTI INCR(keyname) EXPIRE(keyname,10) EXEC PERFORM_API_CALL() END Rate Limit
  • 60. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon ElastiCache の料金
  • 61. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 価格 オンデマンド キャッシュノード • 初期費用無し、時間単位の従量課金モデル リザーブド キャッシュノード • 予約金を支払うことで時間当たり価格を割引(最大70%節減) • アベイラビリティゾーンの指定が不要 バックアップストレージ(Redis) • 各クラスタに対して1つのSnapshotは無料 • 2つ以上のSnapshotから毎月 0.085 USD/GBが課金 AZ間データ転送量 • ElastiCache間の通信は課金対象外 • EC2とElastiCache間でAZを超える場合 0.01 USD/GB が課金 http://aws.amazon.com/jp/elasticache/pricing/ http://aws.amazon.com/jp/elasticache/reserved-cache-nodes/
  • 62. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. TCO比較 • 同スペックでのEC2とElastiCacheでのTCOの比較 • Multi-AZ構成時の通信費用削減 • 運用コスト • バックアップ • Multi-AZ Failover構成 • Clluster構成(Node Auto Discovery, Replication環境) • バージョンアップ/スケールアップ オンデマンド価格(月額換算) 重度リザーブド価格(月額換算) インスタンスタイプ EC2 ElastiCache 差額 EC2 ElastiCache 差額 t2.small $ 29 $ 38 $ 9 $ 21 $ 28 $ 7 r3.large $ 146 $ 199 $ 53 $ 95 $ 130 $ 35
  • 63. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. まとめ
  • 64. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. まとめ • 既存のアプリケーションの変更を最小限に、か つMemcached、Redisを使用したキャッシュ クラスタの構築、運用が可能 • バックアップ、フェイルオーバ、スペックアップ、 バージョンアップ等 • Amazonで拡張されたRedisの機能も利用可能 • バックアップ改善 • レプリケーション同期最適化 • Redis Cluster対応によりスケールするKVSと しての機能の拡充 • 暗号化対応によりセキュリティ要件の高い案件 にも対応可能
  • 65. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 参考資料 • Performance at Scale with Amazon ElastiCache https://d0.awsstatic.com/whitepapers/performance-at-scale-with-amazon-elasticache.pdf • Amazon ElastiCache Document http://aws.amazon.com/jp/documentation/elasticache/ • Amazon ElastiCache FAQ http://aws.amazon.com/jp/elasticache/faqs/ • Amazon ElastiCache Pricing http://aws.amazon.com/jp/elasticache/pricing/ • Memcached http://memcached.org/ • Redis http://redis.io/
  • 66. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. オンラインセミナー資料の配置場所 AWS クラウドサービス活用資料集 • http://aws.amazon.com/jp/aws-jp-introduction/ AWS Solutions Architect ブログ • 最新の情報、セミナー中の Q&A 等が掲載されています • http://aws.typepad.com/sajp/
  • 67. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 公式 Twitter/Facebook AWS の最新情報をお届けします @awscloud_jp 検索 最新技術情報、イベント情報、お役立ち情報、 お得なキャンペーン情報などを日々更新しています! もしくは http://on.fb.me/1vR8yWm
  • 68. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. AWS の導入、お問い合わせのご相談 AWS クラウド導入に関するご質問、お見積り、資料請求を ご希望のお客様は以下のリンクよりお気軽にご相談ください https://aws.amazon.com/jp/contact-us/aws-sales/ ※「AWS 問い合わせ」で検索してください
  • 69. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.