Compute Engine: CPU, Memory & Machine Types
- Get link
- X
- Other Apps
GCP Study Notes — Compute Engine: CPU, Memory & Machine Types
1. Three ways to create/configure a VM
When creating a Compute Engine VM, you can use:
- Google Cloud Console — GUI, easiest for beginners.
- Cloud Shell /
gcloudCLI — useful for automation and repeatable commands. - REST API — useful for programmatic and complex automation.
Recommended approach
If you're not sure about the CLI/API configuration:
Create the VM once in the Console → then get the equivalent gcloud command or REST request.
This helps because the Console gives you:
- Dropdowns for available machine types
- Valid CPU/memory combinations
- Correct configuration
- Less chance of typing mistakes
2. What is a Machine Type?
A machine type defines the resources given to your VM.
Mainly:
- vCPU → processing power
- Memory/RAM → temporary working space
For example:
VM ├── 4 vCPUs └── 16 GB RAM
Think of it like buying a computer:
vCPU = processor capacity
Memory = RAM
3. Machine Family → Series → Machine Type
This hierarchy is important.
Machine Family ↓ Machine Series ↓ Machine Type
For example:
General-purpose ↓ E2 ↓ e2-standard-4
Machine family
A machine family is designed for a particular type of workload.
Google Cloud has four major families:
| Family | Main purpose |
|---|---|
| General-purpose | Normal/common workloads |
| Compute-optimized | CPU-intensive workloads |
| Memory-optimized | RAM-intensive workloads |
| Accelerator-optimized | GPU/parallel computing workloads |
4. General-purpose Machine Family
This is the most common family.
It provides a good balance between:
CPU + memory + price
Good for:
- Web servers
- Application servers
- Development/testing
- Small/medium databases
- General cloud applications
The important series discussed here are:
- E2
- N2
- N2D
- T2A
- T2D
4.1 E2
E2 = economical/general everyday computing
Good when you don't need specialized CPU performance.
Typical use cases:
- Web servers
- Development/test environments
- Small/medium applications
- Small/medium databases
- General workloads
Simple idea
If your application doesn't have demanding CPU requirements:
E2 is often a good low-cost choice.
Your previous Qwiklabs VMs using something like:
e2-medium
are examples of the E2 machine series.
Shared-core E2
Some E2 machines use shared CPU cores.
Instead of your VM having exclusive access to an entire physical CPU core, CPU resources can be shared.
This makes them useful for:
- Small applications
- Low-resource workloads
- Development/testing
Easy comparison
Standard VM → More dedicated CPU resources Shared-core VM → CPU resources shared → Lower cost → Good for small workloads
5. N2 and N2D
These are more powerful general-purpose options.
N2
Uses Intel processors.
Good for:
- Enterprise applications
- Medium/large databases
- Web applications
- Application servers
N2D
Uses AMD processors.
The important concept isn't memorizing the processor names.
Remember:
N2 = Intel-based general purpose
N2D = AMD-based general purpose
Both provide a good balance between:
performance ↔ cost
6. Tau T2A and T2D
Tau is designed for cost-effective scale-out workloads.
T2D
AMD-based and useful for workloads such as:
- Web servers
- Containerized microservices
- Media transcoding
- Large-scale Java applications
This is particularly interesting for you because Java applications are explicitly mentioned as a workload.
T2A
T2A is based on Arm processors.
Important concept:
T2A = Arm architecture
So unlike the typical x86 Intel/AMD environment, T2A uses Arm.
This matters because your application/software must support the Arm architecture.
7. Compute-optimized Family
Now we move from:
"I need a balanced VM"
to:
"My application needs a lot of CPU power."
The Compute-optimized family focuses on high CPU performance per core.
Examples:
- C2
- C2D
- H3
7.1 C2
Designed for CPU-intensive workloads.
Examples:
- High-performance computing
- Simulations
- Genomic analysis
- Media transcoding
- Electronic design automation
- Gaming workloads
- Applications where CPU performance per core is important
Key idea
General-purpose → Balance CPU + RAM Compute-optimized → Prioritize CPU performance
7.2 C2D
C2D is another compute-optimized series, based on AMD processors.
Good for:
- High-performance computing
- CPU-heavy applications
- Large computational workloads
Think:
C2/C2D = "I need serious CPU power."
8. Memory-optimized Family
Now imagine the opposite situation.
Your application doesn't necessarily need huge CPU power, but it needs a LOT of RAM.
That's where the Memory-optimized family comes in.
Examples:
- M1
- M2
- M3
These are designed for workloads with high memory requirements.
Common example
In-memory databases
For example:
- SAP HANA
- Large in-memory analytics
- Memory-intensive applications
Simple idea
Compute-optimized → More CPU-focused Memory-optimized → More RAM-focused
Why would a database need lots of RAM?
Suppose you have a huge dataset.
Instead of constantly reading data from slower storage:
Storage → RAM → CPU
An in-memory system can keep much more data in RAM:
Large amount of data ↓ RAM ↓ Fast processing
So memory-optimized VMs are useful for these workloads.
9. Accelerator-optimized Family
This family is for workloads that need GPUs/accelerators.
Typical workloads:
- Machine learning
- AI
- GPU computing
- High-performance computing
- Video processing
Examples discussed:
- A2
- G2
Why GPU?
A CPU is good at handling many different types of tasks.
A GPU is designed to perform many similar calculations in parallel.
For example:
CPU → General-purpose processing GPU → Massive parallel calculations
That's why GPUs are heavily used in:
- Machine learning
- Deep learning
- LLM workloads
- Image/video processing
A2
A2 machines use NVIDIA A100 GPUs.
An A100 has dedicated GPU memory.
This makes A2 suitable for demanding:
- ML training
- AI
- HPC
- Large computational workloads
G2
G2 machines use NVIDIA GPUs and are suitable for:
- ML training
- ML inference
- Video transcoding
- Remote visualization
Important distinction
Don't confuse:
VM RAM with GPU memory.
For example:
VM ├── vCPU ├── System RAM └── GPU └── GPU memory
10. Custom Machine Types
Google provides many predefined machine types.
But sometimes none of them are exactly what you need.
For example, suppose predefined options are:
4 vCPU + 16 GB RAM 8 vCPU + 32 GB RAM
But your application needs:
6 vCPU + 20 GB RAM
You could use a custom machine type if the configuration is supported.
Why custom machine types?
Because you can choose:
- Number of vCPUs
- Amount of memory
This allows you to better match the VM to your workload.
11. Predefined vs Custom
Predefined
Google gives you a ready-made configuration.
Example:
e2-medium
You don't independently choose every CPU/RAM value.
Custom
You specify the CPU and memory configuration yourself.
vCPU = X RAM = Y
Trade-off
Custom machine types can cost slightly more than an equivalent predefined configuration.
So:
Use predefined when it fits. Use custom when you need a specific CPU/RAM combination.
12. Custom Machine Type Rules
Important rules from the lesson:
vCPU
You can generally select:
1 vCPU OR even numbers of vCPUs
For example:
1 2 4 6 8 ...
Memory
Normal custom configurations have limits around:
1–8 GB RAM per vCPU
Memory also needs to follow Google's supported increments, such as 256 MB multiples.
13. Extended Memory
What if your application needs more than 8 GB RAM per vCPU?
Google Cloud provides extended memory for supported configurations.
Example concept:
8 vCPU + more than 64 GB RAM
The normal ratio would be:
8 vCPU × 8 GB = 64 GB
If your workload needs substantially more memory than that, extended-memory options may be available at additional cost.
14. The Most Important Decision
When choosing a VM, don't memorize every machine series.
Instead, ask:
Question 1 — What kind of workload?
Normal application? ↓ General-purpose CPU-heavy? ↓ Compute-optimized RAM-heavy? ↓ Memory-optimized GPU/AI-heavy? ↓ Accelerator-optimized
This is the core concept.
15. Quick Revision Table
| Family | Think | Example workloads |
|---|---|---|
| General-purpose | ⚖️ Balance | Web apps, APIs, databases |
| Compute-optimized | 🧮 CPU | HPC, simulations, transcoding |
| Memory-optimized | 🧠 RAM | SAP HANA, in-memory analytics |
| Accelerator-optimized | 🚀 GPU | AI/ML, HPC, video |
And within general-purpose:
E2 → Low-cost everyday workloads N2 / N2D → Balanced enterprise workloads T2A → Arm-based workloads T2D → Cost-effective scale-out workloads
16. Very Simple Mental Model
Remember this:
Machine family = What kind of power do I need?
Machine series = Which hardware generation/type?
Machine type = Exactly how much CPU/RAM do I get?
For example:
General-purpose ↓ E2 ↓ e2-medium ↓ Specific CPU + RAM configuration
And the overall decision:
VM workload │ ┌──────────────┼──────────────┐ ↓ ↓ ↓ Normal CPU-heavy RAM-heavy │ │ │ General-purpose Compute-optimized Memory-optimized │ └───────────┐ ↓ GPU/AI required? │ Yes ↓ Accelerator-optimized
⭐ Exam/interview points to remember
- vCPU = virtual CPU processing capacity.
- Memory = RAM available to the VM.
- Machine family is selected based on workload.
- General-purpose = balanced workloads.
- Compute-optimized = CPU-intensive workloads.
- Memory-optimized = RAM-intensive workloads.
- Accelerator-optimized = GPU/parallel workloads.
- E2 = economical general-purpose option.
- N2 = Intel general-purpose; N2D = AMD general-purpose.
- T2A = Arm-based; T2D = AMD-based scale-out workloads.
- Custom machine types let you choose CPU and memory more precisely.
- Predefined machine types are simpler and generally preferable when they fit.
- GPU memory and VM RAM are different things.
- Extended memory allows supported configurations to go beyond the normal memory-per-vCPU limit.
- Get link
- X
- Other Apps
Comments
Post a Comment