GCP Compute Engine

 

GCP Compute Engine — Easy Notes

1. Compute options in Google Cloud

Google Cloud provides different ways to run applications:

  • Compute Engine → Virtual Machines (VMs)
  • Google Kubernetes Engine (GKE) → Containers/Kubernetes
  • Cloud Run → Serverless containers
  • Cloud Functions → Event-driven serverless
  • Cloud TPU → Specialized hardware for Machine Learning

This section focuses mainly on Compute Engine.


2. What is Compute Engine?

Compute Engine = Virtual Machines in Google Cloud.

Think of it like:

Your own server running inside Google Cloud.

You get:

  • VM
  • Operating System
  • CPU/vCPU
  • RAM
  • Disk
  • Networking
  • IP address
  • Firewall configuration

You have significant control over how the VM operates.

Example

Suppose your company has an old Java application:

Java Application
       ↓
Linux Server
       ↓
CPU + RAM + Disk

Instead of buying a physical server, you can move that workload to:

Google Cloud
     ↓
Compute Engine VM
     ↓
Linux
     ↓
Java Application

This is why Compute Engine is useful for migrating traditional on-premises applications to the cloud.


3. Compute Engine = IaaS

Compute Engine is primarily:

IaaS = Infrastructure as a Service

You manage more of the infrastructure compared with serverless services.

Compute Engine
      ↓
You manage
 ├── OS
 ├── Applications
 ├── Configuration
 ├── Patching
 └── Scaling rules

Google manages the underlying physical infrastructure.

Easy way to remember

IaaS → Google gives you infrastructure; you manage the VM.


4. Main use case

Compute Engine is best for generic workloads, especially applications designed to run on traditional servers.

Examples:

  • Enterprise Java applications
  • Web servers
  • Databases
  • Legacy applications
  • Applications migrated from on-premises
  • Custom software requiring OS-level control

Why is it portable?

If an application already works on a traditional Linux/Windows server, moving it to a Compute Engine VM can be relatively straightforward.


5. Compute Engine machine configuration

You can choose the resources for your VM.

CPU + Memory

You can use:

Predefined machine types

or

Custom machine types

Custom machine type means you can choose the amount of:

CPU
+
RAM

according to your requirements.


6. vCPU — Important

A vCPU = virtual CPU.

In Compute Engine, each vCPU is implemented as a hardware hyper-thread on the underlying CPU platform.

Think:

Physical CPU
     ↓
Hyper-thread
     ↓
vCPU
     ↓
Your VM

Don't confuse:

  • Physical CPU core
  • Hardware thread
  • vCPU

For GCP VM sizing, you generally select the number of vCPUs.


7. CPU affects network performance

Your choice of CPU/vCPU can also affect network throughput.

The course gives the rule:

Network throughput can scale at approximately 2 Gbps per CPU core, with exceptions for certain smaller instances.

For example, the course mentions:

  • 2 or 4 CPU instances → up to 10 Gbps
  • A C3 instance with 176 vCPUs → theoretical maximum around 200 Gbps

Important

Don't memorize these numbers as universal rules forever because network limits depend on the machine series and configuration.

For exams/interviews, remember:

More powerful VM configurations can provide higher network throughput.


8. Disk options

Compute Engine provides different disk choices.

The important ones here are:

1. Standard Persistent Disk

Uses traditional HDD-style storage.

Advantages:

  • Lower cost
  • Good when very high disk performance isn't required

Think:

Capacity for money


2. SSD Persistent Disk

Uses flash-based SSD storage.

Advantages:

  • Faster
  • Higher IOPS
  • Lower latency than standard HDD-based storage

Think:

Performance for money


3. Local SSD

Local SSD is physically attached to the host hardware.

Therefore:

VM
 ↓
Local SSD
 ↓
Physical host

This provides:

  • Very high throughput
  • Very low latency

But there is an important disadvantage:

Local SSD data is temporary/ephemeral.

The data doesn't survive certain VM lifecycle events, particularly when the VM is stopped or deleted.

So don't use local SSD as your primary permanent storage for important data.


9. Persistent Disk vs Local SSD

FeaturePersistent DiskLocal SSD
Storage typePersistentTemporary/ephemeral
PerformanceGoodVery high
LatencyHigherVery low
Data survives VM lifecycleGenerally yesNo
Typical useApplication/data storageTemporary/high-speed data

Easy memory trick

Persistent = Permanent

Local SSD = Fast but temporary


10. SSD vs Standard Disk

The choice is mainly:

Performance vs Cost

Standard HDD

Cheaper
   ↓
More capacity per money
   ↓
Lower performance

SSD

More expensive
   ↓
Better IOPS
   ↓
Better performance

IOPS = Input/Output Operations Per Second

If your application performs many disk operations, SSD is generally preferable.


11. Disk performance and size

