Scaling MongoDB on AWS
MongoDB Tokyo 2013
自己紹介
Name:松尾康博 ( @understeer )
Company:Amazon Data Services Japan
Job:Solutions Architect
Famous AWS Services :
 High Performance Instance
 High Performance Storage

Community
 MongoDB-JP

Copyright © 2013 Amazon Data Services Japan
Agenda
AWS Overview
MongoDB on AWS
Use cases
Tips

Copyright © 2013 Amazon Data Services Japan
クラウドコンピューティングとは?
初期投資が不要

低額な利用価格

実際の使用分
のみ支払い

セルフサービスな
インフラ

スケールアップ、
ダウンが容易

ビジネススピード
の改善

Deploy
AWSの様々なサービス
お客様のアプリケーション
ライブラリ & SDKs
Java, PHP, .NET,
Python, Ruby,
node.js

IDEプラグイン
Eclipse
Visual Studio

Web管理画面
Management
Console

認証
AWS IAM

メッセージ
Amazon SNS
Amazon SQS
Amazon SES

デプロイと自動化

モニタリング
Amazon
CloudWatch

検索エンジン
Amazon Cloud Search

AWS Elastic Beanstalk
AWS Cloud Formation
AWS OpsWorks

ワークフロー管理
Amazon SWF
AWS DataPipeline

コンテンツ配信

分散処理

トランスコード

Amazon CloudFront

Elastic MapReduce

データベース

Amazon S3
Amazon EBS
Amazon Glacier
AWS StorageGateway

Amazon RDS
Amazon DynamoDB
Amazon ElastiCache
Amazon Redshift

Application
Service

Amazon Elastic Transcoder

ストレージ
コンピュータ処理
Amazon EC2
Auto Scale

ネットワーク & ルーティング
Amazon VPC / Amazon Elastic Load Balancer / Amazon Route 53 /AWS Direct Connect

5 Region

Development &
Administration

AZ

AWS グローバルインフラ
Geographical Regions, Availability Zones, Points of Presence

Infrastructure
Service
世界に広がるAWSのインフラ
GovCloud

米国西部

米国東部

南アメリカ

EU西部

(US ITAR Region)

(Northern
California,
Oregon)

(Northern
Virginia)

(Saopaulo)

(Dublin)

アジア
パシフィック
(Singapore)

アジア
アジア
パシフィック パシフィック
(Sydney)
(東京)

世界190以上の国または地域で
数十万のお客様がご利用
日本でも20,000超のお客様
世界で500を超える政府機関や、
2,000を超える教育機関もご利用
Amazonが年商5000億円規模の頃の同じサー
バリソースを毎日追加

AWS リージョン
AWS エッジロケーション(CloudFront & Route 53)

6
EC2

Amazon EC2(Elastic

リージョン

アベイラビリティ
ゾーン A

EC2

Compute Cloud)

任意のゾーンに
分散配置可能
1

アベイラビリティ
ゾーン B

EC2

数分で起動可能な仮想サーバ
1時間ごとの従量課金で利用可能
14種類の仮想サーバを選択可能
Windows, Linuxなどx86-64アーキテクチャのOSが利用可能
OS以上は自由に触れる
 MongoDBでもそれ以外のNoSQLでもインストール可能

Copyright © 2013 Amazon Data Services Japan
AWSの高い汎用性
フロントUI

×
HTML5

OS

ミドルウェア

開発言語

×
MongoDB on AWS
MongoDBをAWSで実行すると・・
簡単に試せる
 しかも安く試せる
 複数データセンター間・遠隔レプリカを簡単に実現

AWSの機能を活用して、運用を楽に!
 データの可用性、耐久性対策

スケーラブル!
 高性能インスタンスに簡単にスケールアップ
 すぐに台数を増やして簡単にスケールアウト

Copyright © 2013 Amazon Data Services Japan
簡単に試せる
Linuxインスタンス起動 5分
EBS設定 5分
MongoDBインストール 数分
MongoDBセットアップ 数分
MongoDB起動 数分

http://docs.mongodb.org/ecosystem/platforms/amazon-ec2/
Copyright © 2013 Amazon Data Services Japan
Easy to start a single node
AWS マーケットプレイス
 MongoDB 2.4.8がプリインストールされたイメージを無償提供
• https://aws.amazon.com/marketplace/pp/B00COAAEH8/

Copyright © 2013 Amazon Data Services Japan
Easy to start a single node
AWS マーケットプレイス
 MongoDB がプリインストールされたイメージを無償提供
• https://aws.amazon.com/marketplace/pp/B007IBMJPI/

 手順も公開
• http://www.mongodb.org/display/DOCS/AWS+Marketplace

