๐ AWS CCP - Day-22 - Unlock Scalability and Savings with Amazon EFS ๐
Introduction to EFS ๐ก
Here's a third type of storage you can attach onto your EC2 instance. And this is a network file system or NFS. So, EFS stands for Elastic File System and it is a managed network file system. And the idea and the benefits of it is that it can be mounted to hundreds of EC2 instances at a time. So, before you had an EBS volume attached to only one EC2 instance at a time. But with an EFS drive, you can mount it onto hundreds of EC2 instances. So, that makes it a shared network file system or shared NFS. ๐ป
Key Features of EFS ๐
So, EFS works only with your Linux EC2 instances. And on top of it, it works across multiple availability zones. So, it is possible for an instance in one AZ to be attaching the same EFS volume as the instance in another AZ. Now, EFS is highly available, scalable, pretty expensive. It's about three times the price of a gp2 EBS volume, but you pay per use and you don't plan for capacity. So, that means that if you store 20 gigabytes of data onto your EFS drive then you're only going to pay for these 20 gigabytes. โ๏ธ
Usage and Architecture ๐
+-----------------------------------------------------------+
| EFS File System |
| +-----------------------------------------------+ |
| | Security Group | |
| +-----------------------------------------------+ |
| |
| +----------------+ +----------------+ +--------------+ |
| | EC2 Instance | | EC2 Instance | | EC2 Instance | |
| | (us-east-1a) | | (us-east-1b) | | (us-east-1c) | |
| +----------------+ +----------------+ +--------------+ |
| |
+-----------------------------------------------------------+
You have an EFS file system with a security group, and then you have EC2 instances in various availability zones connected to it. So, you have EC2 instances in us-east-1a, EC2 instances in us-east-1b, as well as EC2 instances in us-east-1c. And they're all connected to the same EFS File system. ๐๏ธ
Comparison with EBS ๐
Feature | EBS | EFS | EFS Standard | EFS (IA) |
Storage Type | Block storage | File storage | File storage | File storage |
Storage Classes | Provisioned IOPS SSD, General Purpose SSD, Throughput Optimized HDD, Cold HDD | Standard Storage, Infrequent Access (IA) | Standard | Infrequent Access (IA) |
Compatibility | Attached to a single EC2 instance | Shared among multiple EC2 instances | Shared among multiple EC2 instances | Shared among multiple EC2 instances |
Durability | Highly durable | Highly durable | Highly durable | Highly durable |
Availability | Availability limited to the specific Availability Zone (AZ) | Availability across multiple AZs | Availability across multiple AZs | Availability across multiple AZs |
Performance | High IOPS, low-latency | Good for throughput, moderate latency | Good for throughput, moderate latency | Good for throughput, moderate latency |
Use Cases | Databases, boot volumes, low-latency applications | Shared data across multiple instances, content repositories, web serving | General-purpose file storage, content management | Workloads with infrequently accessed data, cost-sensitive workloads |
Access Control | Controlled via IAM permissions | Supports POSIX permissions | Supports POSIX permissions | Supports POSIX permissions |
Lifecycle Management | Not applicable | Not applicable | Not applicable | Supports lifecycle management policies |
Cost | Pay for provisioned storage and IOPS | Pay for storage usage | Pay for storage usage | Pay for storage usage |
Use Case Example | Running a database requiring high IOPS | Shared document storage for development team | Storing web application files | Storing logs or backups |
Now, let's outline the exact differences between EBS and EFS. So, with EBS, say you had EC2 instance in one AZ and another one. Then the EBS volume can only be attached to one instance in one specific AZ. And the EBS volumes are bound to specific availability zones. But if you wanted to move over the EBS volume from one AZ to another, you could create a snapshot, it would create an EBS snapshot and then restore that snapshot into a new availability zone. And effectively you would've moved the EBS volume over. But this is a copy, this is not an in-sync replica. This is a copy, and that would mean that this drive can now be used by another EC2 instance. ๐
EFS as a Shared File System ๐
EFS is a network file system. That means that whatever is on the EFS drive is shared by everything that is mounted to it. So, what does that mean? Say you have many instances in Availability Zone 1 on one or many instances as well on Availability Zone 2. At the same time, all these instances can mount the same EFS drive, using a mount target, and they will all see the same files. So, that makes it a shared file system. ๐
Cost Optimization with EFS-IA ๐ฐ
Hopefully that makes it a very easy way to understand the difference between EBS and EFS. And this is something that the exam will test you on. There is a storage class you need to know for EFS and it's called EFS infrequent access or EFS-IA. So, storage class is going to be cost-optimized for files that you don't access very often. So, for example, you don't access these files every day. And this storage class will give you up to 92% lower cost for storing the data compared to the other storage class, which is called EFS standard. And if you enable EFS-IA, then EFS will automatically move your files to EFS-IA, based on the last times they were accessed and something called a lifecycle policy. ๐ก
Lifecycle Policy and File Movement ๐
So, let's take an example. You have your EFS file system. You 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. So, the idea is that this is a cost-saving optimization. ๐
Seamless Integration with Applications ๐
And from an application perspective, there is really no drawbacks. It's very transparent to the applications, that means that your applications don't even need to know where the file is if it's an EFS standard, or EFS-IA, it will access all these files the same way. It's just behind the scenes, EFS will do some cost optimizations. ๐
Day-22 Finished ๐
Today you have learned about Amazon EFS and its types. ๐ก