Cloud Computing Tutorial · Storage and Databases · Lesson 16 of 24

Block and File Storage

Disks for VMs (EBS, Managed Disks, Persistent Disk), shared file systems (EFS, Azure Files, Filestore) and snapshots.

Create a free account to save this page, take notes and track your progress. Sign in

Three kinds of storage

Kind Behaves like AWS Azure Google Cloud
Block A disk attached to one VM EBS Managed Disks Persistent Disk / Hyperdisk
File A shared network file system (NFS/SMB) EFS, FSx Azure Files, Azure NetApp Files Filestore
Object Files over an HTTP API S3 Blob Storage Cloud Storage

Block storage details

  • Disks live in one availability zone and attach to instances in that zone.
  • Performance is provisioned: choose IOPS and throughput (for example EBS gp3 lets you set both).
  • Snapshots are incremental backups stored durably; copy them to another region or account for disaster recovery.
  • Instance store / local SSDs are fast but lost when the instance stops.
Incremental snapshotsTry it yourself
snapshots = []
disk_blocks = {i: f"v1-{i}" for i in range(100)}     # a 100-block disk

def snapshot(day):
    last = snapshots[-1]["blocks"] if snapshots else {}
    changed = {k: v for k, v in disk_blocks.items() if last.get(k) != v}
    snapshots.append({"day": day, "blocks": dict(disk_blocks), "stored": len(changed)})
    print(f"day {day}: snapshot stores {len(changed):3} changed blocks")

snapshot(1)
for i in range(5):
    disk_blocks[i] = f"v2-{i}"                        # 5 blocks change
snapshot(2)
for i in range(3, 13):
    disk_blocks[i] = f"v3-{i}"
snapshot(3)
print("total blocks stored:", sum(s["stored"] for s in snapshots), "instead of", 100 * len(snapshots))

Output

day 1: snapshot stores 100 changed blocks
day 2: snapshot stores   5 changed blocks
day 3: snapshot stores  10 changed blocks
total blocks stored: 115 instead of 300

When to use which

Databases on VMs need block storage; several servers sharing files (CMS uploads, home directories) need file storage; most application data, backups and media belong in object storage, which is cheaper and scales without management.

Test yourself

An EBS volume is in eu-west-1a. Can an instance in eu-west-1b attach it?

  1. Yes, any instance in the region
  2. No, block volumes attach only within their availability zone
  3. Only if it's encrypted
  4. Only with a VPN
Show answer

Answer: No, block volumes attach only within their availability zone

Create a snapshot and restore it in the other zone instead.

Was this page helpful?