Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Shared storage between multiple AWS EC2 instances

I'm facing a problem to share a storage between multiple EC2 instances. I'm going to have to run heavy jobs so I'll need a lot of instances to do it. On one side ,I have an EBS volume attached to one server instance. On the other side I have a a worker instance. I created an AMI of this worker instance and then I created several instances copies of this AMI. There are all running on the same VPC. Basically the server instance is sending jobs and the workers are executing the job. I would like to save some log files when my workers are running the jobs, in the share storage something like:

worker_1/ logfile.log

worker_2/ logfile.log

What could be the best solution to do that?

  • I read it's not possible to attach the same EBS volume to multiple instances.
  • I had a look at GlusterFS but here is what I found:

"Before realizing a proof of concept with two servers, in different availability zones, replicating an EBS volume with an ext4 filesystem, we will list the cases where GlusterFS should not be used: Sequential files written simultaneously from multiple servers such as logs. The locking system can lead to serious problems if you store logs within GlusterFS. The ideal solution it’s to store them locally then use S3 to archive them. If necessary we can consolidate multiple server logs before or after storing them in S3."

  • And finally, I've also checked S3 bucket mounted with s3fs but I found out it's not a good option too:

"You can't partially update a file with s3fs so changing a single byte will re-upload the entire file" . Then if you want to make small incremental change then its a definite no. You can't use s3fs - S3 Just doesn't work that way you can't incrementally change a file."

Then what could be a good solution to my problems and allows my workers to write their log files in a share storage?

Thanks for your help!

Romanzo

like image 810
Romanzo Criminale Avatar asked Jul 02 '13 00:07

Romanzo Criminale


People also ask

Which AWS service allows for the file sharing between multiple Amazon EC2 instances?

Amazon EFS provides shared file storage for use with compute instances in the AWS Cloud and on-premises servers. Applications that require shared file access can use Amazon EFS for reliable file storage delivering high aggregate throughput to thousands of clients simultaneously.

How do I create a shared folder between two EC2 instances?

You can simply create a security group and then add an inbound rule to allow all traffic from it's own security group and then add these security group in both instances to share data with each other but there's an better approach for this is to use FSx in AWS.

Can I share EBS volume between instances?

Amazon EBS Multi-Attach enables you to attach a single Provisioned IOPS SSD ( io1 or io2 ) volume to multiple instances that are in the same Availability Zone. You can attach multiple Multi-Attach enabled volumes to an instance or set of instances.

Can multiple EC2 instances share an EBS volume?

Amazon Elastic Block Store or EBS is a durable block-based storage device that can be attached to your EC2 instance. AWS released a feature called Multi-Attach, which allows EC2 instances to share a single EBS volume for up to 16 instances and provide higher availability of your applications for Linux workloads.


2 Answers

Thanks for the answers. but finally I'm using NFS between the instances and it works pretty well!

like image 125
Romanzo Criminale Avatar answered Nov 16 '22 01:11

Romanzo Criminale


As is described in this thread and in some of the answers already provided, two common ways to accomplish this goal were to use S3 or NFS to share data access between instances.

On April 9th 2015, Amazon announced Amazon Elastic File System (Amazon EFS), which provides a much better solution to the problem you're trying to solve.

like image 32
Scott Avatar answered Nov 16 '22 01:11

Scott