Google Compute Engine (GCE) — IaaS

 

Google Compute Engine (GCE) — IaaS

1. What is Compute Engine?

Compute Engine is Google Cloud's IaaS (Infrastructure as a Service) solution.

It allows you to create and run Virtual Machines (VMs) on Google's infrastructure.

Think of it as:

Physical server → Google owns it
Virtual machine → You rent/use it

You don't need to buy physical servers upfront.


2. What is a Virtual Machine?

A VM is like a virtual computer/server running inside Google's data center.

You can configure it similar to a physical server:

  • CPU → How much processing power you need
  • Memory (RAM) → How much memory you need
  • Storage → Disk space and type
  • Operating System → Linux, Windows Server, etc.

Example

You could create:

VM
├── 4 vCPUs
├── 16 GB RAM
├── 100 GB Disk
└── Linux OS

This VM behaves like a complete computer/server.


3. How can you create a VM?

You have three main options:

Google Cloud Console

Web-based graphical interface.

Google Cloud CLI

Command-line interface used from a terminal.

Compute Engine API

Used by applications/scripts to create and manage VMs programmatically.


4. Operating Systems

Compute Engine supports:

  • Linux
  • Windows Server
  • Customized images
  • Other OS images that you build yourself

An image is basically a template containing an operating system and configuration used to create a VM.


5. Cloud Marketplace

Cloud Marketplace provides ready-to-deploy solutions from:

  • Google
  • Third-party vendors

Instead of manually configuring:

Software
   ↓
VM
   ↓
Storage
   ↓
Network

Marketplace can package these configurations together.

Example

Suppose you want to deploy a particular software application.

Instead of:

Create VM → install OS → install software → configure settings

You can find a preconfigured Marketplace solution and launch it.

Many Marketplace solutions have no additional software charge beyond normal Google Cloud resource usage.

Some third-party commercial software does have additional licensing charges, and estimated charges are shown before deployment.


6. Compute Engine Pricing

Compute Engine has several pricing options/discount mechanisms.

A. Pay-as-you-go

You generally pay based on how long your VM resources are used.

The course states:

Billed by the second, with a one-minute minimum.

So you don't necessarily have to pay for an entire hour just because your VM ran briefly.


B. Sustained-use Discounts

If a VM runs for a significant portion of the month, Google automatically provides a discount.

According to the course:

Discounts start applying after the VM runs for more than 25% of a month.

The longer the eligible VM runs, the more discount can apply.

Important: You don't manually request this discount; it is automatic.


7. Committed-use Discounts (CUD)

Useful when your workload is:

Stable + predictable

You commit to using a certain amount of resources for a fixed period.

Typical commitment periods:

  • 1 year
  • 3 years

In return, you can receive a significant discount.

The course mentions up to 57% compared with normal pricing for the applicable resources/configuration.

Easy example

Suppose your company knows:

"We will continuously need this amount of CPU and memory for the next 3 years."

Instead of paying normal rates, you can make a commitment and receive a discount.

Remember

Predictable workload → Committed-use discount


8. Spot VMs ⭐

Spot VMs are designed for workloads that can tolerate interruption.

Example:

A batch job processing a huge dataset.

You don't necessarily need a person watching it continuously.

Spot VMs can provide up to 90% savings compared with standard pricing, according to the course.

The catch 🚨

Google Cloud can terminate/stop the VM when the capacity is needed elsewhere.

Therefore, your application should be designed to:

Start
 ↓
Process
 ↓
Interrupted
 ↓
Restart
 ↓
Continue processing

You should avoid using Spot VMs for workloads where interruption would cause serious problems.


Spot VM vs Preemptible VM

The course highlights an important difference:

Older Preemptible VMs had a maximum runtime.

Spot VMs don't have a fixed maximum runtime.

They can continue running as long as the required capacity remains available.


9. Compute + Storage Performance

Compute Engine provides high throughput between:

VM processing ↔ Persistent Disk

without requiring you to select a special machine type just to obtain that throughput.

The course describes this as the default, with no additional charge for that capability.


10. Machine Types

Compute Engine allows you to select the resources your VM needs.

Important properties include:

  • Number of vCPUs
  • Amount of memory/RAM

You can use:

Predefined machine types

Google provides ready-made configurations.

For example:

Machine Type
     ↓
4 vCPU + 16 GB RAM

Custom machine types

You can choose the resources yourself.

For example:

Custom VM
├── 6 vCPUs
└── 20 GB RAM

This gives you more flexibility so you don't have to pay for resources you don't need.


🧠 Quick Revision

