5.3
Instance Store: Fast and Ephemeral
Physically attached disks with millions of IOPS, and exactly when their data disappears.
16 min Reading + animations
Tip: tap or hover any dotted-underlined term to see what it means.
By the end of this lesson you will be able to
- Explain what an instance store is and why it is much faster than EBS: local NVMe disks in the host, no network hop, millions of IOPS on storage optimised types.
- Recognise which instance types have one (the
din m6id or c6gd, the I and D families) and explain why its size is fixed and it can never be detached, moved or resized. - Say exactly when instance store data survives (any reboot) and when it is lost (stop, hibernate, terminate, type change, host move, disk failure).
- Protect what you put there: copy out to S3 or EBS, stripe with RAID 0 knowing the risk, and rely on the built-in hardware encryption.
- Pick instance store for caches, buffers, scratch data and replicated datastores, and reject it for the only copy of important data.
- Answer the classic exam questions: highest IOPS for temporary data, data after a reboot, a fast database that must survive stops, and moving storage between instances.
#Why have a disk inside the host at all
Until now every disk in this course has been an EBS volume. An EBS volume is not inside the server your instance runs on. It lives on separate storage servers in the same Availability Zone, and every read and write travels over the AWS network to reach it. That design is what makes EBS so flexible: you can detach a volume, attach it to another instance, snapshot it, resize it, and it keeps its data when the instance stops.
The network hop has a cost, though. Each I/O makes a round trip, and each instance has a cap on how much EBS traffic it can push. For most workloads that does not matter. For a few it matters a lot: a cache that must answer in microseconds, a big data job that shuffles terabytes of temporary files, a NoSQL database doing millions of small random reads.
For those, EC2 offers the instance store: disks that are physically attached to the host computer your instance is running on.
#What an instance store is
An instance store provides temporary block-level storage for an instance. It consists of one or more instance store volumes, each one a real disk (or part of one) in the host machine, exposed to your operating system as a block device.
- Which disks: on current instance types they are NVMe SSDs. The D family and the older H1 use HDDs for cheap, dense capacity. A few very old types (C3, I2, M3, R3, X1) use non-NVMe SSDs.
- How many and how big: fixed by the instance type and size. An
m6id.largegets one 118 GB NVMe SSD; ani8g.48xlargegets twelve 3,750 GB NVMe SSDs (45 TB). You cannot pick another size. - Price: there is no extra charge. The disks are included in the price of the instance.
- When they appear: only at launch. On instance types with NVMe instance store, every volume is attached automatically at launch. On the old non-NVMe types you had to list them in the block device mapping (as
ephemeral0toephemeral23). Either way, you cannot add an instance store volume to an instance that is already running. - State on arrival: raw and empty. Apart from the root volume, nothing is formatted or mounted for you.
#Why it is so fast
| EBS volume | Instance store | |
|---|---|---|
| Where the disk is | Storage servers elsewhere in the AZ | Inside the host your instance runs on |
| Path of every I/O | Instance → AWS network → storage servers and back | Instance → local NVMe disk and back |
| Shared with | The instance’s EBS bandwidth cap (all volumes together) | Nothing; the disks are yours while the instance runs |
| Peak on the largest current types | 240,000 IOPS per instance (i8g.48xlarge, all EBS volumes together) | About 7.2 million random read IOPS and 3.96 million write IOPS (i8g.48xlarge, 12 NVMe disks) |
Some current storage optimised examples, from the EC2 instance type specifications:
| Instance | Instance store | Random read / write IOPS |
|---|---|---|
i4i.32xlarge | 8 × 3,750 GB NVMe SSD (30 TB) | 3.2 million / 1.76 million |
i7i.48xlarge, i8g.48xlarge | 12 × 3,750 GB NVMe SSD (45 TB) | 7.2 million / 3.96 million |
i7ie.48xlarge, i8ge.48xlarge | 16 × 7,500 GB NVMe SSD (120 TB) | 5.2 million / 4.16 million |
d3en.12xlarge | 24 × 13,980 GB NVMe HDD (about 336 TB) | HDD: built for throughput and capacity, not IOPS |
You do not need to memorise these figures. Remember the shape: instance store reaches millions of IOPS on one instance, which EBS cannot, because there is no network in the way and many local disks work in parallel.
EBS over the network, instance store inside the host
Follow one read. Press a tab, then play: the difference is the distance the data has to travel.
Scenario
Instance A asks its EBS volume for a block. The volume is not in this server: it lives on storage servers elsewhere in the AZ.
#Which instance types have it
Not every instance type has an instance store. You can spot the ones that do:
- A
din the family name (lesson 4.1):m5d,m6id,m7gd,c6gd,r6id… Thedmeans “with local NVMe instance store”. The same type without thed(m6i,c6g) is EBS-only. - Storage optimised I family:
i3,i3en,i4i,i4g,i7i,i7ie,i8g,i8ge. Large NVMe SSDs and the highest random IOPS: NoSQL databases, in-memory databases with local persistence, search engines, data warehousing. - Storage optimised D family (and the older H1): many large HDDs for the lowest cost per terabyte of local storage: Hadoop/HDFS data nodes, distributed file systems, log processing.
- Some GPU and accelerated types too (for example
g4dn,g5,p4d), which use the local disks for training data and checkpoints.
Most other types, such as t3, m7i or c7g, have no instance store at all.
#When the data survives and when it is lost
This is the part the exam loves. One rule explains every row: instance store data lives only as long as your instance stays on the same host and that disk keeps working. A reboot keeps the instance on its host. Anything that releases the host erases the disks.
| Event | Instance store data |
|---|---|
Reboot (console, reboot-instances, or sudo reboot in the OS) | Persists |
| AWS scheduled instance reboot or system reboot | Persists |
| Power failure, followed by a reboot | Persists |
| Stop (and later start) | Lost |
| Hibernate | Lost |
| Terminate | Lost |
| Change the instance type (needs a stop) | Lost; the new type brings its own empty disks, if it has any |
| AWS scheduled instance stop or instance retirement | Lost |
| Automatic recovery after a host failure (simplified automatic recovery or a CloudWatch recover action) | Lost; the instance comes back on new hardware with empty disks |
Shutdown from inside the OS (sudo shutdown -h now) | Lost; EC2 treats it as a stop or a terminate (depending on the shutdown behaviour setting), never as a reboot |
| The underlying disk fails | The data on that disk is lost |
| A Spot Instance is interrupted (stopped, hibernated or terminated) | Lost |
What actually happens on a stop: EC2 cryptographically erases every block of the instance store by destroying the disk’s encryption keys, then gives the host back to the pool. When you start the instance it usually lands on a different host, with new, empty, unformatted disks.
What happens to instance store data
One instance with files on its instance store. Pick an event and watch whether the files survive.
Scenario
The instance runs on Host A and keeps 800 GB of cache files on its instance store.
Self-checkQuestion
A user reboots an EC2 instance that keeps temporary files on its instance store. Later the same day, another user stops and starts the instance. What happens to the files?
#Instance store as the root volume
The root volume is the disk the operating system boots from. Almost every instance today boots from an EBS-backed AMI, so its root is an EBS volume. Long ago, AMIs could also be instance store-backed (AWS now calls them Amazon S3-backed AMIs): the root volume was an instance store volume, filled at launch from an image template stored in S3.
| EBS-backed AMI | Instance store-backed (S3-backed) AMI | |
|---|---|---|
| Root volume | EBS volume | Instance store volume (Linux only, at most 10 GB) |
| Can the instance be stopped? | Yes, the root persists in EBS | No: it is only running or terminated |
| Change instance type later | Yes, while stopped | No, attributes are fixed for its life |
| Boot time | Usually under 1 minute | Usually under 5 minutes |
| Status today | The normal choice | End of life; only on old types (C1, C3, D2, I2, M1, M2, M3, R3, X1) |
For the exam, remember one line: an instance whose root is on instance store cannot be stopped, only rebooted or terminated. (It also cannot be hibernated, as lesson 4.5 showed: hibernation needs an encrypted EBS root.) Windows never supported an instance store root.
#Protecting what you put there
#No snapshots: backups are your job
EBS has snapshots, Data Lifecycle Manager and AWS Backup (lesson 5.1). The instance store has none of these. There is no snapshot API for it, and creating an EBS-backed AMI from the instance does not include instance store data.
If anything on it matters, you copy it somewhere durable:
- To S3 (
aws s3 cp,aws s3 sync) for results, checkpoints and backups. - To an EBS volume attached to the same instance, if it must stay block storage.
- To another node, when the application replicates by itself (the database pattern below).
#RAID 0 across instance store volumes
An instance with several instance store disks shows them as separate devices (nvme1n1, nvme2n1…). To use them as one large, fast volume, stripe them together with RAID 0 (mdadm on Linux). Capacity and throughput add up roughly linearly.
RAID 0 has no redundancy: if one disk fails, the whole array is lost, not just one disk’s share. On an instance store that is usually acceptable, because the data was temporary anyway. If you need redundancy, RAID 1 or RAID 10 halves the usable space, and still does not survive a stop.
#Encryption is built in
On NVMe instance store, the data is encrypted at rest with an XTS-AES-256 block cipher in a hardware module on the instance. The keys are generated by that hardware, are unique to each disk, and are destroyed when the instance stops or terminates. You cannot turn this encryption off, and you cannot bring your own key; it involves no KMS key and needs no setting. (EBS encryption with KMS keys is lesson 5.2.)
#Two performance tips
- SSD instance store has no space reserved for the controller’s housekeeping. AWS recommends leaving about 10% unpartitioned on write-heavy volumes, so write speed stays high as the disk fills.
- On types that support it, run
fstrimperiodically so the SSD knows which blocks are free.
Using instance store safely
Instance store arrives as raw disks. You format them, you decide how to combine them, and you decide what to copy somewhere safe.
Scenario
On a Nitro instance with NVMe instance store, the disks are attached automatically at launch. They show up as nvme1n1, nvme2n1… next to the EBS root.
#How it is used in system design
#Good fits
- Cache: a local cache of objects, images, query results or compiled assets. If it is wiped, the application refills it from the source.
- Buffers and queues of work in progress: data that is about to be processed or sent onwards.
- Scratch and temporary data: video rendering frames, intermediate files of big data jobs (Spark shuffle files, temporary output of Hadoop jobs), sort spill files, build directories. The input and the final result live in S3; only the middle steps live on the instance store.
- Replicated datastores: Cassandra, MongoDB replica sets, Kafka, Elasticsearch, HDFS. The application keeps several copies of every piece of data on different instances (ideally in different racks or AZs, lesson 4.5). When one node’s instance store is lost, the cluster keeps serving from the other copies and rebuilds the lost one on a new node. You get instance store speed, and durability comes from the cluster.
- Fleets of identical servers: for example web servers behind a load balancer that each keep a copy of the same static content, pulled from S3 at boot.
#The anti-pattern
Putting the only copy of anything important on an instance store: the single database server, uploaded user files, the only log of financial transactions. Sooner or later a stop, a type change, a host failure or a Spot interruption will erase it, and there is no snapshot to restore from.
A cluster that keeps copies vs one lonely database
Both designs use instance store for speed. Only one of them survives losing a node.
Scenario
A 3-node Cassandra cluster, one node per AZ, each storing its data on local NVMe instance store. Replication factor 3: every row lives on all three nodes.
#Instance store or EBS for a fast database?
| Instance store | EBS (io2 Block Express for top performance) | |
|---|---|---|
| Survives stop and start | No | Yes |
| Survives host or disk failure | No (unless the application replicates) | Yes; EBS replicates inside the AZ |
| Snapshots and backups | None; your job | Snapshots, Data Lifecycle Manager, AWS Backup |
| Detach and attach to another instance | Never | Yes, within the AZ |
| Size | Fixed by instance type | Chosen and changeable (up to 64 TiB) |
| Performance | Highest: millions of IOPS per instance, lowest latency | Very high: up to 256,000 IOPS per io2 Block Express volume, sub-millisecond latency, capped per instance |
| Cost | Included in the instance price | Billed per GB (and per provisioned IOPS) |
So the decision is simple:
- A single high-performance database whose data must survive stops and starts → EBS Provisioned IOPS (io2 Block Express; io1 on older designs), however strongly the question stresses performance.
- A distributed database that replicates across nodes and needs the absolute maximum IOPS → instance store is a valid, common choice.
- Temporary data that needs extreme speed (cache, scratch) → instance store. For cheap, large, sequential data such as logs and data warehouses, the EBS answer is st1 (lesson 5.2).
The full three-way decision between EBS, EFS and instance store is in lesson 5.4.
#Try it yourself
# 1. Which instance types have an instance store, how big, SSD or HDD?
aws ec2 describe-instance-types \
--filters Name=instance-storage-supported,Values=true \
--query "InstanceTypes[].[InstanceType,InstanceStorageInfo.TotalSizeInGB,InstanceStorageInfo.Disks[0].Count,InstanceStorageInfo.Disks[0].Type]" \
--output table
# Only the NVMe SSD ones, for one family
aws ec2 describe-instance-types \
--filters Name=instance-storage-supported,Values=true Name=instance-storage-info.disk.type,Values=ssd \
Name=instance-type,Values="i8g.*" \
--query "InstanceTypes[].[InstanceType,InstanceStorageInfo.TotalSizeInGB,InstanceStorageInfo.EncryptionSupport]" \
--output table
# 2. Launch one with a small instance store (m6id.large: 1 x 118 GB NVMe SSD)
aws ec2 run-instances --image-id $AL2023_AMI --instance-type m6id.large --subnet-id $SUBNET_A
# 3. On the instance: find the disks. The instance store shows the model
# "Amazon EC2 NVMe Instance Storage"; the root is "Amazon Elastic Block Store".
lsblk -o NAME,SIZE,TYPE,MOUNTPOINT,MODEL
# 4. Format and mount (the disk arrives raw)
sudo mkfs.xfs -K /dev/nvme1n1 # -K skips the slow discard on a fresh disk
sudo mkdir -p /scratch
sudo mount /dev/nvme1n1 /scratch
df -h /scratch
# In /etc/fstab use "nofail", or mount from a boot script: after a stop and start the disk is blank again.
# 5. Prove the lifecycle
echo "hello" | sudo tee /scratch/test.txt
sudo reboot # reconnect, mount again: test.txt is still there
# aws ec2 stop-instances / start-instances → /dev/nvme1n1 is empty and unformatted again
# 6. RAID 0 across several instance store disks (on an i4i.8xlarge: 2 x 3,750 GB)
sudo mdadm --create /dev/md0 --level=0 --raid-devices=2 /dev/nvme1n1 /dev/nvme2n1
sudo mkfs.xfs -K /dev/md0
sudo mkdir -p /data && sudo mount /dev/md0 /data
cat /proc/mdstat # one disk failing = the whole array is lost
# 7. Back up what matters: instance store has no snapshots
aws s3 sync /data/results s3://my-results-bucket/run-42/
sudo fstrim -v /data # tell the SSDs which blocks are free
#Summary
Key takeaways
- An instance store is block storage on disks physically attached to the host your instance runs on: NVMe SSDs on current types, HDDs on the D family and H1. It is included in the instance price.
- It is the fastest storage on EC2: no network hop, many local disks in parallel, millions of IOPS on storage optimised types (about 7.2 million random read IOPS on an i8g.48xlarge, against 240,000 IOPS from EBS for the same instance).
- It comes only with certain types: a
din the name (m6id, c6gd, r6id), the I and D families. Size and number of disks are fixed by the type; it is available only at launch and can never be detached, moved or resized. - Data survives any reboot (yours, AWS scheduled, after a power failure). It is lost on stop, hibernate, terminate, instance type change, retirement, automatic recovery to a new host, OS shutdown and disk failure.
- An instance with its root on instance store (an S3-backed AMI, end of life) cannot be stopped.
- No snapshots: copy anything valuable to S3 or EBS yourself. RAID 0 joins disks for speed but loses everything if one disk fails. Data is encrypted at rest by hardware (XTS-AES-256), always on, keys destroyed at stop.
- Use it for cache, buffers, scratch and temporary data, and replicated datastores (Cassandra, MongoDB, Kafka, HDFS). Never for the only copy of important data.
- A high-performance database that must survive stops → EBS io2. Moving storage between instances → EBS.
Answer on your own first, then read the explanation, even when you got it right.
Self-checkQuestion
Where are the disks of an EC2 instance store?
Self-checkQuestion
An instance with an instance store is rebooted with the reboot-instances command. What happens to the data on the instance store?
Self-checkQuestion
Which of these events keeps the data on an instance store volume?
Self-checkQuestion
A team wants a general purpose instance that includes a local NVMe instance store. Which instance type should they choose?
Self-checkQuestion
Which two events cause the data on an instance store volume to be lost?
Choose 2
Self-checkQuestion
A gaming company needs a temporary session cache with the highest possible IOPS and the lowest latency. If the cache is lost, it is rebuilt from the database. What storage should the cache use?
Self-checkQuestion
A single high-performance relational database runs on EC2. Its data must survive when the instance is stopped and started for maintenance. Which storage should hold the database files?
Self-checkQuestion
A company wants to decouple storage from compute so that a data volume can be detached from a failing instance and attached to a replacement. What should it use?
Self-checkQuestion
An application on an i4i.large is running out of space on its instance store. What can the team do?
Self-checkQuestion
An engineer tries to protect the files on an instance store by taking an EBS snapshot of it. What happens?
Self-checkQuestion
How is data on an NVMe instance store volume protected at rest?
Self-checkQuestion
Which two statements about instance store are true?
Choose 2
Self-checkQuestion
A Cassandra cluster of three i4i nodes, one per AZ, stores data on instance store with a replication factor of 3. The host under one node fails. What happens?
Self-checkQuestion
A startup runs its only PostgreSQL server on an i4i instance and keeps the database files on instance store because benchmarks were excellent. What is the biggest risk?
Self-checkQuestion
An instance runs on an m6id.large and keeps files on its instance store. The team changes the instance type to m6id.xlarge. What happens to the files?
Self-checkQuestion
An instance’s host fails, and EC2 automatic recovery brings the instance back on new hardware. Which statement is true?
Self-checkQuestion
An i4i.8xlarge has two NVMe instance store disks combined into one RAID 0 array. One disk fails. What is the result?
Self-checkQuestion
Which two workloads are good uses of instance store?
Choose 2
Self-checkQuestion
An older Linux instance was launched from an Amazon S3-backed (instance store-backed) AMI, so its root volume is on instance store. An admin wants to stop it over the weekend to save money. What is possible?
Self-checkQuestion
A batch job on a Spot Instance keeps six hours of intermediate results only on instance store. The Spot Instance is interrupted. What should the team change?
Self-checkQuestion
Which two events does AWS list as causing instance store data NOT to persist?
Choose 2
Self-checkQuestion
A big data job on a fleet of EC2 instances writes huge intermediate files that need extreme speed and are useless once the job ends. Which storage fits these files best?
Self-checkQuestion
Which statement about instance store is NOT true?
Self-checkQuestion
Study notes say: ‘An OS reboot keeps instance store data, but if AWS reboots the instance for maintenance, the data is lost.’ What is the accurate version?
Self-checkQuestion
An i8g.48xlarge reaches about 7.2 million random read IOPS from its instance store, while the same instance can push at most 240,000 IOPS to all its EBS volumes together. Roughly how many times more read IOPS does the instance store give?
Self-checkQuestion
Which two reasons explain why instance store is faster than EBS?
Choose 2
Self-checkQuestion
An admin runs sudo shutdown -h now inside an instance that has data on its instance store. The instance’s shutdown behaviour is set to stop. What happens to the instance store data?
Self-checkQuestion
A team creates an EBS-backed AMI from an instance whose instance store holds a prepared data set, then launches new instances from that AMI. What do the new instances find on their instance store?
Self-checkQuestion
A Hadoop cluster needs hundreds of terabytes of local storage per node at the lowest cost per terabyte, mostly for large sequential reads. Which instance family is built for this?
Self-checkQuestion
Twenty web servers behind a load balancer each download the same static assets from S3 at boot and serve them from instance store. The host under one server fails. What is the impact?