Copyright © 2013 Amazon Data Services Japan
Scale MongoDB!
Replica sets on AWS
MongoDB

+

Arbiter in Availability Zones.
Sharded Replica sets on AWS
Config Servers (t1.micro) and MongoDBs in AZs
Copyright © 2013 Amazon Data Services Japan
replicate

Copyright © 2013 Amazon Data Services Japan
shard

shard

shard

Copyright © 2013 Amazon Data Services Japan
Scale OUT!

shard

shard

shard

Copyright © 2013 Amazon Data Services Japan
shard

shard

shard

Copyright © 2013 Amazon Data Services Japan
3.75
7.5
15
17.1
34.2
68.4
60.5
244

< - - -Where you should be

Copyright © 2013 Amazon Data Services Japan
3.75 m1.medium
7.5 m1.large
15 m1.xlarge
17.1 m2.xlarge …
34.2 m2.2xlarge
68.4 m2.4xlarge
60.5 c3.8xlarge
244 cr1.8xlarge

GBメモリ

Copyright © 2013 Amazon Data Services Japan
High I/O 4XL 60.5 GB
35 EC2 Compute Units
16 virtual cores
2*1024 GB SSD-based local instance storage

High Storage 8XL 117 GB
35 EC2 Compute Units,
24 * 2 TB ephemeral drives
10 GB Ethernet

256

Hi-Mem 2XL 34.2 GB
13 EC2 Compute Units
4 virtual cores

64

Memory (GB)

M3 XL 15 GB
13 EC2 Compute Units 4
virtual cores
EBS storage only

Medium 3.7 GB,
2 EC2 Compute Units
1 virtual core
Large 7.5 GB
4 EC2 Compute Units
2 virtual cores

4
2

Cluster GPU 4XL 22 GB
33.5 EC2 Compute Units,
2 x NVIDIA Tesla “Fermi”
M2050 GPUs

Extra Large 15 GB
8 EC2 Compute Units
4 virtual cores

16

Cluster Compute 8XL 60.5 GB
88 EC2 Compute Units

Cluster Compute 4XL 23 GB
33.5 EC2 Compute Units

Hi-Mem XL 17.1 GB
6.5 EC2 Compute Units
2 virtual cores

32

8

10 GB
InterInstance
Network

Hi-Mem 4XL 68.4 GB
26 EC2 Compute Units
8 virtual cores

128

Hi-Mem Cluster Compute 8XL 244
GB
88 EC2 Compute Units
16 virtual cores
240 GB SSD

Small 1.7 GB,
1 EC2 Compute Unit
1 virtual core

M3 2XL 30 GB
26 EC2 Compute Units 8
virtual cores
EBS storage only

High-CPU XL 7 GB
20 EC2 Compute Units
8 virtual cores

High-CPU Med 1.7 GB
5 EC2 Compute Units
2 virtual cores
Micro 613 MB
Up to 2 ECUs (for
short bursts)

1
1

2

4

8

16

32

EC2 Compute Units

64 128 256
Scale UP!

Copyright © 2013 Amazon Data Services Japan
高性能スペック
1

C3 インスタンス
3世代目の、クラスタコンピュートインスタンスタイプ
HVM(完全仮想化)で実行
Intel® Xeon® E5-2680v2 processors
10 Gigabit Ethernet

32仮想core
60GB RAM
320GB x 2
Local SSD

Cluster Compute
大容量メモリスペック
2 CR1 インスタンス
3世代目の、大容量メモリクラスタコンピュートインスタンスタイプ
Intel® Xeon® E5-2670 processors
10 Gigabit Ethernet

16仮想core
244GiB RAM
120GB x 2
Local SSD

Cluster Compute
Scale I/O

SSD

SSD

SSD
SSD

SSD

SSD

SSD

SSD

SSD

Copyright © 2013 Amazon Data Services Japan
高速 IO
3

I2 インスタンス
高速ファイルI/Oを実現するインスタンスタイプ
Intel® Xeon® E5-2670v2 processors
10 Gigabit Ethernet
高速なSSDを内蔵 ( Max 350,000 IOPS ※4KB read)

32仮想core

244 GB RAM
720GB x 8
Local SSD

Cluster Compute
New Instances まとめ
ファミリー (6)
汎用
General Purpose

M1
M3

コンピューティング最適化
Compute Optimized

C1
CC2

メモリ最適化
Memory Optimized

M2

CR1

ストレージ最適化
Storage Optimized

HI1
HS1

マイクロインスタンス
Micro

T1

GPUインスタンス
GPU

30

タイプ (10)

CG1

新しいタイプ (3)

C3

I2

