๐ŸŒŸ AWS CCP - Day-22 - Unlock Scalability and Savings with Amazon EFS ๐ŸŒŸ

๐ŸŒŸ AWS CCP - Day-22 - Unlock Scalability and Savings with Amazon EFS ๐ŸŒŸ

ยท

6 min read

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 ๐Ÿ”„

FeatureEBSEFSEFS StandardEFS (IA)
Storage TypeBlock storageFile storageFile storageFile storage
Storage ClassesProvisioned IOPS SSD, General Purpose SSD, Throughput Optimized HDD, Cold HDDStandard Storage, Infrequent Access (IA)StandardInfrequent Access (IA)
CompatibilityAttached to a single EC2 instanceShared among multiple EC2 instancesShared among multiple EC2 instancesShared among multiple EC2 instances
DurabilityHighly durableHighly durableHighly durableHighly durable
AvailabilityAvailability limited to the specific Availability Zone (AZ)Availability across multiple AZsAvailability across multiple AZsAvailability across multiple AZs
PerformanceHigh IOPS, low-latencyGood for throughput, moderate latencyGood for throughput, moderate latencyGood for throughput, moderate latency
Use CasesDatabases, boot volumes, low-latency applicationsShared data across multiple instances, content repositories, web servingGeneral-purpose file storage, content managementWorkloads with infrequently accessed data, cost-sensitive workloads
Access ControlControlled via IAM permissionsSupports POSIX permissionsSupports POSIX permissionsSupports POSIX permissions
Lifecycle ManagementNot applicableNot applicableNot applicableSupports lifecycle management policies
CostPay for provisioned storage and IOPSPay for storage usagePay for storage usagePay for storage usage
Use Case ExampleRunning a database requiring high IOPSShared document storage for development teamStoring web application filesStoring 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. ๐Ÿ’ก

ย