Mongodb – Where to store data on AWS

amazon ec2awsmongodb

I'm using AWS to host my application, and I'm using mongodb as db. I have installed mongodb on amazon ec2, but now I have no idea about where I should store all of my data. Can I store all of my data on ec2 itself as my db will grow with time?

Best Answer

Yes.

Think of EC2 as a machine. It has a disk attached - a EBS (Elastic Block Store), and the disk size is your limit. Lets say your ec2 instance has a 20gig disk. If you database grow over 20gig, you will have to resize your attached disk.

I am not aware of a auto-scalling method for EC2 disks.

But you can simply make a snapshot of a EBS, create another EBS from this snapshot with you desired size, detach the old disk from your machine and attach the new one. This new disk will have all of the old disk data (its a snapshot, a clone) but will be bigger in size. Lets say you make it 30gigs this time.

After that, if you are on a Linux EC2 Machine, you'll have to run a command within the machine to resize the disk to the new value. Its as simple as that. Just the other day my machine started behaving bad, I checked and it had a disk full. The whole proccess took a couple of minutes and was done entirely on the EC2 dashboard plus a simple ssh command on the machine.

Full details here: http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ebs-expand-volume.html