EC2 instances can be configured either with ephemeral storage or persistent storage using the Elastic Block Store (EBS). Ephemeral storage is lost when instances are terminated so it is generally not recommended for use unless you’re comfortable with the data-loss implications.
For almost all deployments EBS will be the better choice. For production systems we recommend using
EBS-optimized EC2 instances
Provisioned IOPS (PIOPS) EBS volumes
Storage configurations can vary from one deployment to the next but for the best performance we recommend one volume for each of the following: data directory, journal, and log. Each of those has different write behaviours and we use one volume for each to reduce IO contention. Different RAID levels such as RAID0, RAID1, or RAID10 can also be used to provide volume level redundancy or capacity. Different storage configurations will have different cost implications especially when combined with PIOPS EBS volumes.
Deploy from the AWS Marketplace
There are three officially maintained MongoDB AMIs on the AWS Marketplace. Each AMI comes pre-configured with individual PIOPS EBS volumes for data, journal, and the log.
For specific information about how each instance was configured, refer to Deploy MongoDB on EC2.
Deploy MongoDB on EC2
The following steps can be used to deploy MongoDB on EC2. The instances will be configured with the following characteristics:
MongoDB 2.4.x installed via Yum
Individual PIOPS EBS volumes for data (1000 IOPS), journal (250 IOPS), and log (100 IOPS)
Updated read-ahead values for each block device
Update ulimit settings
Before continuing be sure to have the following:
Install EC2 command line tools
Generate an EC2 key pair for connecting to the instance via SSH
Create a security group that allows SSH connections
Create the instance using the key pair and security group previously created and also include the --ebs-optimized flag and specify individual PIOPS EBS volumes (/dev/xvdf for data, /dev/xvdg for journal,/dev/xvdh for log).
After login, update installed packages, add the MongoDB yum repo, and install MongoDB: