# EFS

[Life cycle management](https://docs.aws.amazon.com/efs/latest/ug/lifecycle-management-efs.html) |

## Overview

## Benefits

* **Scalability**: automatically **grows** and **shrinks** as we add and remove files.
  * Can support over 10GB/sec, >500,000 IOPS
* **Reliability**:&#x20;
  * SLA \~ 11 9s durability. Just the same amount of 9s like S3.
  * Every EFS object is redundantly stored across multiple AZ.
  * Quickly detecting and repairing any lost redundancy.
* Integration well with thousands of EC2 instances. EC2 instances can use EFS for <mark style="background-color:blue;">parallel</mark> shared access.&#x20;
* Access data across AZs

<figure><img src="https://2259236002-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fuh9xZDZ53qGqmMCM44PU%2Fuploads%2FJkmxiiMRdeQCSHN1zMEe%2Fimage.png?alt=media&#x26;token=b8e5a9ff-02ba-460b-83eb-bd56dc15b0c7" alt=""><figcaption><p>using Direct Connect or VPN</p></figcaption></figure>

## Features

### EFS Mount point

A mount point in AWS Elastic File System (EFS) connects the EFS file system to EC2 instances or on-premises servers, allowing file system interaction. It uses the NFSv4 protocol for secure and seamless file operations.

**Key Steps:**

1. **Create Mount Target:** Set up a mount target in each Availability Zone where EC2 instances need EFS access.
2. **Security Groups:** Assign security groups to mount targets to control access, allowing NFS connections from EC2 instances.
3. **Mounting:** Use the `mount` command with the EFS DNS name on EC2 instances. For persistent access, add the mount command to the `/etc/fstab` file.
4. **Performance:** Consider mount options and network performance between EC2 instances and EFS mount targets to optimize file operations.

Correctly configured mount points enable the use of EFS’s scalable and durable shared file storage.

* Provide a serverless, **set-and-forget** elastic NFSv4 (**N**etwork **Fi**le **S**ystem) File System service.
  * Traditional hierarchial directory structure
  * Trandional file permissions
  * File locking
* For cost down, consider using:
  * EFS-IA
  * EFS One Zone-IA

### Application specific directory & permission

* Using EFS access points for restrict access to File system, or specific directory.
* Using AWS IAM policy to ensure specific app only access specific EFS Access Point.

### Storage classes

<figure><img src="https://2259236002-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fuh9xZDZ53qGqmMCM44PU%2Fuploads%2FDSBP6IZgP3A8YnSIetJ6%2Fimage.png?alt=media&#x26;token=b4d5d170-63f8-4edf-98bc-9530fe57ffc0" alt=""><figcaption><p>EFS storage classes</p></figcaption></figure>

There are 4 storage classes in EFS

1. Standard storage class: for frequently accessed files.
2. EFS IA (Infrequent Access) storage class
3. EFS One Zone
4. EFS One Zone-IA

* Lower cost storage class.
* Turn on **EFS Lifecycle management** to using this storage class.
  * When files have not been access for a <mark style="color:red;">**period**</mark> of time -> go to IA storage class
  * Using Lifecycle policy to define that <mark style="color:red;">**period**</mark> (1, 7, 14, 30, 60, 90 days). Maximum is 90 days.

### Performance modes

<table><thead><tr><th width="174.33333333333331"></th><th width="274">General purpose</th><th>Max I/O</th></tr></thead><tbody><tr><td>latency</td><td>Lowest</td><td>-</td></tr><tr><td>throughput</td><td>-</td><td>Higher</td></tr></tbody></table>

### Throughput modes

<table><thead><tr><th width="175"></th><th width="299.3333333333333">Bursting</th><th>Provisioned</th></tr></thead><tbody><tr><td>throughput</td><td>dynamically scale depend on Size</td><td>Higher dedicated throughput</td></tr><tr><td>config</td><td>can not</td><td>can be configured independently</td></tr></tbody></table>

### Containers and serverless file storage

* Serverless architecture do not have server (no EBS), so it needs a Shared storage service to handle IOPS-heavy workload or Latency-sensitive workload.
* Allow container services like: ECS, EKS, Fargate, Lambda to handle <mark style="background-color:orange;">stateful</mark> workloads.

## Security

### Encryption

* Data at rest using encryption keys managed by KMS.
* Data at transit using Transport Layer Security (TLS)

## Trivia

* <mark style="color:red;">Amazon EFS is NOT supported on Windows instances.</mark> Only for **Linux** (POSIX). Amazon [FSx](https://mamawhocode.gitbook.io/aws/services/storage/fsx) is a specific service used for Windows File Server.
  * FSx --> shared Windows file system（SMB）&#x20;
  * EFS --> Linux NFS
