OCI Block Volume: Performance Tiers, Backup Policies, and Cross-Region Replication

Block volumes are the most common source of performance surprises on OCI. The default Balanced tier works for boot volumes and general workloads. Databases, high-throughput batch jobs, and latency-sensitive applications need Higher Performance or Ultra High Performance. Provisioning the wrong tier means either overpaying or delivering insufficient throughput. This post covers selecting the right performance tier, configuring backup policies, managing volume groups for crash-consistent backups, and setting up cross-region replication for disaster recovery.

Performance Tiers

OCI Block Volume performance is controlled by VPUS (Volume Performance Units) per GB. Setting 0 = Lower Cost (2 IOPS/GB), 10 = Balanced (10-60 IOPS/GB), 20 = Higher Performance (30-120 IOPS/GB), 30 to 120 = Ultra High Performance (up to 225 IOPS/GB and 2680 MB/s). For Oracle Database datafiles, start at 20 and use AWR I/O wait data to determine whether Ultra High Performance is needed before paying for it.

Step 1: Higher Performance Volume for Oracle Database

resource "oci_core_volume" "db_data" {
  compartment_id      = var.compartment_id
  availability_domain = var.availability_domain
  display_name        = "production-db-data"
  size_in_gbs         = 2000
  vpus_per_gb         = 20
  kms_key_id          = var.vault_key_id

  is_auto_tune_enabled   = true
  auto_tuned_vpus_per_gb = 10

  defined_tags = {
    "Operations.Environment" = "production"
    "Operations.Application" = "oracle-db"
    "Operations.ManagedBy"   = "terraform"
  }
}

resource "oci_core_volume_attachment" "db_data_attach" {
  attachment_type                     = "paravirtualized"
  instance_id                         = var.db_instance_id
  volume_id                           = oci_core_volume.db_data.id
  is_pv_encryption_in_transit_enabled = true
  device                              = "/dev/oracleoci/oraclevdb"
}

Step 2: Ultra High Performance for Redo Logs

resource "oci_core_volume" "db_redo" {
  compartment_id      = var.compartment_id
  availability_domain = var.availability_domain
  display_name        = "production-db-redo"
  size_in_gbs         = 500
  vpus_per_gb         = 30
  kms_key_id          = var.vault_key_id
}

# Ultra High Performance requires iSCSI attachment, not paravirtualized
resource "oci_core_volume_attachment" "db_redo_attach" {
  attachment_type = "iscsi"
  instance_id     = var.db_instance_id
  volume_id       = oci_core_volume.db_redo.id
  use_chap        = true
}

output "redo_iqn"       { value = oci_core_volume_attachment.db_redo_attach.iqn }
output "redo_ipv4"      { value = oci_core_volume_attachment.db_redo_attach.ipv4 }
output "redo_chap_user" { value = oci_core_volume_attachment.db_redo_attach.chap_username }

Step 3: Automated Backup Policy

resource "oci_core_volume_backup_policy" "db_policy" {
  compartment_id = var.compartment_id
  display_name   = "oracle-db-backup-policy"

  schedules {
    backup_type       = "INCREMENTAL"
    period            = "ONE_DAY"
    retention_seconds = 604800
    offset_type       = "STRUCTURED"
    hour_of_day       = 2
    time_zone         = "UTC"
  }

  schedules {
    backup_type       = "FULL"
    period            = "ONE_WEEK"
    retention_seconds = 2592000
    offset_type       = "STRUCTURED"
    hour_of_day       = 3
    day_of_week       = "SUNDAY"
    time_zone         = "UTC"
  }

  schedules {
    backup_type       = "FULL"
    period            = "ONE_MONTH"
    retention_seconds = 31536000
    offset_type       = "STRUCTURED"
    hour_of_day       = 4
    day_of_month      = 1
    time_zone         = "UTC"
  }
}

resource "oci_core_volume_backup_policy_assignment" "db_data_backup" {
  asset_id  = oci_core_volume.db_data.id
  policy_id = oci_core_volume_backup_policy.db_policy.id
}

Step 4: Volume Groups for Crash-Consistent Backup

resource "oci_core_volume_group" "db_all_volumes" {
  compartment_id      = var.compartment_id
  availability_domain = var.availability_domain
  display_name        = "production-db-volume-group"

  source_details {
    type       = "volumeIds"
    volume_ids = [
      oci_core_volume.db_data.id,
      oci_core_volume.db_redo.id,
      var.db_arch_volume_id
    ]
  }
}

# Manual pre-maintenance crash-consistent backup of all DB volumes
resource "oci_core_volume_group_backup" "pre_maint_backup" {
  volume_group_id = oci_core_volume_group.db_all_volumes.id
  display_name    = "pre-maintenance-backup"
  type            = "FULL"
}

# List recent backups
# oci bv backup list --compartment-id ${COMPARTMENT_ID} --volume-id ${VOLUME_ID}
#   --query 'data[*].{name:"display-name", size:"size-in-gbs", type:type, state:"lifecycle-state", created:"time-created"}'

Step 5: Cross-Region Replication for DR

resource "oci_core_volume" "db_data_with_replication" {
  compartment_id      = var.compartment_id
  availability_domain = var.availability_domain
  display_name        = "production-db-data"
  size_in_gbs         = 2000
  vpus_per_gb         = 20
  kms_key_id          = var.vault_key_id

  block_volume_replicas {
    availability_domain = var.dr_availability_domain
    display_name        = "production-db-data-dr-replica"
  }

  block_volume_replicas_deletion = false

  defined_tags = {
    "Operations.Environment" = "production"
    "Operations.ManagedBy"   = "terraform"
  }
}

# Monitor replication lag
resource "oci_monitoring_alarm" "replication_lag" {
  compartment_id        = var.compartment_id
  display_name          = "block-volume-replication-lag"
  is_enabled            = true
  metric_compartment_id = var.compartment_id
  namespace             = "oci_block_storage"
  query                 = "ReplicationLagSeconds[5m]{volumeId = '${oci_core_volume.db_data_with_replication.id}'}.max() > 300"
  severity              = "WARNING"
  pending_duration      = "PT10M"
  destinations          = [var.ops_notification_topic_id]
  body                  = "Block volume replication lag exceeds 5 minutes. DR recovery point objective may be at risk."
}

# Activate replica in DR region (run during DR failover)
# oci bv block-volume-replica activate --block-volume-replica-id ${REPLICA_ID}

Operational Notes

Use volume groups when multiple volumes belong to the same database or application. A volume group backup captures all member volumes at the same point in time, giving you a crash-consistent snapshot of the entire storage layout. Backing up volumes individually at different times produces an inconsistent set that cannot reliably recover a running database.

The is_auto_tune_enabled setting reduces VPUS per GB when a volume is detached, lowering cost for volumes only attached during maintenance windows or business hours. When re-attached, performance is automatically restored to the configured level. Enable this for non-production and development environment volumes.

Ultra High Performance requires iSCSI attachment, not paravirtualized. After attaching via iSCSI, configure multi-path I/O on the OS for redundancy and maximum throughput. The iscsiadm commands and multipath configuration must be completed on the instance before the volume appears as a block device. OCI provides per-volume iSCSI connection instructions in the Console and via API that include the exact iscsiadm commands to run.

Regards,
Osama

#OCI #OracleCloud #BlockVolume #Storage #Terraform #IaC #OracleCloudInfrastructure #DevOps #TechBlog #Oracle #DisasterRecovery #CloudStorage #VolumeBackup #CrossRegion #DatabaseStorage #PlatformEngineering #OracleDBA #IOPS #UltraHighPerformance #CloudReplication

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.