For persistent disks, performance can scale with the amount of disk capacity provisioned.

So disk size isn't only about:

"How much data can I store?"

It can also influence:

"How much disk performance can I get?"


12. Operating Systems

Compute Engine supports different operating systems, including:

  • Linux
  • Windows

You can therefore run a mixed environment:

VM 1 → Linux
VM 2 → Linux
VM 3 → Windows
VM 4 → Windows

This is useful for enterprise environments with different application requirements.


13. Networking in Compute Engine

Compute Engine VMs integrate with VPC networking.

You can configure:

  • Network interfaces
  • IP addresses
  • Firewall rules
  • Network tags
  • Load balancing

Example:

Internet
   ↓
Load Balancer
   ↓
VPC
   ↓
Compute Engine VMs
 ┌─────┬─────┬─────┐
 VM1   VM2   VM3

14. Load Balancing

Compute Engine can work with:

Application Load Balancer

Used mainly for application/HTTP(S) traffic.

Think:

Application-level traffic

Network Load Balancer

Used for network-level traffic.

Think:

Network/transport-level traffic

The important idea:

Google Cloud load balancing is implemented through Google's software-defined network infrastructure rather than requiring you to deploy a physical load-balancer appliance.


15. Autoscaling

Compute Engine can automatically increase or decrease the number of VM instances based on rules.

Example:

Normal traffic
     ↓
3 VMs

Traffic increases
     ↓
Autoscaling
     ↓
5 VMs

Traffic decreases
     ↓
Autoscaling
     ↓
3 VMs

You define the conditions/rules.

Key point

Autoscaling = automatically adjust VM capacity according to demand.

This topic will be covered separately in more detail.


16. Important Compute Engine features

The module will cover:

Machine rightsizing

Choosing an appropriately sized VM.

Example:

Too small → poor performance
Too large → unnecessary cost

Goal:

Right resources + right cost

Startup and shutdown scripts

Scripts that automatically execute when the VM starts or shuts down.

Useful for:

  • Installing software
  • Configuring services
  • Starting applications
  • Performing cleanup

Metadata

Information/configuration associated with a VM or project.

It can also be used by applications/scripts running on the VM.

Availability policies

Controls related to VM availability and behavior during infrastructure events.

OS patch management

Helps manage operating-system updates and patches.

Pricing and usage discounts

Google Cloud provides different pricing mechanisms/discounts depending on usage and configuration.


17. Cloud TPU

Now there is another important concept:

TPU = Tensor Processing Unit

A TPU is Google's custom-designed hardware for machine learning workloads.

Unlike CPUs and GPUs, TPUs are designed specifically to accelerate certain ML computations.

CPU
↓
General-purpose computing

GPU
↓
Parallel processing / ML

TPU
↓
Specialized ML acceleration

18. Why TPU?

Modern ML models require huge amounts of computation.

A major operation in ML is:

Matrix multiplication

TPUs are designed to perform these kinds of operations efficiently.

Therefore they can provide:

  • High ML performance
  • High efficiency
  • Better energy efficiency for suitable workloads

19. CPU vs GPU vs TPU

HardwareMain purpose
CPUGeneral-purpose computing
GPUHighly parallel workloads, graphics, ML
TPUSpecialized ML workloads

Easy example

Imagine three workers:

CPU:

"I can do almost any type of job."

GPU:

"I can do thousands of similar calculations in parallel."

TPU:

"I'm specially optimized for the mathematical operations common in ML."


20. When are TPUs useful?

TPUs are particularly suitable for:

  • Large ML models
  • Long-running training jobs
  • Large effective batch sizes
  • ML workloads that benefit from TPU architecture

They aren't automatically the best choice for every ML workload.


⭐ Final Revision Sheet

Remember these points:

Compute Engine
      ↓
Virtual Machines
      ↓
IaaS
      ↓
High flexibility
      ↓
CPU + RAM + Disk + Network + OS

Compute Engine

  • VM service
  • IaaS
  • Supports Linux and Windows
  • Good for traditional/enterprise applications
  • Good for on-premises migration
  • Predefined + custom machine types
  • Supports autoscaling
  • Supports load balancing
  • Supports startup/shutdown scripts
  • Supports OS patch management

Storage

Standard HDD
→ cheaper
→ capacity-focused

SSD Persistent Disk
→ faster
→ higher IOPS

Local SSD
→ extremely fast
→ low latency
→ temporary/ephemeral

Hardware

CPU → general purpose
GPU → parallel processing
TPU → specialized ML

One-line interview answer

Google Compute Engine is an IaaS service that provides configurable virtual machines with control over CPU, memory, storage, networking, and operating systems, making it suitable for traditional enterprise and on-premises workloads that need high infrastructure flexibility.

Comments

Popular posts from this blog

Async/await

First negative in every window of size k

Valid Parentheses