There are multiple EC2 storage options for storing data files.
1. AWS EBS Drives
AWS EBS drives are designed for being a root drive for an operating system and for long term durable storage of data.
AWS EBS drives are placed in a specific Availability Zone and are automatically replicated to prevent a failure of a single component.
Some AWS EBS drives can be shared among a number of instances.
Each launched EC2 instance is accompanied by one or more new AWS EBS drives which are, by default, deleted once the EC2 instance gets terminated. To prevent the EBS drive from being deleted change the “Delete on termination” to No or change the attribute DeleteOnTermination using the AWS CLI.
2. AWS EC2 Instance Store
Some high performance EC2 instance types (e.g. c5ad, c5d, c6gd, d2, d3, d3en, f1, g4ad) are provided with EC2 instance store, a temporary block-level storage physically attached to the host computer designed for temporary EC2 storage of frequently accessed information, such as caches, buffers.
The data on the EC2 instance store is lost when the instance stops / hibernates / terminates. On reboot, the instance store storage remains intact.
The data is also lost when the underlying disk fails, i.e. the data is not replicated like with regular EBS drives.
An EC2 Instance Store cannot be shared among multiple EC2 instances.
3. AWS EFS
AWS EFS is designed for Linux based operating systems and provides a file system which automatically grows or shrinks as you add or remove files.
It can be attached to multiple EC2 instance types or Lambda functions and provides a high-performance, high-availability and high-durability option for storing files.
The service offers multiple EC2 storage classes with different prices and different reliability profiles:
- Standard Storage @ $0.3 per GB-month
- Standard – Infrequent Access @ $0.025 per GB-month + $0.01 per GB transferred
- One Zone @ $0.16 per GB-month
- One Zone – Infrequent Access @ $0.01 per GB-month + $0.01 per GB transferred
4. Amazon FSx
Amazon FSx is a high-performance file system supporting these file systems: NetApp ONTAP, OpenZFS, Windows File Server and Lustre.
It provides a high-availability and high-durability option for storing files.
Unlike other options, it offers file deduplication and file compression which is estimated to save about 50% of the file storage costs. Thus, it is difficult to directly compare the pricing between EFS and FSx – it depends on the specific use case.
5. Amazon S3
In addition to the above file system based storage options, AWS offers Amazon S3 – an object storage managed service.
It provides a high-availability and high-durability option for storing files.
S3 offers multiple storage classes with different availability, durability and pricing. The S3 Glacier Deep Archive is the cheapest storage option available in AWS.
Unlike file system based storage options;
- an object storage does not allow append data to a file – the entire object has to be updated
- an object storage does not provide a tree directory storage – all files are stored in a flat one-level hierarchy though directories are can be emulated by adding a prefix
- an object storage is substantially cheaper
- an object storage’s first access to an object can have higher latency than the first access to any file system based file