AWS S3 Storage Classes
Tags: aws, s3, cloud, design
Published: 2023-03-02 16:28:06

## Introduction
S3 storage classes are often overlooked by developers but this is quite interesting topic to learn.

I have been assigned a task that I have to archive the historical data from database. For that I have to use the glacier but then I started learning about glacier but the issue with using glacier was that we couldn't use AWS athena on Glacier. 

Then there were storage classes supported in S3 which was fulfilling the both the use cases which has less cost for storage and AWS athena is also supported. Note, before using athena, we need to restore the data in S3 if using Glacier storage class.

## Storage Classes

Amazon S3 offers different storage classes to meet various use cases and cost requirements. Each storage class has unique features that make it appropriate for specific scenarios.
Here are the characteristics of different S3 storage classes:
1. **S3 Standard:** S3 Standard is best for data that is regularly accessed and needs high durability, availability, and performance. It offers fast access and is suitable for applications like big data analytics, mobile and gaming apps, content delivery, and backup and recovery. Data is stored in multiple locations to ensure availability and durability.
2. **S3 Intelligent-Tiering:** S3 Intelligent-Tiering is suitable for data with unknown or changing access patterns. It uses machine learning to automatically move data between two access tiers - frequent access and infrequent access. This helps reduce costs by automatically moving data to the most cost-effective storage class based on its access patterns.
3. **S3 Standard-Infrequent Access:** S3 Standard-Infrequent Access is appropriate for data that is accessed less frequently but requires quick access when needed. It has the same performance, durability, and availability as S3 Standard but at a lower cost.
4. **S3 One Zone-Infrequent Access:** S3 One Zone-Infrequent Access is best for data that can be recreated if lost, like secondary backups and disaster recovery data. It stores data in a single location, making it more cost-effective than S3 Standard-Infrequent Access.
5. **S3 Glacier:** S3 Glacier is appropriate for data archiving and long-term storage that is accessed infrequently. It offers very low storage costs, but access times can be several hours.
6. **S3 Glacier Deep Archive:** S3 Glacier Deep Archive is ideal for long-term data archival that is accessed very infrequently, like compliance data and financial records. It offers the lowest storage costs among all S3 storage classes, but access times can be up to 12 hours.
In summary, S3 Standard is suitable for regularly accessed data, S3 Intelligent-Tiering is appropriate for data with changing access patterns, S3 Standard-Infrequent Access and S3 One Zone-Infrequent Access are best for less frequently accessed data, and S3 Glacier and S3 Glacier Deep Archive are suitable for long-term data archival with very infrequent access.



## Storage Classes Cost

It's a table that summarizes the cost for different Amazon S3 storage classes for storage and API (per 1 GB per month) as of March 2023. Note that these prices are subject to change, and additional costs may apply for data transfer, requests, and other AWS services:

| Storage Class                 | Storage Cost per GB | API Cost (PUT, COPY, POST, LIST requests) | API Cost (GET, SELECT, and all other requests) |
|-------------------------------|--------------|-------------------------------------------|--------------------------------------------------|
| S3 Standard                   | $0.023       | $0.005 per 1,000 requests                  | $0.0004 per 1,000 requests                      |
| S3 Intelligent-Tiering        | $0.023       | $0.005 per 1,000 requests                  | $0.0004 per 1,000 requests                      |
| S3 Standard-Infrequent Access | $0.0125      | $0.01 per 1,000 requests                    | $0.001 per 1,000 requests                       |
| S3 One Zone-Infrequent Access | $0.01        | $0.01 per 1,000 requests                    | $0.001 per 1,000 requests                       |
| S3 Glacier                    | $0.004       | $0.05 per 1,000 requests                    | $0.004 per 1,000 requests                       |
| S3 Glacier Deep Archive       | $0.00099     | $0.05 per 1,000 requests                    | $0.004 per 1,000 requests                       |

Note that these prices are for standard storage in the US-East region, and prices may vary in different regions. Also, the cost for data retrieval and other additional costs may vary depending on the storage class and usage. It's always recommended to check the official AWS documentation for up-to-date pricing information.


## Cost Estimation for 2 Years Standard Vs Glacier
It is an estimation of the AWS S3 storage and API cost for uploading 100 GB of data and 240,000 files for the first month in the US East (N. Virginia) region using the Standard and Glacier storage classes:

### S3 Storage Cost:
Standard Storage Class: $0.023 per GB per month
Glacier Storage Class: $0.004 per GB per month

For 100 GB of data uploaded in the first month, the storage cost would be:
Standard Storage Class: 100 GB x $0.023 = $2.30
Glacier Storage Class: 100 GB x $0.004 = $0.40

### S3 API Cost:
**PUT, COPY, POST, LIST requests**: $0.005 per 1,000 requests
**GET and all other requests**: $0.0004 per 1,000 requests


#### For 240,000 files uploaded in the first month, assuming 240,000 PUT requests:
**PUT requests**: 240,000 x $0.005 = $1.20
**GET requests (assuming 0.1% of the files are accessed):**
 240,000 x 0.1% x $0.0004 = $0.10

Note that the above estimation is based on the standard AWS pricing as of the knowledge cutoff date of March 2023 and is subject to change.


|Total cost Upto Month| S3 Glacier| S3 Standard |
|-------------------|-----------|------------|
|1|12.4|3.5|
|2|12.8|5.8|
|3|13.2|8.1|
|4|13.6|10.4|
|5|14|12.7|
|6|14.4|15|
|7|14.8|17.3|
|8|15.2|19.6|
|9|15.6|21.9|
|10|16|24.2|
|11|16.4|26.5|
|12|16.8|28.8|
|13|17.2|31.1|
|14|17.6|33.4|
|15|18|35.7|
|16|18.4|38|
|17|18.8|40.3|
|18|19.2|42.6|
|19|19.6|44.9|
|20|20|47.2|
|21|20.4|49.5|
|22|20.8|51.8|
|23|21.2|54.1|
|24|21.6|56.4|