Here is the full description directly from Amazon EFS:
Amazon Elastic File System (Amazon EFS) provides simple, scalable file storage for use with Amazon EC2 instances in the AWS Cloud. Amazon EFS is easy to use and offers a simple interface that allows you to create and configure file systems quickly and easily. With Amazon EFS, storage capacity is elastic, growing and shrinking automatically as you add and remove files, so your applications have the storage they need, when they need it.
What Is Amazon Elastic File System?
Let’s say you want the ability to start new instances to handle a traffic spike on your web application. You have to make sure the new instance will have the updated version of every file created on your web applications and that everything will stay in sync. Ex: images, cache, etc. To do so, you are probably using a solution such as NAS storage or GlusterFS. They both work great but for every new instance, you’ll need to edit your security settings to allow access to the newly created instance. It’s a bother. Not anymore with Amazon EFS.
Amazon allows you to create a EFS instance and mount it on every instance in your security group. The storage space grows without any action from you. No more downtime to allow us to grow our storage space. Amazon also takes care of the reliability of the EFS system.
How to Setup a Highly Available System?
Let’s say you have a website called example.com. It runs on Nginx with MySQL as a database and WordPress for a CMS. Here is how I would set it up to make sure everything is highly reliable. In this example, I am using Amazon products but you could probably get it done with other products such as Google Cloud, DNS Made Easy, etc. You get the idea.
- I setup a Amazon Aurora database server with replication to make sure it is highly available.
- I use Amazon Route 53 to point example.com DNS to my Load Balancer from Amazon. No more DNS failure!
- I create the load balancer who will point toward my target instance group. When I create an instance, I just need to tell the target group to add the new instance and everything is taking care of.
- I create the new instance with the AMI I took from my full customized server. Once this is done, you can easily start new instances with EFS, Nginx, etc already installed on it. You don’t even have to SSH into the new instance. Just start or terminate it and everything will adjust itself.
How to Setup Default AMI Instance for Fast Deployment?
- Launch a new instance with the default Amazon AMI 64 bit. It works great and it’s really reliable.
- Install Nginx, PHP7-FPM
- Mount Amazon EFS partition with /etc/fstab to make sure that when a machine reboot, it automatically mount EFS.
- Store all your website and configuration files in the EFS partition. How I did it: I mounted EFS in the folder “/efs”. In it you can find the “nginx.conf” so that I can manage Nginx server blocks on all my instances at once. The wordpress files and cache also are there so that every new instance has the last versions of the website and that every server stay in sync when changes occur.
- Make sure to setup your primary services such as PHP and Nginx start at boot so that everything will work when starting up. Use a command such as “chkconfig nginx on”
- Create a AMI Image of the instance once it’s completely customized and working. This image will be the default AMI from which you will start new servers from.
Now, when you get a warning of resources getting scarce on your web infrastructure, just launch a new Amazon EC2 instance with the customized AMI with EFS and add it to your load balancer target group. There you go, you can now easily create or terminate EC2 instances to your liking without having to worry about files and database integrity.
In the future, you can even add CloudFront as a CDN to speed things up. Amazon WAF is also a good solution for those of you who want to handle DDoS attack and common vulnerability such as SQL Injection, etc.