how does multiple EC2 instances (scaling) works on one EBS for data storage?
Asked Answered
S

2

10

So, in a simple situation, if there is only one instance, then I can store the data into a EBS volume mounted on that instance. e.g. /mnt/db

However, how does it work if I scale and have multiple instance (either static or dynamic scaling)?

Because one EBS can only attach to one instance, if I have multiple instance, does it mean that I have to attach an EBS volume for each instance? If that's the case, the data on each Instance's EBS volume will be different.

It is obvious that I want all instances to access (R & W) a single volume (as data-storage). and the data in the volume will constantly grow and there is no downtime.

What is the solution? Is there a way that I don't mount the device (EBS), and just call it for accessing the data?

Here is what I can think of: 1) if each instance has its own EBS volume, then each time interval (e.g. 1 hour), all instances will unmount & detach the EBS volume,and attach a new one. Then there is one powerful instance that mount all the EBS volumes just detached, and aggregate all the data. 2) or similar to 1), instead of detach and attach, I just take a snapshot on all volumes for all instances. Then the powerful instance aggregateness the data from the snapshot. And save the result into either another EBS or S3.

These two approach seem to be working.. but require a lot of work. is there a smarter way to approach this problem? thanks.

  • by the way, because of performance issue, I cannot have the instance writes data to S3. :)

OH how about this 3) First, all instances have their own EBS and write data into the EBS. and then each hour, data will be sent to S3. Then another instance will aggregate them.

Sillsby answered 27/1, 2011 at 0:39 Comment(1)
This is a very good question and a part of the AWS Auto Scaling that I do not understand and came hoping for an answer. How does auto scaling work when the database is on an EBS volume? That is, how do the new EC2 instances have access to it?Greasewood
C
1

how about having ang NFS instance which can be mounted to the other instances?

Chippewa answered 27/1, 2011 at 3:25 Comment(1)
Yes you can setup NFS in Linux. For the performance side obviously slower than direct ephemeral storage. Either use ephemeral drive and just sync it to an NFS using a cron task on a specified times.Chippewa
H
0

It seems that you need to create an EBS snapshot of your most up to date EC2 instance. This will create an EBS backed AMI. You would then need to terminate all your EC2 instances that are not up to date and launch a new stack of instances from your newly created AMI. If you had a load balancer running then you would have to attach these new instances to your load balancer also. It seems a little long-winded but it can all be done programmatically. At least this is how I think scaling in the cloud with Amazon works and far as propagating changes across multiple instances goes. Somebody else with more experience verify this. I plan to test it out myself later on.

Heptamerous answered 1/5, 2012 at 7:55 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.