3

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?

6

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

  • Just a small note: depending on the instance type, other storage types (SSD and HDD) are available, too. These are not recommended, though: docs.mongodb.org/ecosystem/platforms/amazon-ec2 – dezso Feb 18 '16 at 16:43
  • Good input. I have not experience with mongodb. A couple of EBS options available but one has to pick one that is appropriate for the mission. You can easily attach multiple EBS's to the same machine. If you need ssd for cache (IE) and Mongodb doesnt play well with it, just attach a standard HDD (magnetic?). Best of luck. – ddutra Feb 18 '16 at 16:46
  • One thing to keep in mind: backups. EC2 instances can and will be terminated without notice. Any information that is stored on one should have an automated backup system running if you value your data at all. – Willem Renzema Feb 18 '16 at 16:51
  • @WillemRenzema exactly this is why EBS is recommended: it is not instance-specific, so it survives an instance crash. – dezso Feb 18 '16 at 17:12
  • Good point @willemRenzema. I use Turnkey Linux Hub to manage my Ec2 machines. All my software runs on their vms which are crafted on top of debian. Turnkey linux itself has a backup software which I strongly recommend (tklbam) but the hub itself schedules snapshots and even full images of my machines! You can restore to a different machine right from the hub. I am sure there are many saas like this out there. Or if you are into the command line you sure could use aws cli to schedule this yourself. – ddutra Feb 18 '16 at 17:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.