Chapter 8 - Resource Management & VM CPU Schedulers
Chapter 8 — Resource Management & VM CPU Schedulers
CSS451 Cloud Computing · Cheat Sheet
🧭 Big Picture First
Think of a hypervisor like a hotel manager:
- The hotel has limited rooms (physical CPUs)
- Many guests (VMs) want to check in
- The manager must decide who gets a room, for how long, and how fairly
- That decision process = Resource Management & Scheduling
1. Cloud Resource Management Policies
Five policies that govern how cloud resources are managed:
| # | Policy | What It Does | Real Example |
|---|---|---|---|
| 1 | Admission Control | Prevents the system from accepting more work than it can handle | API server caps at 10,000 req/sec → extra requests get HTTP 503 or queued |
| 2 | Capacity Allocation | Assigns specific resources to each service | Service A → 2 vCPU + 4 GB RAM; Service B → 1 vCPU + 2 GB RAM |
| 3 | Load Balancing | Distributes workload evenly across servers | Round-robin across 3 web servers |
| 4 | Energy Optimisation | Minimises energy consumption | Consolidate VMs onto fewer servers at night, power down the rest |
| 5 | QoS Guarantees | Ensures SLA conditions are met | Uptime ≥ 99.9%, Response ≤ 200ms, Latency ≤ 50ms |
Policy vs Mechanism
- Policy = the rule (what to do) → "Premium customers get priority"
- Mechanism = the enforcement tool (how to do it) → the actual queue/software that enforces the rule
2. Server Load Balancing
- Distributes client traffic to servers for consistent, high-performance delivery
- Ensures: application delivery · scalability · reliability · high availability
Two Types
| Type | How It Works |
|---|---|
| Transport-level | DNS-based; acts independently of application payload |
| Application-level | Uses actual traffic load to make smarter balancing decisions (e.g., Windows Server Load Balancing) |
Analogy: A load balancer is like a restaurant host — they seat customers (requests) across different tables (servers) so no single table gets overwhelmed.
3. Scheduling Fundamentals
Scheduling = deciding how to allocate resources (CPU, memory, storage, I/O, network) between users and tasks.
A scheduler is the program that implements a particular scheduling algorithm.
Three Evaluation Criteria for Any System
- Functionality — Does it work correctly?
- Performance — Does it perform well?
- Cost — How much does it cost?
- Processing Cost (computation time)
- Communication Cost
- Storage Cost
Why Is Cloud Scheduling Hard?
- Requires complex multi-objective decisions simultaneously
- Impossible to have accurate global state at all times
- Large, fluctuating loads challenge cloud elasticity
- Unpredictable interactions (failures, attacks, spikes)
Scheduling Algorithm Goals
A good scheduling algorithm must be:
- Efficient — fast and performant
- Fair — no single VM hogs all resources
- Starvation-free — every process eventually gets CPU time
Starvation = a process is perpetually denied the resources it needs. Can be caused by scheduling errors, resource leaks, or attacks (e.g., fork bomb).
Objectives by Application Type
| Application Type | Scheduling Objective |
|---|---|
| Batch system | Maximise throughput |
| Real-time system | Meet deadlines (e.g., K-Plus payment) |
Common Scheduling Algorithms
- Round-Robin — Each process gets equal time slices in rotation
- First-Come-First-Serve (FCFS) — Process that arrives first runs first
- Shortest-Job-First (SJF) — Shortest estimated burst time runs first
Deadline Types
| Type | Description |
|---|---|
| Hard Deadlines | Strict — penalties apply if missed. Expressed in ms/sec |
| Soft Deadlines | Guidelines — no penalty if missed by a small margin |
4. Key Scheduling Concepts
4.1 Proportional Share (PS) Scheduling
Each VM gets CPU proportional to its weight (shares).
Equal priority case: each of processes gets
Example
| Process | Shares | CPU % |
|---|---|---|
| P1 | 100 | 100/600 = 16.7% |
| P2 | 200 | 200/600 = 33.3% |
| P3 | 300 | 300/600 = 50.0% |
Analogy: Like splitting a pizza — if you paid for 3 slices and your friend paid for 1, you get 3/4 of the pizza.
PS Pros & Cons
| ✅ Pros | ❌ Cons |
|---|---|
| Works well under CPU overcommit | Not suitable for hard real-time systems |
| Prevents starvation | Cannot guarantee strict deadlines |
| Allows VM-level guarantees | No deterministic latency |
| Scales to many processes | |
| Simple to implement |
CPU Overcommit = allocating more vCPUs than physical cores exist. Example: 8 physical cores, 6 VMs × 4 vCPUs = 24 vCPUs → Overcommit ratio = 24:8 = 3:1 Like a hotel overbooking rooms — works fine until everyone shows up at once.
4.2 Work-Conserving vs Non-Work-Conserving
| Mode | Behaviour | CPU Shares Are... |
|---|---|---|
| Work-Conserving (WC) | If CPU is free and there's work to do, use it | Guarantees (minimum) |
| Non-Work-Conserving (NWC) | Clients get exactly their share, nothing more, even if CPU is free | Caps (maximum) |
WC = "If someone's done, let others use the leftover time." NWC = "You get exactly your slot — nothing more, nothing less."
4.3 Preemptive vs Non-Preemptive Schedulers
| Feature | Preemptive | Non-Preemptive |
|---|---|---|
| Resource allocation | For a limited time (time slice) | Held until process terminates |
| Interruption | Can be interrupted mid-execution | Not interrupted until done |
| Starvation risk | Due to priority insertion | Due to large burst time monopoly |
| Overhead | Requires queue + remaining time tracking | No such overhead |
⭐ Exam Q: Why is preemption good for I/O-intensive workloads? I/O-bound processes frequently wait for disk/network. Preemption lets the CPU serve other processes during those waits, rather than sitting idle.
4.4 Completely Fair Scheduler (Linux CFS)
- Default CPU scheduler in Linux (since kernel 2.6.23)
- Goal: fair CPU time distribution among all runnable processes
Key Concept: vruntime
- Each process tracks virtual runtime (vruntime) — increases as the process runs
- Scheduler always picks the process with the smallest vruntime next
- Processes that ran less recently get priority → fairness over time
Two Key Properties
- Long-term Fairness — All equal-priority processes receive approximately equal CPU over time
- Immediate Decision — At each scheduling point, run the process with smallest
vruntime
Analogy:
vruntimeis like a debt counter. Whoever used the CPU least recently has the lowest "debt" and gets to go first. Over time, everything levels out.
4.5 Workload Management
Workload Management = ability to precisely assign (CPU, memory, I/O) resources to applications.
| Approach | How It Works | Problem |
|---|---|---|
| Static | Resources estimated once and assigned permanently | Over-provisioning (wasted resources) |
| Dynamic | Resources allocated and adjusted to match actual demand | More complex to implement |
Dynamic workload managers typically use PS schedulers in NWC mode for performance isolation.
5. Resource Management in Virtualized Servers
Key challenges:
- Many different, mixed workloads
- Finite workloads per server
- Workload requirements change over time
- Need performance and resource isolation between VMs
6. Xen CPU Schedulers — Case Study
Three schedulers introduced in Xen VMM (Virtual Machine Monitor), in order:
| Scheduler | Era | Core Idea |
|---|---|---|
| BVT | Oldest | Virtual time + fair-share |
| SEDF | Middle | Deadline-based |
| Credit | Current | Weight + credits + load balancing |
6.1 Borrowed Virtual Time (BVT)
Core Idea: Fair-share scheduler based on virtual time. Runs the VM with the lowest virtual time first.
How It Works
- Each thread has a virtual time counter
- Scheduler always picks the thread with the smallest virtual time
- Latency-sensitive apps can "borrow" from their future CPU time to jump the queue
- After borrowing, the thread's virtual time is penalized to compensate
- Long-term fairness is maintained — borrowing only creates a temporary priority boost
BVT Example
Scheduler compares Effective Virtual Time (EVT) = Raw VT − Borrowed
| Thread | Raw VT | Borrowed | EVT | Runs... |
|---|---|---|---|---|
| Thread-2 | 10 | 0 | 10 | 1st (tied) |
| Thread-3 | 15 | 5 | 10 | 1st (tied) |
| Thread-1 | 20 | 0 | 20 | Last |
After Thread-3 runs, its VT increases, so it drops down the queue → fairness restored.
BVT Characteristics
| ✅ | ❌ |
|---|---|
| Preemptive | WC-mode only (no NWC) |
| Optimally fair | Limits performance isolation |
| Low-overhead on uni- and multiprocessors |
⭐ Exam Q: What's the problem with BVT? If a process keeps borrowing and borrowing → unfairness accumulates. Long-term fairness breaks down under repeated borrowing.
6.2 Simple Earliest Deadline First (SEDF)
Core Idea: Deadline-based scheduler — the VM with the earliest deadline runs next.
Parameters Per Domain
| Parameter | Meaning |
|---|---|
| Slice — how much CPU time the domain gets | |
| Period — how often it receives that slice | |
| Extra — can it receive extra CPU in WC-mode? (1 = yes) |
Domain receives time units every period of length .
Assigning 30% CPU
Two valid configurations:
(3ms, 10ms, 0)→ gets 3ms every 10ms(30ms, 100ms, 0)→ gets 30ms every 100ms
Both give 30% — but the period size affects behavior:
| Factor | Small Period (3ms, 10ms) | Large Period (30ms, 100ms) |
|---|---|---|
| Granularity | More frequent CPU slices | Less frequent |
| Latency | Lower (better for interactive) | Higher |
| Burst Length | Short (3ms at a time) | Long (30ms uninterrupted) |
| Context Switches | More (higher overhead) | Fewer (lower overhead) |
| Best For | Real-time, interactive tasks | Batch / compute-heavy workloads |
Burst Time = time needed to execute the process (processing time)
⭐ Exam Q: What determines the proper choice of and ? Answer: C. Throughput
SEDF Example
- P1:
(3ms, 10ms, 0)→ runs 3ms every 10ms, deadline = 10ms - P2:
(5ms, 15ms, 0)→ runs 5ms every 15ms, deadline = 15ms
Execution (Earliest Deadline First):
- Time 0: P1 runs for 3ms (deadline 10 < 15 → P1 first)
- Time 3: P2 runs for 5ms (P1 done, P2 deadline 15)
- Time 8: P1 runs again (new deadline 20)
- Time 11: P2 runs again (new deadline 30)
- Pattern continues...
SEDF Characteristics
| ✅ | ❌ |
|---|---|
| Preemptive, supports WC and NWC | Fairness depends on period value |
| Precise timing guarantees | Per-CPU queue — no global load balancing |
| Good for real-time workloads | Not ideal for large-scale VM deployments |
When to Use SEDF
| ✅ Use For | ❌ Avoid For |
|---|---|
| Hard real-time guarantees | Large numbers of VMs |
| Deterministic latency requirements | Non-real-time workloads |
| Safety-critical VMs | Heavy overcommit environments |
| Automotive hypervisors, industrial control | General-purpose cloud |
6.3 Credit Scheduler (Current Xen Default)
Core Idea: Proportional-share scheduler with automatic global load balancing across all physical CPUs on SMP hosts.
Parameters Per VM
| Parameter | Meaning |
|---|---|
| Weight | Determines proportional CPU share |
| Cap = 0 | VM can receive extra idle time → WC-mode |
| Cap ≠ 0 | VM is limited to cap value → NWC-mode |
How It Works
- Each VM gets an initial credit allocation proportional to its weight
- When a VM runs → it spends credits
- Scheduler picks the VM with the highest remaining credits next
- If credits go negative → VM is deprioritized (let others run)
- Idle VMs accumulate credits (but don't consume them)
- Before any CPU goes idle → scheduler checks other CPUs for runnable vCPUs (global load balancing)
Credit Allocation Example
| VM | Weight | CPU Allocation |
|---|---|---|
| VM1 | 200 | 200/600 = 33.3% |
| VM2 | 100 | 100/600 = 16.7% |
| VM3 | 300 | 300/600 = 50.0% |
If VM2 becomes idle → its share is redistributed to active VMs.
Timing
- Works in 30ms slices — a vCPU runs for 30ms before being preempted
- Credits of all runnable VMs recalculated every 30ms
- CPU usage monitored every 10ms
Credit Scheduler Characteristics
| ✅ | Notes |
|---|---|
| Preemptive | Supports both WC and NWC modes |
| Automatic global load balancing | Key advantage over BVT and SEDF |
| No CPU goes idle with runnable work | Efficient multiprocessor utilization |
Analogy: Credit Scheduler = a taxi dispatcher that automatically reassigns idle drivers to busy pickup zones. Fair, efficient, and globally aware.
7. Evolution: BVT → SEDF → Credit
| Transition | What Was Added |
|---|---|
| BVT → SEDF | Added NWC mode (performance isolation via caps) |
| BVT/SEDF → Credit | Added automatic global load balancing on SMP systems |
Full Comparison
| Feature | BVT | SEDF | Credit |
|---|---|---|---|
| Scheduling Basis | Virtual time (fair-share) | Earliest deadline | Credit/weight |
| Mode | WC only | WC + NWC | WC + NWC |
| Load Balancing | ❌ No | ❌ No (per-CPU queue) | ✅ Yes (global SMP) |
| Real-time Support | ❌ No | ✅ Yes | ❌ No |
| Starvation Prevention | ✅ Yes | Depends on config | ✅ Yes |
| Best For | Fair sharing, simple cases | Periodic real-time tasks | General-purpose cloud VMs |
8. Challenges in VMM Scheduling
Three main challenges compared to OS scheduling:
| Challenge | Cause | Description |
|---|---|---|
| Semantic Gap | OS independence | Two independent scheduling layers. VMM sees each VM as a black box — cannot see inside |
| Scarce Information | Small TCB | Hard to extract workload characteristics. Only I/O and privileged instructions visible to VMM |
| Inter-VM Fairness | Performance isolation | Favoring one VM must not compromise others |
Two competing goals for VMM design:
- Lightweightness — No cross-layer optimization
- Efficiency — Intelligent, informed VMM decisions
9. I/O Model in Xen
- Dom0 performs I/O on behalf of all guest VMs
- Dom0 itself requires CPU allocation to process I/O for other VMs
- Key question: How much CPU should Dom0 get?
Findings from experiments:
- As Dom0 weight increases relative to Dom1 → web server throughput decreases (Dom1 gets less CPU)
- As SEDF period increases → throughput decreases (longer gaps between CPU slices → higher latency)
10. Experimental Comparison (Paper Summary)
Benchmarks: Web server (req/sec), Iperf (network Mbits/s), Disk read (MB/s) Setup: Dual CPU HP workstations, 1-GHz PIII, 2GB RAM, Xen 3.0.3
Key Findings
| Scenario | Finding |
|---|---|
| Single node | All three schedulers perform similarly |
| SMP (multi-CPU) | Credit scheduler increases throughput with more VMs due to global load balancing |
| I/O workloads | Highly sensitive to Dom0 CPU allocation across all schedulers |
| Credit vs SEDF/BVT on SMP | Credit throughput sometimes lower in single-node case due to higher allocation error |
11. Summary Table
| Concept | Key Point |
|---|---|
| PS Scheduling | CPU share ∝ weight. Prevents starvation. No deadline guarantees. |
| WC Mode | CPU shares = guarantees (minimums). Idle CPU is redistributed. |
| NWC Mode | CPU shares = caps (maximums). Strict isolation. |
| Preemptive | Process can be interrupted. Good for I/O workloads. |
| CFS (Linux) | Picks process with smallest vruntime. Fair over time. |
| BVT | Fair-share via virtual time. WC only. Borrowing can cause unfairness. |
| SEDF | Deadline-based. WC + NWC. No global load balancing. |
| Credit | Weight + credits + global SMP balancing. Current Xen default. |
| CPU Overcommit | More vCPUs than physical cores. Scheduler time-shares. |
| Starvation | Process perpetually denied resources. Good schedulers prevent this. |
Overall Analogy for the Whole Chapter: Imagine a theme park (cloud) with limited rides (CPUs).
- Admission control = how many people enter the park
- Capacity allocation = which rides each group gets
- Load balancing = distributing people across rides so no single ride queues for 3 hours
- Scheduler = the park staff deciding who boards next, for how long, and whether someone can "borrow" a spot
- BVT = fair queuing with an express-pass you repay later
- SEDF = reserved time slots (you pre-book your 3-minute ride window)
- Credit = a points system where popular rides auto-reassign to wherever the crowd is thickest