G2
Storage Tuning
インスタンスを大きくするとEBSの帯域も増えるので
ディスク本数を増やしてもサチらない
(m1.xlarge, c1.xlarge, m2.4xlarge)
例) 100GiBを8本 RAID10で400+ IOPS
Test: random 4k reads

EBS One Volume: ~200 MongoOPS
Loaded instance: ~ 1000 MongoOPS

+

4,000 MongoOPS
Loaded Instance: 80,000 MongoOPS

PIOPS One Volume:

SSD

I2 SSD: ~180,000 MongoOPS

Copyright © 2013 Amazon Data Services Japan
Test: random 4k reads

+

PIOPS

EBS

Copyright © 2013 Amazon Data Services Japan

SSD
random 4k reads

+

EBS

Stable

PIOPS

Copyright © 2013 Amazon Data Services Japan

SSD
random 4k reads

+

SSD

Copyright © 2013 Amazon Data Services Japan

Fast!!!

EBS

Stable

PIOPS
Ext4 or XFS, noatime
Raise file descriptor limits

Set disk read-ahead
No large virtual memory pages
Freeze IO’s during snapshots

Copyright © 2013 Amazon Data Services Japan

Fast!!!

Stable

Config Tips
Whitepaper
Published March 2013.
MongoDB 2.2

http://d36cz9buwru1tt.cloudfront.net/AWS_NoSQL_MongoDB.pdf

Copyright © 2013 Amazon Data Services Japan
Sumally(サマリー)
「モノの百科事典」を目指すサービス
• http://sumally.com/
• 250,000+ Users
• 1,200,000+ Items
• 35,500,000+ Wants/Haves

Copyright © 2013 Amazon Data Services Japan
Sumally(サマリー)
「モノの百科事典」を目指すサービス

EBS

EBS

EBS

EBS

Availability Zone a

EBS

EBS

EBS

EBS

EBS

EBS

Availability Zone b

• 3 Replica Sets
• Main: m2.2xlarge
• Log: m1.large
• Notification: m2.xlarge
• Use MMS
• Availability
• 99.9996%
• (メンテ時間を含む)

Copyright © 2013 Amazon Data Services Japan
JMTY(ジモティ-)
地元の無料の広告掲示板サービス
• Full AWS
• Only MongoDB as Datastore

• Replicaset ( 3 nodes)

Copyright © 2013 Amazon Data Services Japan
SnapDish by Vuzz.inc
料理を簡単に美味しく撮る「料理カメラ」
• 70万 DL
• 160万 Posts

• 1000万 もぐもぐ( likes)
• 800posts/hour

Copyright © 2013 Amazon Data Services Japan
SnapDish by Vuzz.inc
• Replicaset( 2 nodes +arb)
• 1000 PIOPS EBS RAID10
• hi1.4xlarge + SSD
• GridFS – photos from users
• GeoIndex – location of photo

AWSを利用することで、インフラ管理を自分で全部で
きるのでコスト削減に役立っています。あと、アプリ
開発により時間がとれるので、サービスの向上に繋
がっています。
Copyright © 2013 Amazon Data Services Japan
Vuzz CTO 清田史和様
発行部数6,000万部!伝説の不良漫画のソーシャルゲーム
・フルAWS
・データベースはMongoのみ
・1レプリカ
・S3にバックアップ
・EBS 2000IOPS
・150000+ Users
・Chef + Capistranoでサーバ構築を自動化
・Github + Capistrano + Jenkinsで自動deploy
ELB

Web Server
Web Server
Web Server+
Apache
CakePHP

Cloud Front

Web Server
Web Server
Web Server
Apache +
CakePHP

ap-northeast-1a:c1.medium *
nap-northeast-1c:c1.medium * n

Admin Server

ElastiCache

Mongo DBPrimary

Jenkins Server

github
Mongo
DBSecondary
Mongo
DBSecondary
ap-northeast-1a:m3.2xlarge * 2
ap-northeast-1c:m3.2xlarge * 1

Batch Server

S3
Whitepaper
Published March 2013.
MongoDB 2.2

http://d36cz9buwru1tt.cloudfront.net/AWS_NoSQL_MongoDB.pdf

Copyright © 2013 Amazon Data Services Japan
まとめ
MongoDBをすぐに安く試すならAWS!
 無料枠でも十分試せます!

AWSの多くの機能で運用を楽に!
 Whitepaperあります

AWSでMongoDBの機能をフル活用!
 本番利用時はMongoDBサポートも併せて!

Copyright © 2013 Amazon Data Services Japan
Scaling MongoDB on AWS

Scaling MongoDB on AWS

Editor's Notes

  • #27 Cc1 – bargain on the spot market!
  • #28 Cc1 – bargain on the spot market!
  • #30 Cc1 – bargain on the spot market!