EC2 Instance Storage : Elastic File System (EFS)
In series of EC2 Instance Storage , here’s a third type of storage we can attach to an EC2 instance. This is a network file system or NFS.
What is EFS ?
- EFS stands for Elastic File System and it is a managed network file system.
- It can be mounted to hundreds of EC2 instances at a time.
- EFS works only with Linux EC2 instances.
- It works across multiple availability zones.
- We can attach EFS volume in one AZ (Availability Zone) with instance in another AZ.
- EFS is highly available, scalable, pretty expensive. It’s about three times the price of a EBS volume, but you pay per use and you don’t plan for capacity.
An EBS volume can be attached to only one EC2 instance at a time. But an EFS drive, can be attached to hundreds of EC2 instances. So, that makes it a shared network file system or shared NFS.
EBS vs EFS
So, if we look at the diagram, We have an EFS file system with a security group, connected to EC2 instances in various availability zones and on other hand we have EBS volume in one availability zone.
So now, let’s outline the exact differences between EBS and EFS.
If we wanted to move over the EBS volume from one AZ to another, we could create a snapshot, it would create an EBS snapshot and then restore that snapshot into a new availability zone. But this is a copy, this is not an in-sync replica, and that would mean that this drive can now be used by another EC2 instance.
On other hand, EFS is a network file system. That means , whatever is on the EFS drive is shared by everything that is mounted to it.
EFS Storage Class : EFS-IA (Infrequent Access)
EFS storage class is going to be cost-optimized for files that you don’t access very often. This storage class will give you upto 92% lower cost for storing the data compared to the other surge class, which is called EFS standard. And if you enable EFS-IA, then EFS will automatically move your files to a storage class based on the last times they were accessed.
So, let’s take an example. We have our EFS file system. We have three files in EFS standard and maybe a fourth file in EFS standard. This one hasn’t been accessed for 60 days, that means that no one has read this file and no one has been writing to this file either, right? So, if you define your lifecycle policy and you enable EFS-IA, then for example, you can say, hey, after 60 days, please move this file to a different storage class which is called EFS-IA, which is going to have some cost saving. And this is going to be done automatically. Now, next time you access this file, it’s going to be put back into EFS standard because it’s more accessed more often.
Yes, That is it for the EFS. I hope you enjoyed this reading. See you in next article. Happy Learning !!