4.3 ストレージ
GCP Storage Services
GCPのストレージサービスは、Cloud Storage(オブジェクト)、Persistent Disk(ブロック)、Filestore(ファイル)を提供する。シンプルな料金体系と、BigQueryとの統合によるデータ分析が強みである。
Cloud Storage
@startuml
skinparam backgroundColor #FEFEFE
rectangle "Cloud Storage" as GCS {
rectangle "バケット" as Bucket #DBEAFE {
rectangle "オブジェクト" as Obj1 #93C5FD {
file "images/photo.jpg" as F1
}
rectangle "オブジェクト" as Obj2 #93C5FD {
file "data/export.csv" as F2
}
}
}
rectangle "ストレージクラス" as Classes #FEF3C7 {
rectangle "Standard" as Std #FDE68A
rectangle "Nearline" as Near #FDE68A
rectangle "Coldline" as Cold #FDE68A
rectangle "Archive" as Arch #FDE68A
}
rectangle "統合サービス" as Integrated #D1FAE5 {
rectangle "BigQuery" as BQ #6EE7B7
rectangle "Dataflow" as DF #6EE7B7
rectangle "Cloud Functions" as CF #6EE7B7
}
Bucket --> Classes : ライフサイクル\nポリシー
Bucket --> Integrated : データ分析
note bottom of Bucket
バケット名: グローバルで一意
ロケーション: リージョン/マルチリージョン
アクセス制御: IAM + ACL
end note
@enduml
図1: Cloud Storageの構造と統合
| ストレージクラス | 最小保存期間 | ユースケース | AWS対応 |
|---|---|---|---|
| Standard | なし | 頻繁アクセス | S3 Standard |
| Nearline | 30日 | 月1回程度 | S3 Standard-IA |
| Coldline | 90日 | 四半期1回程度 | S3 Glacier Instant |
| Archive | 365日 | 年1回未満 | S3 Glacier Deep Archive |
GCP独自機能: Autoclass
Autoclassを有効にすると、オブジェクトのアクセスパターンに応じてストレージクラスを自動的に変更する。手動でライフサイクルポリシーを設定する必要がなくなる。
Autoclassを有効にすると、オブジェクトのアクセスパターンに応じてストレージクラスを自動的に変更する。手動でライフサイクルポリシーを設定する必要がなくなる。
Persistent Disk
@startmindmap skinparam backgroundColor #FEFEFE * Persistent Disk ** SSD *** pd-balanced **** コスト効率 **** 汎用ワークロード **** AWS gp3相当 *** pd-ssd **** 高性能 **** DB、本番環境 **** AWS io1相当 *** pd-extreme **** 最高性能 **** SAP、大規模DB **** 最大120,000 IOPS ** HDD *** pd-standard **** シーケンシャルI/O **** バックアップ **** 最低コスト left side ** 高度な機能 *** リージョナルPD **** 同期レプリケーション **** 高可用性 **** 2ゾーン間で複製 *** スナップショット **** 増分バックアップ **** リージョン間コピー **** スケジュール設定可能 *** ディスクサイズ変更 **** オンライン拡張 **** ダウンタイム不要 @endmindmap
図2: Persistent Diskのタイプと機能
| タイプ | 最大IOPS | 用途 |
|---|---|---|
| pd-balanced | 80,000 | 汎用(推奨) |
| pd-ssd | 100,000 | 高性能DB |
| pd-extreme | 120,000 | 最高性能要求 |
| pd-standard | 7,500 | バックアップ、ログ |
BigQueryとの統合
@startuml
skinparam backgroundColor #FEFEFE
storage "Cloud Storage" as GCS #DBEAFE {
file "data.csv" as CSV
file "logs/*.json" as JSON
file "export.parquet" as Parquet
}
database "BigQuery" as BQ #D1FAE5 {
rectangle "外部テーブル" as External #6EE7B7
rectangle "ネイティブテーブル" as Native #6EE7B7
}
rectangle "分析フロー" as Analysis #FEF3C7 {
rectangle "Dataflow\n(ETL)" as Dataflow #FDE68A
rectangle "Looker\n(BI)" as Looker #FDE68A
}
GCS --> External : フェデレーテッドクエリ\n(データ移動なし)
GCS --> Dataflow : 変換処理
Dataflow --> Native : ロード
BQ --> Looker : 可視化
note bottom of External
GCSのデータを直接
SQLでクエリ可能
(コスト注意)
end note
@enduml
図3: Cloud StorageとBigQueryのデータ分析連携
Cloud StorageはBigQueryと緊密に統合されている。外部テーブル機能により、GCS上のデータをBigQueryにロードせずに直接SQLでクエリできる。CSV、JSON、Parquet、ORC等の形式をサポート [1]。
出典
[1] Google Cloud. Cloud Storage Documentation. https://cloud.google.com/storage/docs/
[2] Google Cloud. Persistent Disk Documentation. https://cloud.google.com/compute/docs/disks/
[2] Google Cloud. Persistent Disk Documentation. https://cloud.google.com/compute/docs/disks/
発展学習
→ Cloud Storage Autoclass
→ BigQuery external tables
→ Cloud Storage Autoclass
→ BigQuery external tables