Skip to content

Storage Classes & Location Types

Tại Sao Quan Trọng Trong Production

Storage class và location type là hai quyết định không thể thay đổi dễ dàng sau khi bucket được tạo (location type hoàn toàn immutable). Chọn sai class → lãng phí chi phí hoặc penalty retrieval fee không mong muốn. Chọn sai location type → latency cao, replication overhead, hoặc mất data locality. Đây là quyết định architecture-time, không phải runtime.


Internal Model — Storage Classes

Cơ Chế Phân Tầng: Không Phải Chỉ Là Pricing

Các storage classes của GCS không chỉ khác về giá — chúng khác nhau về SLA, minimum storage duration, và retrieval semantics. Underlying storage system của GCS (dựa trên Colossus — Google's distributed filesystem) về mặt vật lý lưu trữ data theo cùng cách, nhưng metadata tier xác định pricing và access behavior.

Bốn storage classes chính theo thứ tự chi phí lưu trữ giảm dần:

Standard Storage

SLA: 99.95% (multi-region/dual-region), 99.9% (regional) Typical Availability: >99.99% (multi-region), 99.99% (regional) Minimum Duration: Không có Retrieval Fee: Không có

Standard là class cho data được truy cập thường xuyên. Không có penalty khi xóa sớm và không có retrieval cost — cost model thuần túy là per-GB-per-month storage + operation costs.

# Ví dụ cost (us-central1 region, approximate):
# Standard:  $0.020/GB/tháng
# Nearline:  $0.010/GB/tháng  (nhưng có $0.01/GB retrieval)
# Coldline:  $0.004/GB/tháng  (nhưng có $0.02/GB retrieval)
# Archive:   $0.0012/GB/tháng (nhưng có $0.05/GB retrieval)

Nearline Storage

SLA: 99.9% (multi-region/dual-region), 99.0% (regional) Minimum Duration: 30 ngày Retrieval Fee: Có (per-GB)

Nearline tối ưu cho data access khoảng 1 lần/tháng. Minimum storage duration của 30 ngày có nghĩa là nếu bạn xóa object sau 15 ngày, bạn vẫn bị charge 30 ngày. Điều này là một billing invariant thực tế phải tính vào.

Retrieval fee là per-GB data đọc ra, không phải per-operation. Nếu access pattern là nhiều reads nhỏ trên cùng một object, cost/byte giống nhau.

Coldline Storage

SLA: 99.9% (multi-region/dual-region), 99.0% (regional) Minimum Duration: 90 ngày Retrieval Fee: Cao hơn Nearline (~2x)

Coldline phù hợp cho quarterly access — backup DR, compliance data, audit logs. Retrieval latency giống hệt Standard (milliseconds) — GCS không có "thaw" delay như AWS Glacier. Điểm khác biệt hoàn toàn là cost structure.

Điều quan trọng: Coldline không có tradeoff về latency so với Standard. Đây là hiểu lầm phổ biến. GCS giữ data online và accessible ngay lập tức — chỉ price structure khác nhau.

Archive Storage

SLA: 99.9% (multi-region/dual-region), 99.0% (regional) Minimum Duration: 365 ngày Retrieval Fee: Cao nhất (~5x Nearline)

Archive cho data accessed dưới 1 lần/năm: long-term compliance storage, disaster recovery cold copy, regulatory data retention. Với minimum 365-day duration, bất kỳ object nào bị xóa trước 1 năm đều bị charge đủ 1 năm.

Autoclass — Alternative Approach

Thay vì manual tiering, GCS có Autoclass — tự động di chuyển objects giữa Standard/Nearline/Coldline/Archive dựa trên access pattern thực tế. GCS track last access time và downgrade objects không được access sau một khoảng thời gian.

Autoclass quan trọng ở chỗ nó không tương thích với manual lifecycle rules trên cùng bucket — phải chọn một trong hai.


Internal Model — Location Types

Location type xác định nơi data vật lý nằmreplication model. Đây là quyết định hoàn toàn immutable — không thể thay đổi bucket location sau khi tạo. Migration cần tạo bucket mới và copy data.

Regional — Synchronous Multi-Zone Replication

Data được replicate synchronously across multiple availability zones trong một region. Khi upload thành công, data đã ở ít nhất 2 zones.

Durability: 11 nines (99.999999999%) annual Failure resilience: Zonal failure — automatic failover, không cần đổi endpoint Latency cho compute cùng region: Thấp nhất (~1ms vs ~10ms cross-region)

Regional là lựa chọn cho workloads compute-colocated: GKE pods đọc training data, Cloud Functions processing uploads, Dataflow jobs. Latency difference giữa same-region và cross-region access có thể là 10-100x.

Replication trong regional là synchronous và là phần của write path — client không nhận success cho đến khi data đã được written ở đủ số zones.

Dual-Region — Asynchronous Cross-Region Replication

Data được replicate asynchronously across hai paired regions. Hai loại:

  • Predefined pairs: NAM4 (us-central1 + us-east1), EUR4 (europe-north1 + europe-west4)...
  • Custom pairs: Chọn hai regions bất kỳ trong cùng continent

Replication model:

  1. Write đến primary region → success response trả về client
  2. Asynchronously replicate sang secondary region

Với turbo replication (tính phí thêm), GCS guarantee data available tại secondary region trong 15 phút (RPO ≤ 15 phút).

# Turbo replication SLA:
# 100% objects replicated within 15 minutes of write
# Applies to objects ≥ 1KB

RTO = 0: Nếu một region fail, không cần thay đổi storage path hay endpoint — GCS tự failover sang region còn lại. Client không cần làm gì.

Dual-region pricing cao hơn regional (replication traffic charge) nhưng không có egress charge cho reads từ cùng hai regions trong pair. Đây là subtlety quan trọng cho cost modeling.

Multi-Region — Geo-Redundant Storage

Data được replicate across ít nhất hai regions trong một geographic area lớn: US, EU, hoặc ASIA.

US   = data centers across multiple US regions
EU   = data centers across multiple EU regions  
ASIA = data centers across multiple ASIA regions

Google không publicly document chính xác regions nào trong mỗi multi-region location. Replication là asynchronous.

Highest availability SLA trong tất cả các location types cho Standard class (99.95%).

Tradeoff quan trọng: Multi-region không guarantee data stays in specific region trong một continent, chỉ trong continent đó. Điều này có thể problematic cho data residency requirements (GDPR, data sovereignty). Nếu cần data stay in specific country/region, phải dùng regional bucket trong region đó.

So Sánh Replication Mechanics

AspectRegionalDual-RegionMulti-Region
Replication typeSynchronous (intra-region zones)Asynchronous (cross-region)Asynchronous (cross-region)
RPO (normal)~0 (sync)Minutes (turbo: ≤15min)Minutes
RTO on zone failure~0 (auto)N/AN/A
RTO on region failureData loss~0 (auto)~0 (auto)
Egress cost within locationFreeFree (within pair)Free (within location)
Storage costLowestMediumHighest
Data residency controlSpecific regionSpecific region pairContinent only

Constraints & Trade-offs

Storage Class Transition Rules

Không phải mọi transition đều hợp lệ. GCS chỉ cho phép downgrade (higher access → lower access):

Standard → Nearline, Coldline, Archive
Nearline → Coldline, Archive
Coldline → Archive

Để upgrade (Archive → Standard), phải download và re-upload với class mới. SetStorageClass lifecycle action không hỗ trợ upgrade.

Lý do thiết kế này: GCS muốn lifecycle management là one-way ratchet để tránh tiering churn tốn kém. Nếu cần auto-upgrade, Autoclass là cơ chế đúng.

Minimum Storage Duration Billing

Khi xóa object trước minimum duration:

# Object 1GB trên Coldline (min 90 ngày), xóa sau 30 ngày
# Bị charge:
# - 30 ngày lưu trữ thực tế
# - 60 ngày remaining của minimum duration
# Tổng: 90 ngày charge

Đây là chi phí ẩn với lifecycle rules. Nếu lifecycle rule xóa objects sau 45 ngày trên Coldline (min 90 ngày), bạn đang paying penalty mỗi lần.

Pattern đúng: Chỉ move data sang colder class nếu expected lifetime > minimum duration của class đó.

SLA Downgrade Khi Thay Đổi Class

Khi object được tiered từ Standard xuống Nearline/Coldline/Archive, SLA availability giảm:

  • Standard Multi-Region: 99.95% SLA
  • Nearline/Coldline/Archive Multi-Region: 99.9% SLA

Khoảng cách 0.05% có thể quan trọng nếu data này serve production traffic. Lifecycle tiering nên xảy ra khi data đã "archivable" — không còn trực tiếp serve user requests.

Không Thể Thay Đổi Location

Đây là giới hạn cứng nhất của GCS. Một bucket tạo ở us-central1 không thể move sang us-east1 hay US multi-region. Hệ quả:

  • Phải plan location upfront dựa trên compute colocality và DR requirements
  • Migration cần gcloud storage cp hoặc Transfer Service để copy toàn bộ data
  • Tên bucket mới sau migration — URLs thay đổi

Đây là lý do tại sao nhiều teams dùng abstraction layer (signed URLs, CDN, hoặc service layer) ở trước GCS để tách URL endpoint khỏi bucket location vật lý.


References