3

So I'm trying to learn more about AWS EC2 Auto Scaling and trying to figure out how exactly storage works between instances. When creating new instances it looks like a new EBS volume for each instance.

If I'm running a web server on EC2 Auto Scaling how can I get my content to be transferred to each new EC2 instance created. Is there a way to have one EBS volume used in all the EC2 Auto Scaling instances? I have read about Elastic File System but I'm not sure how you would attach the volume to new instances as they are created.

Thanks in advance for your help.

5

No, EBS can be connected to just one EC2 instance. You can imagine it as normal harddisk - it can be connected to only one machine too. You can switch EBS between your instances but cannot attach it to more than one.

EFS is just network filesystem like nfs or samba, you can mount it with your fstab. But you have to check if EFS is available in your region!

As I understand, you're trying to make file storage shared between all your machines. In this case you have several ways how to achieve it:

  • if you don't need regular filesystem, you can use S3. It is recommended way in AWS. But S3 is not filesystem, it is object storage with rest api, so you cannot use regular method to access files on it but you have to use amazon SDK. S3 has quite unlimited size and it has no problem with multiple accesses. You can even use S3 as backend for CloudFront CDN.

  • If you need regular filesystem, you have several ways. You can use EFS is available or you can build some storage VMs with gluster and mount it to your instance. You definitelly will need custom AMI with mounts in fstab, prepare HA, backups etc. But it works like regular FS? it is shared and instant - file created on machine A can be instantly accessed on machine B

  • If you just need to deploy your application to newly started EC2, you can use CodeDeploy or OpsWorks to tell autoscalling group to deploy your application on new EC2. But it works only with limited number of distributions, I think with Amazon Linux, RHEL and Ubuntu only.

  • If you need to have that storage synced across all of your EC2 and don't want to setup some storage EC2, you can just run rsync accross cluster. This way is little tricky and can be problematic in case of big number of instances. You cannot achieve instant sharing with rsync too.

Recomended solutions depends on your needs, I'm using two EC2 instances with big EBS and replicated gluster volume mounted on all of my application servers. It works well.

  • Thanks for the detailed comment!! After doing a bit more research also would I be able to create a EFS volume and setup a new AMI that is a custom version that runs the EFS mount in the /etc/rc.local file to mount on bootup. Then just use that AMI in my auto scaling group? Would that be a viable option? Thanks again so much for your help!! – Charlie Fish Jul 9 '16 at 23:57

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.