How do I set up shared persistent storage for multiple AWS EC2 instances?

I have a service hosted on Amazon Web Services. There I have multiple EC2 instances running with exactly the same settings and data that are managed using elastic load balancing and scaling groups.

These instances are web servers running PHP based web applications. So currently all instances host the same files, etc. But when the ELB / scaling group launches a new instance based on loading rules and so on, the files may be out of date. Also, I would rather use a shared filesystem for PHP sessions, etc. than sticky sessions.

So, my question is, for these reasons, and perhaps more in the future, I would like to have a shared filesystem that I can connect to my EC2 instances. How would you suggest to solve this problem? Are there any solutions offered by AWS directly so I can rely on their services instead of doing it on mine with DRBD and so on? What's the easiest approach? DRBD, NFS, ...? Is S3 Possible For Those Intending?

Thanks in advance.

+3


source to share


7 replies


As mentioned in the comment, AWS announced EFS ( http://aws.amazon.com/efs/ ) a Shared Network File System. It is currently in very limited preview, but based on previous AWS services, I hope it will be available over the next few months.

At the same time, there are several third party file system solutions for AWS such as SoftNAS https://aws.amazon.com/marketplace/pp/B00PJ9FGVU/ref=srh_res_product_title?ie=UTF8&sr=0-3&qid=1432203627313

S3 is possible, but not always ideal, the main blockage is that it does not support file system protocols, and all interactions must be done through AWS API or over HTTP calls. Also, when you use it for session stores, the "ultimately consistent" model is likely to cause problems.



If you need to update resources, you can create a simple script to run either as cron or on startup that downloads files from s3.

Finally, in the case of static resources like css / images, they don't store them on your web server in the first place - there are many articles out there on storing and accessing static web resources directly from s3 while keeping the dynamic stuff on your server.

+2


source


To sync web server sessions, you can easily switch to Redis or Memcached as your session handler. It's a simple setup in PHP.ini, and they can all access the same Redis or Memcached server for sessions. You can use Amazon Elasticache to manage your Redis or Memcache instance for you.

http://phpave.com/redis-as-a-php-session-handler/ <- explains how easy it is to set up Redis with PHP

Keeping your files in sync is a little tricky.

How do I push new code changes to all of my web servers?


You can use Git. When deploying, you can set up multiple servers and it will redirect your branch (master) to multiple servers. Therefore, each new build goes to all web servers.



How about launching new machines?

I would set up new machines to run the rsync script from a trusted source, your main web server. This way, they sync their web folders with the master at boot and will be identical even if the AMIs had old web files.

How about files that change and need to be updated in real time?

Store any user-uploaded files in S3. So if a user uploads a document to Server 1, then the file is stored in s3 and the location is stored in the database. Then, if another user is on server 2, they can see and access the same file as if they were on server 2. The file would be retrieved from s3 and sent to the client.

+1


source


From what we can tell at this point, EFS is expected to provide NFS file sharing on SSD-backed storage. Once available, it will be v1.0 filesystem. No encryption and its AWS-only. All data is managed by AWS.

SoftNAS is a mature, proven NAS Filer Advanced ZFS Server that is fully featured, including encrypted EBS and S3 storage, storage snapshots for data protection, writeable clones for DevOps and QA testing, RAM and SSD caching for maximum IOPS and throughput. deduplication and compression, cross-zone HA and 100% SLA. It supports NFS with LDAP and Active Directory authentication, CIFS / SMB with AD users / groups, iSCSI multicast, FTP and (soon) AFP. Your SoftNAS instances and all storage are completely under your control and you have complete control over EBS and S3 encryption and keys (you can use EBS encryption or whatever Linux encryption and key management approach you prefer or require).

The ZFS file system is a proven file system trusted by thousands of enterprises around the world. There are currently over 600 million files running on SoftNAS in production - ZFS can scale to billions.

SoftNAS is cross-platform and runs on cloud platforms other than AWS, including Azure, Cloud Cloud Cloud, Faction cloud, VMware vSPhere / ESXi, VMware vCloud Air, and Hyper-V, so your data is not capped or locked in AWS. more platforms. It enables cross-platform replication, allowing data to be easily migrated between any supported cloud cloud regions, private cloud, or premise-based datacenter.

SoftNAS is backed by industry-leading cloud storage support (everything we do) for whatever you need or need.

Here are some of the more notable differences between EFS and SoftNAS. For a more detailed comparison chart:

https://www.softnas.com/wp/nas-storage/softnas-cloud-aws-nfs-cifs/how-does-it-compare/

If you're willing to roll over your own HA NFS cluster and be responsible for care, power, and maintenance, then you can use Linux and DRBD / corosync or any number of other Linux clustering approaches. You will have to support it yourself and be responsible for everything that happens.

There's also GlusterFS. It is well suited for 250,000 files (in our testing) and has been seen to suffer from IOPS bypass as it approaches 1 million files, and IOPS falls off 1 million files (according to customers who have used it). For small deployments, it reportedly works reasonably well.

Hope it helps.

CTO - SoftNAS

+1


source


Before Amazon EFS hits production The best approach in my opinion is to build a storage backend exporting NFS from EC2 instances, possibly using Pacemaker / Corosync to achieve HA.

You can create an EBS volume that stores files and tell Pacemaker to umount / dettach and then attach / attach the EBS volume to a healthy NFS node cluster.

0


source


Hi, we are currently using a product called SoftNAS in our AWS environment. This allows us to choose between EBS and S3 backup. It has built-in replication as well as a high availability option. Maybe you can check. I believe they offer a free trial that you can try on AWS

0


source


We use ObjectiveFS and work well for us. It uses S3 for storage and is directly configured for customization.

They also wrote a document on how to share files between EC2 instances. http://objectivefs.com/howto/how-to-share-files-between-ec2-instances

0


source


GlusterFS is also an open source distributed file system used by many to create shared storage across EC2 instances.

0


source







All Articles