One of the client had a requirement to auto scale their existing web infrastructure. Initially we created Target group without a shared folder for cakephp/tmp and logs but then later on we felt the need to implement this as some of the functionality required to have such setup.
We considered using various methods such as NFS, S3 etc but decided to use AWS EFS just because it is *scalable* and capacity can be scaled up and down on demand which eliminates forecasting.
This is the basic diagram for the setup.
In order for you to go about creating this setup, first go ahead and login to your console. In case, if you have trouble remembering your company’s AWS URL, I use http://awsiamlogin.com to get to that URL.
Once you are logged in, search for EFS.
Click on Create file system.
It automatically selects the default VPC and auto select all AZs with default security group. You can make any changes here if you prefer. But for this example, we will just use the default.
Name it appropriately.
You can choose lifecycle policy to archive files which are less used which could save you some money.
Remaining performance modes, we left it as is due to the nature of our application. But you can decide based on the workload of your usage and change this accordingly.
Click Create File System
It takes few minutes to create EFS in all AZs.
Click refresh after few minutes and it should have the all the mount targets available.
Once they are available, click on mount instruction for local VPC.
It will show you all the prereq that you must to in order to mount this file system on the Linux server. Since we are on Amazon Linux, we will be mounting as EFS file system.
You will have to run below command on your Linux host.
yum install -y amazon-efs-utils
sudo chown -R apache:apache /var/www/cakephp/tmp/ /var/www/cakephp/logs/
sudo mount -t efs fs-ddb3ee3d:/ /var/www/cakephp/tmp/
sudo mount -t efs fs-8a78af68:/ /var/www/cakephp/logs
This should mount filesystem on your Linux.
If you want to auto mount on the reboot, You will have to add this entry in /etc/fstab.
Once all the setup is complete. Create an AMI of this machine then a Launch template, which can be used for the Target group for the Autoscaling(Auto Scale) of this application.
Any questions , please reach out.