Amazon EFS
共有フォルダ(NFS)
マネージド NFS ファイルシステムで、複数の AZ にある多数の EC2/コンテナから同時に mount でき、容量は自動で拡張されます。
- コスト$$ ふつう
- 難易度●●●●●
- 未使用でも課金?少し
- サーバーレス
- 出題試験SAA · SOA
たとえるならオフィスの共有ネットワークドライブのようなものです。誰でも同じフォルダを開けます。
EFS はシステムのどこにある?
EFS を呼び出す
具体例でステップごとに
- WordPress サイトがロードバランサーの後ろで EC2 4 台で動いていて、誰かが画像を投稿したら 4 台すべてで表示される必要があります。
- VPC 内に EFS ファイルシステムを作成し、各 AZ にマウントターゲットを置きます。
- 4 台すべてが wp-content/uploads に EFS をマウントするので、1 台にアップロードした画像はすぐに他の台からも見えます。
- 容量は画像の数に合わせて自動で増えるので、事前にサイズを決める必要はありません。
- ライフサイクル管理で、30 日間見られていない画像を低頻度アクセスクラスに移し、保存料金を下げます。
いつ使う?
✓ 使うべき場面
複数のマシンが共通のファイルを読み書きする必要がある場合(CMS、ユーザーフォルダ)。
✗ 避けるべき場面
1 台だけで使い、高い IOPS が必要 → EBS、Windows マシン → FSx。
よくある使い方
- 複数の EC2/コンテナで共有するフォルダ(CMS、WordPress)
- ECS/EKS コンテナと Lambda 向けの永続ストレージ
- ユーザーのホームディレクトリ、共有 ML データ
EFS・EBS・S3 の違い
料金はいくら?
- 課金方式: 実使用の GB 月単位(Standard 約 $0.30/GB、Infrequent Access クラスはずっと安い)+ スループットモードに応じた読み書き料金。
- 無料枠: わずかです。
アクセス頻度の低いデータでは S3 の約 13 倍高い。lifecycle の有効化忘れ。誤って Provisioned Throughput を選択する。
「多数の Linux インスタンスで 1 つのフォルダを共有し、自動で同期したい」なら EFS です。Windows マシンで共有フォルダが必要なら FSx for Windows File Server です。めったに使わないデータは EFS 低頻度アクセスへのライフサイクルを設定します。
本番の試験問題に挑戦
1A company wants to move its on-premises network attached storage (NAS) to AWS. The company wants to make the data available to any Linux instances within its VPC and ensure changes are automatically synchronized across all instances accessing the data store. The majority of the data is accessed very rarely, and some files are accessed by multiple users at the same time. Which solution meets these requirements and is MOST cost-effective?
- ACreate an Amazon Elastic Block Store (Amazon EBS) snapshot containing the data. Share it with users within the VPC.
- BCreate an Amazon S3 bucket that has a lifecycle policy set to transition the data to S3 Standard-Infrequent Access (S3 Standard-IA) after the appropriate number of days.
- CCreate an Amazon Elastic File System (Amazon EFS) file system within the VPC. Set the throughput mode to Provisioned and to the required amount of IOPS to support concurrent usage.
- DCreate an Amazon Elastic File System (Amazon EFS) file system within the VPC. Set the lifecycle policy to transition the data to EFS Infrequent Access (EFS IA) after the appropriate number of days.
答えを見る
正解: D
EFS は複数の Linux マシンで使える NFS の共有フォルダで、変更はすべてのマシンにすぐ反映されます。EFS 低頻度アクセスへのライフサイクルポリシーを設定すれば、あまり使わないファイルを最も安く保存できます。プロビジョンドスループットは費用が増えるだけで、S3 は共有ファイルシステムではありません。
2A company is building a web application that serves a content management system. The content management system runs on Amazon EC2 instances behind an Application Load Balancer (ALB). The EC2 instances run in an Auto Scaling group across multiple Availability Zones. Users are constantly adding and updating files, blogs, and other website assets in the content management system. A solutions architect must implement a solution in which all the EC2 instances share up-to-date website content with the least possible lag time. Which solution meets these requirements?
- AUpdate the EC2 user data in the Auto Scaling group lifecycle policy to copy the website assets from the EC2 instance that was launched most recently. Configure the ALB to make changes to the website assets only in the newest EC2 instance.
- BCopy the website assets to an Amazon Elastic File System (Amazon EFS) file system. Configure each EC2 instance to mount the EFS file system locally. Configure the website hosting application to reference the website assets that are stored in the EFS file system.
- CCopy the website assets to an Amazon S3 bucket. Ensure that each EC2 instance downloads the website assets from the S3 bucket to the attached Amazon Elastic Block Store (Amazon EBS) volume. Run the S3 sync command once each hour to keep files up to date.
- DRestore an Amazon Elastic Block Store (Amazon EBS) snapshot with the website assets. Attach the EBS snapshot as a secondary EBS volume when a new EC2 instance is launched. Configure the website hosting application to reference the website assets that are stored in the secondary EBS volume.
答えを見る
正解: B
すべての EC2 インスタンスが同じ EFS をマウントするので、新しいコンテンツがすぐに見えます。1 時間ごとの S3 同期や EBS スナップショットでは遅れが出て、内容がずれることがあります。
よくある質問
Windows から EFS を使えますか?
使えません。EFS は Linux 向けの NFS プロトコルを使います。Windows マシンで SMB による共有フォルダが必要な場合は、Amazon FSx for Windows File Server を使います。
EFS の料金はどのように決まりますか?
月ごとに実際に保存しているデータ量に応じて課金され、事前のプロビジョニングは不要です。ライフサイクル管理を有効にすると、あまり使わないファイルをより安い低頻度アクセスやアーカイブのクラスへ自動で移動できます。
AWS 認定試験では EFS について何が問われますか?
複数のインスタンスやコンテナが同じフォルダを共有する場面、EFS、EBS、FSx の選択、低頻度アクセスのストレージクラスを使ったコスト削減などです。