GCP Free Learning
, ,

What is the difference between a persistent disk and a local SSD in Compute Engine?

by

GCP Free Learning

A persistent disk and a local SSD are two types of storage options in Compute Engine in GCP. They have different characteristics, use cases, and pricing structures.

Persistent Disk:

  1. Persistent disks are network-attached block storage that provides data durability and availability.
  2. They can be used as boot disks or additional data disks.
  3. Persistent disks can be attached to multiple instances (read-only) or a single instance (read-write).
  4. They support automatic backup through snapshots.
  5. Persistent disks offer lower IOPS (Input/Output Operations Per Second) and throughput compared to local SSDs.
  6. You only pay for the space you provision. Pricing details can be found here.

Local SSD:

  1. Local SSDs are physically attached to the host machine, providing low-latency and high-performance I/O.
  2. They are best suited for temporary storage and high-performance workloads, such as databases or caches.
  3. Local SSDs cannot be used as boot disks.
  4. Data on local SSDs is not automatically backed up and is lost when the instance is stopped or terminated.
  5. They provide higher IOPS and throughput compared to persistent disks.
  6. You pay for the entire local SSD capacity, regardless of usage. Pricing details can be found here.

Creating instances with Persistent Disk and Local SSD using GCP Console, gcloud CLI, and Terraform:

GCP Console:

  1. Go to the GCP Console: https://console.cloud.google.com/
  2. Navigate to Compute Engine > VM instances.
  3. Click on the “Create” button to start creating a new instance.
  4. Fill in the required fields, such as instance name, region, zone, and machine type.
  5. Choose a boot disk (persistent disk) by clicking on the “Change” button under the “Boot disk” section. Select the desired OS image and disk size.
  6. To add a local SSD, click on the “Add” button under the “Local disks” section. Choose “Local SSD” and specify the size and interface (NVMe or SCSI).
  7. Click the “Create” button to launch the instance.

gcloud CLI:

  1. Launch a new instance with a boot persistent disk and a local SSD using the following command:
gcloud compute instances create INSTANCE_NAME \
    --image-family IMAGE_FAMILY \
    --image-project IMAGE_PROJECT \
    --machine-type MACHINE_TYPE \
    --boot-disk-size DISK_SIZE_GB \
    --zone ZONE \
    --local-ssd interface=INTERFACE

Replace INSTANCE_NAME, IMAGE_FAMILY, IMAGE_PROJECT, MACHINE_TYPE, DISK_SIZE_GB, ZONE, and INTERFACE (NVMe or SCSI) with appropriate values.

Terraform:

  1. Create a main.tf file with the following content:

“`hcl
provider “google” {
credentials = file(“”)
project = “”
region = “us-central1”
}

resource “google_compute_instance” “with_local_ssd” {
name = “instance-with-local-ssd”
machine_type = “n1-standard-1”
zone = “us-central1-a”

boot_disk {
initialize_params {
image = “debian-cloud/debian-9”
}
}

scratch_disk {
interface = “INTERFACE” # Replace with “NVME” or “SCSI”
}

network_interface {
network = “default”
access_config {
// Ephemeral external IP

}
}

Replace `<PATH_TO_YOUR_SERVICE_ACCOUNT_JSON>`, `<YOUR_PROJECT_ID>`, and `INTERFACE` (NVMe or SCSI) with appropriate values.

2. Initialize Terraform:

terraform init

3. Review the execution plan:

terraform plan

4. Apply the changes to create the instance:

terraform apply
“`

After creating the instance with both persistent disk and local SSD, you can use them for different purposes based on their characteristics. For example, you can store your application data on the persistent disk for durability and use the local SSD for caching or temporary data that requires high performance.

Cost:

The cost of using persistent disks and local SSDs depends on various factors such as the type of disk, the size of the disk, and the region where the instance is running. You can find the detailed pricing for persistent disks here and for local SSDs here.

Glance and Google’s Next-Level Gaming Recommendation Engine

Collaborative Excellence: Glance and Google’s Next-Level Gaming Recommendation Engine Introduction: In the dynamic gaming industry, personalized recommendations are crucial for..

gcp_ml gcp_ml

Digits and Google Cloud ML

How Digits is Transforming the Accounting Landscape Using Google Cloud ML The finance and accounting industry is experiencing a significant..

GCP AI GCP AI

Google Cloud’s Vertex AI Model Garden and the Launch of Generative AI Studio

Google Cloud’s Vertex AI Model Garden and the Launch of Generative AI Studio Artificial Intelligence (AI) and Machine Learning (ML)..

GCP AI/ML GCP AI/ML

Google Cloud’s Pioneering AI Models and the Launch of Generative AI Studio

 Google Cloud’s Pioneering AI Models and the Launch of Generative AI Studio Artificial Intelligence (AI) continues to break new grounds,..

GCP App Engine GCP App Engine

How to scale an App Engine application in GCP?

Scaling an App Engine application involves configuring the scaling settings in the app.yaml file and deploying the changes. I’ll provide..

Leave a Reply

Your email address will not be published. Required fields are marked *