ConceptRemember
Compute EngineGoogle Cloud's IaaS
VMVirtual computer/server
CPUProcessing power
MemoryRAM
ImageTemplate used to create a VM
Cloud MarketplaceReady-to-deploy solutions
Sustained-use discountAutomatic discount for longer usage
Committed-use discountDiscount for 1/3-year commitment
Spot VMVery cheap but can be terminated
Predefined machine typeReady-made CPU/RAM configuration
Custom machine typeChoose your own CPU/RAM

⭐ Most important exam/interview points

Compute Engine = IaaS

Spot VM = Cheap + Interruptible

Committed-use = Predictable workload + commitment

Custom machine type = Choose your own vCPU + memory

Cloud Marketplace = Preconfigured software/solutions

VM = Virtual version of a physical server



Compute Engine — Autoscaling & Load Balancing

This section introduces Autoscaling, Load Balancing, and Scaling Up vs Scaling Out.

1. Autoscaling

Autoscaling means automatically increasing or decreasing the number of VMs based on the application's workload.

For example:

Low traffic
   ↓
2 VMs

Traffic increases
   ↓
5 VMs

Traffic decreases
   ↓
2 VMs

The VMs are added or removed based on load metrics.

Why use Autoscaling?

Instead of manually creating VMs when traffic increases, Google Cloud can automatically adjust the number of VMs.

Benefit:

  • Handles increased traffic
  • Reduces unnecessary resources
  • Helps control costs
  • Improves application availability

2. Load Balancing

If you have multiple VMs, incoming users need to be distributed among them.

That's the job of a Load Balancer.

                 Users
                   |
                   ↓
            Load Balancer
             /     |     \
            ↓      ↓      ↓
          VM 1   VM 2   VM 3

For example, if 1,000 users are accessing your application, the load balancer distributes the requests across available VMs rather than sending everything to one VM.

Key idea

Autoscaling decides how many VMs you need.
Load balancing distributes traffic among those VMs.

They often work together.


3. Scaling Up vs Scaling Out ⭐

There are two major ways to handle increased workload.

Scaling Up — Vertical Scaling

Make one VM bigger.

Before:
VM → 4 CPU + 16 GB RAM

After:
VM → 32 CPU + 128 GB RAM

This is useful for workloads that need a very powerful individual machine.

Examples mentioned in the course:

  • In-memory databases
  • CPU-intensive analytics

Scaling Out — Horizontal Scaling

Add more VMs instead of making one VM extremely large.

Before:

       VM 1


After:

       Load Balancer
       /     |     \
      VM1   VM2   VM3

Most Google Cloud customers generally start with scaling out.

Easy way to remember

Scale UP = Make the machine bigger
Scale OUT = Add more machines


4. Very Large VMs

Compute Engine can create very large VMs with many CPUs and large amounts of memory.

These can be useful when the workload needs a lot of resources in a single VM.

For example:

Large VM
├── Many vCPUs
├── Large RAM
└── High-performance workload

But large doesn't always mean better.

For many applications, having multiple smaller VMs provides better scalability and availability.


5. VM CPU Limits and Quotas

There are limits on how many CPUs a VM can have.

The maximum number of CPUs depends on:

Machine family

Different Compute Engine machine families support different VM sizes.

Quota

Your Google Cloud project/user also has resource quotas.

The available quota can depend on the zone.

So even if a particular VM configuration exists, you may not necessarily be able to create it if your available quota isn't sufficient.


🧠 Important Concepts Together

Think about an online application:

                 Internet Users
                       |
                       ↓
                Load Balancer
                       |
          ┌────────────┼────────────┐
          ↓            ↓            ↓
        VM 1          VM 2         VM 3
          ↑            ↑            ↑
          └──────── Autoscaling ────┘

When traffic increases:

100 users
   ↓
2 VMs

10,000 users
   ↓
10 VMs

Autoscaling → adds VMs

Load balancing → distributes traffic


⭐ Exam/Interview Revision

ConceptMeaning
AutoscalingAutomatically adds/removes VMs based on load
Load BalancingDistributes incoming traffic across VMs
Scale UpMake an existing VM bigger
Scale OutAdd more VMs
Large VMsUseful for memory/CPU-intensive workloads
Machine FamilyDetermines available VM configurations
QuotaLimits how many resources you can use
Zone-dependent quotaAvailable quota can vary by zone

One-line memory trick

Autoscaling = How many VMs?
Load Balancing = Which VM gets the request?
Scale Up = Bigger VM
Scale Out = More VMs

Comments

Popular posts from this blog

Async/await

First negative in every window of size k

Next Smaller Element