Sub topic 2
EBS versus instance store, EFS and S3
This chapter assumes you know what an EC2 instance and an Availability Zone (AZ) are, and that you have used a Linux shell. It compares the four storage services you will most often choose between for EC2 workloads. It does not cover EBS internals, which later chapters do.
The four options in one view
Amazon EBS is network-attached block storage. The instance sees a raw disk, formats it with a file system, and mounts it. The volume lives in one AZ and exists independently of the instance. You can detach it, and you can snapshot it.
Instance store is block storage on disks physically attached to the host computer. It has low latency and no separate charge, because it is included in the price of instances that offer it. Its data is temporary.
Amazon EFS is a managed network file system that speaks NFS. Many instances mount it at the same time, across AZs in a Region. It grows and shrinks as you add and remove files.
Amazon S3 is object storage. You read and write whole objects by key through an HTTP API. It is not a disk, and you do not format or mount it like one.
| Property | EBS | Instance store | EFS | S3 |
|---|---|---|---|---|
| Storage type | Block | Block | File (NFS) | Object |
| Scope | One AZ | One host | Region, multi-AZ | Region |
| Survives stop or terminate | Yes, if the volume is kept | No | Yes | Yes |
| Concurrent clients | One instance (Multi-Attach is an exception) | One instance | Thousands | Unlimited |
| Capacity | You provision a size | Fixed by instance type | Elastic | Unlimited |
What "ephemeral" means for instance store
Instance store data survives a reboot. It is lost when the instance stops, hibernates or terminates, or when the underlying drive fails. Use it for data you can rebuild: caches, scratch space, buffers, or data replicated elsewhere. Do not keep the only copy of anything there.
EBS data persists after you stop the instance. A non-root volume also persists after termination. A root volume is deleted at termination by default, a behavior a later chapter covers.
Choosing between them
Common errors come from misjudging one of these boundaries:
- Putting a database on instance store without replication. A stop or host failure erases it.
- Expecting an EBS volume to attach across AZs. It cannot. Use a snapshot to create a copy in another AZ.
- Using EBS to share files between many instances. EBS is a single-instance disk, so use EFS.
- Treating S3 as a file system for software that needs POSIX semantics, such as in-place edits or file locks.
Exercise
A fleet of web servers in three AZs must read and write the same upload directory as ordinary files. Which service fits, and why do EBS and S3 fit worse?
Show answer
EFS. It is an NFS file system that instances in every AZ of the Region mount at once. EBS is limited to one AZ and normally one instance, so it cannot be shared. S3 is accessed by object API rather than as a mounted POSIX file system.