Tuần 3 - Ngày 2: S3 Storage Classes
Mục tiêu học tập
- Phân biệt 7+ S3 storage classes
- Hiểu retrieval pricing và minimum duration
- Biết khi nào dùng Intelligent-Tiering vs lifecycle rules
- Áp dụng đúng storage class cho mỗi use case
1. Tổng quan Storage Classes
| Class | Availability | AZs | Min duration | Retrieval | Cost |
|---|---|---|---|---|---|
| S3 Standard | 99.99% | ≥3 | None | Instant | $$$$ |
| S3 Intelligent-Tiering | 99.9% | ≥3 | None | Instant | Auto-tier |
| S3 Standard-IA | 99.9% | ≥3 | 30 days | Instant | $$$ |
| S3 One Zone-IA | 99.5% | 1 | 30 days | Instant | $$ |
| S3 Express One Zone | 99.95% | 1 | 1 hour | < 10ms | $$$$$ |
| S3 Glacier Instant Retrieval | 99.9% | ≥3 | 90 days | Instant (ms) | $ |
| S3 Glacier Flexible Retrieval | 99.99% | ≥3 | 90 days | Min-hours | $ |
| S3 Glacier Deep Archive | 99.99% | ≥3 | 180 days | 12-48 hours | ¢ |
| Reduced Redundancy (deprecated) | — | — | — | — | — |
2. S3 Standard
Đặc điểm
- Default storage class
- 99.99% availability
- 11 nines durability (replicate ≥3 AZs)
- Không có retrieval fee
- Không minimum storage duration
Use case
- Frequently accessed data
- Static website assets
- Mobile/gaming applications
- Big data analytics input
- Content distribution
3. S3 Intelligent-Tiering
Định nghĩa
S3 tự động move objects giữa các tiers dựa trên access pattern, không tốn retrieval fee, không có operational overhead.
5 tiers
Frequent Access → Truy cập thường xuyên (Standard-equivalent)
Infrequent Access → > 30 ngày không truy cập
Archive Instant Access → > 90 ngày không truy cập (ms retrieval)
Archive Access (optional) → > 90 ngày (minutes-hours retrieval, opt-in)
Deep Archive (optional) → > 180 ngày (hours retrieval, opt-in)
Pricing
- Storage cost theo tier
- Monitoring fee: $0.0025/1000 objects/month
- KHÔNG retrieval fee giữa tiers
Use case
- Data với unknown/changing access patterns
- "Set and forget" — không muốn manage lifecycle
- Dài hạn nhiều TB data với access không đoán được
Lưu ý
- Object < 128 KB luôn ở Frequent tier (không qualify cho tier khác)
- Auto-archive thì opt-in, mặc định chỉ 2 tier đầu
4. S3 Standard-IA (Infrequent Access)
Đặc điểm
- Truy cập ít thường xuyên nhưng cần nhanh (instant)
- 99.9% availability (thấp hơn Standard)
- Min storage duration: 30 ngày (xóa trước → vẫn tính 30 ngày)
- Retrieval fee: $/GB
- Rẻ hơn Standard ~40%
Use case
- Backup
- Disaster recovery files
- Old log files vẫn cần access nhanh
5. S3 One Zone-IA
Đặc điểm
- Giống Standard-IA nhưng chỉ 1 AZ
- 99.5% availability
- Rẻ hơn Standard-IA ~20%
- Mất data nếu AZ đó destroyed
Use case
- Reproducible data (có thể regenerate)
- Secondary backup copies
- Cached data (replicate được)
6. S3 Express One Zone (2023+)
Đặc điểm
- Single-digit ms latency — nhanh nhất S3
- 1 AZ (như One Zone-IA)
- Min storage duration: 1 hour
- Cost lớn hơn Standard ~7-8x
- Performance: hàng triệu req/giây/bucket
Use case
- AI/ML training data (cần I/O cực nhanh)
- High-performance analytics
- Real-time apps
Cấu trúc
- Tên bucket:
my-bucket--use1-az5--x-s3 - Cần Directory Bucket (kiểu mới, không phải General Purpose Bucket)
7. S3 Glacier (3 tiers)
7.1 Glacier Instant Retrieval
- Archive với instant ms retrieval (như Standard-IA nhưng rẻ hơn)
- Min duration: 90 ngày
- Use case: Quarterly reports, medical images cần retrieve nhanh
7.2 Glacier Flexible Retrieval (cũ "S3 Glacier")
- Truy cập theo phút - giờ
- Min duration: 90 ngày
- 3 retrieval options:
- Expedited: 1-5 phút (đắt nhất)
- Standard: 3-5 giờ
- Bulk: 5-12 giờ (rẻ nhất, ~$0.0025/GB)
7.3 Glacier Deep Archive
- Rẻ nhất ($0.00099/GB-month)
- Min duration: 180 ngày
- Retrieval:
- Standard: 12 giờ
- Bulk: 48 giờ
- Use case: Compliance archive 7-10 năm
So sánh Glacier
| Class | Retrieval | Min storage | Cost |
|---|---|---|---|
| Glacier Instant | ms (instant) | 90 ngày | $$ |
| Glacier Flexible | Min-hours | 90 ngày | $ |
| Glacier Deep Archive | 12-48 hours | 180 ngày | ¢ (cheapest) |
8. Lifecycle Rules
Định nghĩa
Tự động transition objects giữa storage classes hoặc expire (delete) sau thời gian.
2 loại action
Transition Action
Object created → 30 ngày → Move to Standard-IA → 90 ngày → Glacier Flexible → 365 ngày → Glacier Deep Archive
Expiration Action
Object created → 7 ngày → Delete
Incomplete multipart uploads → 7 ngày → Delete (cleanup)
Các transitions hợp lệ
Lưu ý
- KHÔNG transition từ Glacier về Standard (cần restore + copy)
- Object < 128 KB không transition (overhead cost > saving)
- Lifecycle rule áp dụng prefix hoặc tag filter
Ví dụ YAML rule
- Id: ArchiveOldLogs
Status: Enabled
Filter:
Prefix: "logs/"
Transitions:
- Days: 30
StorageClass: STANDARD_IA
- Days: 90
StorageClass: GLACIER
- Days: 365
StorageClass: DEEP_ARCHIVE
Expiration:
Days: 2555 # 7 năm
9. Storage Class Selection Decision Tree
10. Use Case Examples
Ví dụ 1: Web application static assets
- Hot data (CSS, JS, images frequently accessed)
- Class: S3 Standard
- Add: CloudFront để cache thêm
Ví dụ 2: User uploads (photo sharing app)
- Active: hot in first 30 days
- Then: cold (rarely viewed)
- Solution: S3 Standard → Lifecycle to Standard-IA after 30 days → Glacier Instant after 90 days
Ví dụ 3: Backup files
- Daily backups, rarely retrieve
- Need access trong vài giờ khi DR
- Solution: S3 Standard-IA (current) + Lifecycle to Glacier Flexible (90 days) + Deep Archive (1 year)
Ví dụ 4: Compliance logs (giữ 7 năm)
- Rarely accessed, OK chờ 12 giờ retrieve
- Solution: Direct to Glacier Deep Archive (qua S3 Standard 1 day để qualify nếu lifecycle)
- Hoặc upload trực tiếp Deep Archive
Ví dụ 5: ML training data
- Read intensive khi training
- Solution: S3 Express One Zone (single-digit ms)
Ví dụ 6: Unknown access pattern, large dataset
- Data lake mà workload thay đổi theo project
- Solution: S3 Intelligent-Tiering
11. Pricing Breakdown (Example us-east-1)
| Class | Storage $/GB-mo | Retrieval $/GB | PUT/COPY $/1000 |
|---|---|---|---|
| Standard | $0.023 | Free | $0.005 |
| Standard-IA | $0.0125 | $0.01 | $0.01 |
| One Zone-IA | $0.01 | $0.01 | $0.01 |
| Intelligent-Tiering | $0.023 (frequent) → $0.00099 (deep) | Free between tiers | $0.005 |
| Glacier Instant | $0.004 | $0.03 | $0.02 |
| Glacier Flexible | $0.0036 | $0.01 (std) | $0.03 |
| Glacier Deep Archive | $0.00099 | $0.02 (std) | $0.05 |
Giá có thể thay đổi — verify trên AWS Pricing.
12. Storage Class Analysis
Định nghĩa
Tool S3 phân tích access pattern, đề xuất transition to Standard-IA.
Cách dùng
- Enable Storage Class Analysis trong bucket Management
- Sau 30 ngày quan sát, output ra CSV report lưu trong S3
- Visualize: object age vs storage size vs access frequency
- Tích hợp với Athena / QuickSight để analyze
Tip
- Đừng đoán → dùng tool để decide lifecycle rules
Câu hỏi ôn tập
-
Storage class nào có minimum duration charge 180 ngày?
Xem đáp án
Glacier Deep Archive (180 ngày minimum storage duration). Nếu delete object trước 180 ngày vẫn bị charge phần còn lại. Các minimum khác: Standard-IA và One Zone-IA = 30 ngày, Glacier Instant Retrieval và Glacier Flexible Retrieval = 90 ngày, Intelligent-Tiering = 30 ngày. Standard và Reduced Redundancy không có minimum.
-
Khi nào nên dùng S3 Intelligent-Tiering thay vì manual lifecycle?
Xem đáp án
Khi access pattern không predictable hoặc thay đổi theo thời gian. Intelligent-Tiering tự động monitor access frequency và move objects giữa tiers (Frequent Access, Infrequent Access, Archive Instant, Archive). Phù hợp cho data analytics, media assets, user-generated content — không biết file nào sẽ được access lại. Manual lifecycle phù hợp khi access pattern rõ ràng (ví dụ: logs cũ hơn 30 ngày không bao giờ access).
-
Object < 128 KB trong Intelligent-Tiering nằm ở tier nào?
Xem đáp án
Frequent Access tier và không bao giờ bị chuyển xuống tier thấp hơn. S3 không monitor access hoặc charge monitoring fee cho small objects (<128 KB) — overhead của tiering không worth it. Objects nhỏ luôn ở Frequent Access tier. Đây là tối ưu hóa để tránh monitoring cost > storage savings cho small objects.
-
One Zone-IA rẻ hơn Standard-IA bao nhiêu phần trăm? Trade-off là gì?
Xem đáp án
One Zone-IA rẻ hơn ~20% so với Standard-IA. Trade-off: data lưu trong một AZ duy nhất thay vì 3+ AZs — nếu AZ đó bị sự cố hoặc AWS destroy AZ, data bị mất. Phù hợp cho: secondary backups (đã có copy ở nơi khác), easily reproducible data, non-critical data. Không phù hợp cho primary storage của data không thể recreate.
-
Glacier Flexible Retrieval có mấy options retrieval?
Xem đáp án
3 options: (1) Expedited — 1-5 phút, đắt nhất (có thể dùng Provisioned Capacity để đảm bảo), (2) Standard — 3-5 giờ, phí vừa, (3) Bulk — 5-12 giờ, rẻ nhất. Glacier Instant Retrieval (class khác) truy xuất milliseconds như Standard class. Glacier Deep Archive chỉ có Standard (12h) và Bulk (48h).
Bài tập thực hành
- Upload file vào S3 với 3 storage classes khác nhau (Standard, Standard-IA, Glacier Instant)
- Tạo Lifecycle rule: transition prefix
logs/đến Standard-IA sau 30 ngày, Glacier sau 90 ngày, expire sau 365 ngày - Enable Storage Class Analysis cho bucket
- Restore object từ Glacier Flexible (Expedited tier) và đo thời gian
- So sánh giá storage 1 TB cho mỗi class qua Pricing Calculator
Tài liệu tham khảo chính thức
- S3 Storage Classes
- Intelligent-Tiering
- Glacier Storage Classes
- S3 Lifecycle Configuration
- Storage Class Analysis
Tiếp theo: S3 Versioning và Lifecycle