Designing Kubernetes Concurrent App Scheduling and Dynamic Node-Signal Extensions
System DesignModel answerLast updated
Architect concurrent pod scheduling under capacity limits and design a custom Kubernetes scheduler plugin that uses real-time node telemetry for placement.
During a technical design interview for a senior infrastructure position, you are presented with two connected Kubernetes scheduling challenges.
Part 1: Simultaneous Multi-Workload Scheduling Strategy
Four distinct application workloads are deployed to a production Kubernetes cluster at the exact same moment. You are given no preliminary specifications regarding workload sizes, priorities, or cluster state.
- Formulate a structured set of diagnostic questions to uncover system constraints. Group these questions by the architectural decision each drives (e.g., Capacity, Priority & Preemption, Isolation & Co-location, Rollout Strategy).
- Explicitly detail how different answers to your questions dictate specific Kubernetes primitives (such as
PriorityClass,PodDisruptionBudget,NodeAffinity,ResourceQuota, or custom custom schedulers). - State a concrete set of assumptions for the four applications and outline an execution plan to safely schedule and launch all four without causing deadlocks or starvation.
Part 2: Dynamic Node-Feedback Scheduler Plugin Design
The default Kubernetes scheduler places pods primarily based on declared resource requests (resources.requests), which often diverge significantly from actual runtime resource usage (CPU throttling, memory pressure, cache contention, disk IOPS).
Design a custom Kubernetes custom scheduler plugin system that continuously feeds real-time node telemetry back into the scheduling cycle to improve placement decisions.
Your design should specify:
- Telemetry Pipeline: Which node signals to collect, how they are gathered, and how they reach the custom scheduler efficiently and reliably.
- Plugin Integration: Where the custom logic fits into the standard Kubernetes Scheduling Framework extension points (e.g.,
Filter,Score,Reserve). - Edge Cases & Guardrails: How the plugin handles data staleness, metrics agent failures, scheduling hot-spots (thundering herd), and cold starts.
- Rollout & Validation: A strategy to safely roll out the plugin and quantify whether placement quality has actually improved.
Hints
Hint 1
Group your clarifying questions by operational domain (Capacity, Priority, Co-location, Rollout) to demonstrate systematic architecture discovery.
Hint 2
Remember that the default Kubernetes scheduler processes pods one at a time from an active queue; simultaneous deployments are ordered by PriorityClass and creation timestamp.
Hint 3
For the plugin design, leverage standard Kubernetes Scheduler Framework extension points like Filter (hard constraints) and Score (soft weighting).
Hint 4
Address the latency and reliability of telemetry carefully: avoid synchronous API calls during the scheduling cycle by using local in-memory caches populated via Custom Resource Definitions (CRDs) or lightweight streaming.
Model answer
Hard Try it yourself first — then compare your approach, complexity and edge cases.
Part 1: Simultaneous Multi-Workload Scheduling Strategy
1. Structured Discovery Matrix
When facing an ambiguous multi-workload deployment, we must systematically evaluate constraints across four core domains:
| Category | Diagnostic Question | Kubernetes Mechanism Driven |
|---|---|---|
| Capacity & Sizing | What are the CPU/RAM requests/limits for each app? Are workloads elasticity-aware? | ResourceQuota, LimitRange, Cluster Autoscaler (Karpenter) |
| Priority & Preemption | If resources are insufficient, which app must run first? Can existing pods be evicted? | PriorityClass (preemptionPolicy), PodDisruptionBudget |
| Placement Topology | Do workloads need co-location, fault isolation, or specific hardware (GPUs)? | nodeAffinity, podAffinity / podAntiAffinity, tolerations |
| Lifecycle & Coupling | Must applications launch in a strict sequential sequence, or can they start out-of-order? | initContainers, Readines Probes, Gang Scheduling (Kube-scheduler framework extensions like Coscheduler) |
2. Technical Mapping of Responses to Kubernetes Primitives
- If capacity is constrained and App A is critical (e.g., payment gateway) while App D is background processing:
- Assign
PriorityClasswith highvalue(e.g.,1000000) to App A and lowvalue(e.g.,1000) to App D. - Set
preemptionPolicy: PreemptLowerPriorityon App A to allow evicting lower-priority pods if the cluster is full.
- Assign
- If App B and App C must not share failure domains (high availability):
- Define
podAntiAffinitywithtopologyKey: kubernetes.io/hostname(hard requirement viarequiredDuringSchedulingIgnoredDuringExecution).
- Define
- If App C depends on App B’s database migrations:
- Wrap initialization in App C using
initContainersthat check App B's readiness endpoint, or rely on operator custom controllers rather than raw parallel manifests.
- Wrap initialization in App C using
3. Execution Plan Under Stated Assumptions
Assumed Scenario Parameters
- Cluster State: Fixed 10-node cluster, total remaining head-room: 16 vCPUs, 32 GiB RAM.
- Workload Profiles:
- App A (Core API): High priority, 4 replicas, 2 vCPU / 4 GiB per replica (Total: 8 vCPU, 16 GiB).
- App B (Database): State-critical, single replica, 4 vCPU / 8 GiB (Total: 4 vCPU, 8 GiB).
- App C (Worker): Medium priority, 8 replicas, 1 vCPU / 2 GiB per replica (Total: 8 vCPU, 16 GiB).
- App D (Analytics): Low priority, batch job, 4 vCPU / 8 GiB (Total: 4 vCPU, 8 GiB).
- Aggregate Resource Demand: 24 vCPUs, 48 GiB RAM (Exceeds available headroom of 16 vCPU / 32 GiB).
Total Demanded: 24 vCPU / 48 GiB
Cluster Capacity: 16 vCPU / 32 GiB
+-------------------------------------------------------------+
| [App A: Core API] 8 vCPU / 16 GiB (Priority: High) | -> Scheduled (1st)
| [App B: Database] 4 vCPU / 8 GiB (Priority: Critical) | -> Scheduled (2nd)
| [App C: Worker] 4 vCPU / 8 GiB (Priority: Medium) | -> Partially Scheduled (4 of 8 replicas)
| [App D: Analytics] 0 vCPU / 0 GiB (Priority: Low) | -> Queued (Pending)
+-------------------------------------------------------------+
Rollout Step-by-Step Execution
-
Priority Ordering: Apply manifest configurations defining explicit priorities:
- App B:
PriorityClass: 200000(Critical System) - App A:
PriorityClass: 100000(User-Facing API) - App C:
PriorityClass: 50000(Background Workers) - App D:
PriorityClass: 10000(Non-urgent Batch)
- App B:
-
Scheduling Execution Cycle:
- Queue Processing: The
kube-schedulersorts unscheduled pods in its active queue byPriorityClass. - Step 1: App B is evaluated and scheduled onto Node-1 (Consumes 4 vCPU / 8 GiB). Remaining: 12 vCPU / 24 GiB.
- Step 2: App A’s 4 replicas are evaluated next. All 4 are scheduled across available nodes. (Consumes 8 vCPU / 16 GiB). Remaining: 4 vCPU / 8 GiB.
- Step 3: App C’s 8 replicas arrive next. The scheduler places 4 replicas (using the remaining 4 vCPU / 8 GiB). The remaining 4 App C replicas enter
Pendingstate. - Step 4: App D is evaluated. Because App D has lower priority than App C and cannot preempt App C, App D remains
Pending.
- Queue Processing: The
-
Autoscaling & Recovery Trigger:
- The pending pods of App C and App D trigger the Cluster Autoscaler (or Karpenter), which provisions 2 additional nodes.
- Once new nodes register as
Ready, the scheduler processes the remaining 4 replicas of App C followed by App D, achieving full operational state without service degradation for App A or App B.
Part 2: Dynamic Node-Feedback Scheduler Plugin Design
1. Architecture & Telemetry Pipeline
To prevent placing pods on nodes suffering from noisy neighbors, high memory pressure, or IO throttling, we collect dynamic node metrics and make them available to the scheduler out-of-band.
+-----------------------------------------------------------------------+
| NODE |
| +--------------------+ +--------------------------------------+ |
| | Prometheus Node | ----> | Node-Telemetry Agent | |
| | Exporter / cAdvisor| | (DaemonSet - pushes every 2 seconds) | |
| +--------------------+ +------------------+-------------------+ |
+-------------------------------------------------|---------------------+
|
v
+------------------------------------+
| NodeMetrics CRD / Shared Informer |
+------------------+-----------------+
|
v
+-------------------------------------------------|---------------------+
| KUBE-SCHEDULER PROCESS | |
| +------------------v-------------------+ |
| | Custom Scheduler Plugin Cache | |
| | (In-Memory Concurrent Read) | |
| +------------------+-------------------+ |
| | |
| [Filter Phase] ---> [Score Phase] ---> [Reserve Phase] |
+-----------------------------------------------------------------------+
Collected Signals
- Real-Time CPU Usage & Steal Time: Moving average (15s/1m window) of actual CPU utilization and hypervisor steal time.
- Memory Pressure Index: Available memory percentage minus active cache pressure (prevents OOM kills).
- Disk IOPS & Latency: Storage queue depth and read/write latencies.
Pipeline Topology
- DaemonSet Agent: A lightweight binary running on each node reads metrics from
/proc, cgroups, and local eBPF programs. - Publishing Path: Writes state to a lightweight Custom Resource (
NodeMetrics) or directly streams to an in-memory gRPC service co-located with the custom scheduler instance. - Local In-Memory Cache: The scheduler plugin consumes data via an Informer pattern, maintaining an $O(1)$ lookup table of node metrics inside the scheduler process. Crucially, the plugin never executes network calls inside the scheduling loop.
2. Scheduler Plugin Integration Points
The plugin hooks into the Kubernetes Scheduling Framework:
// Simplified Go conceptual implementation of the scoring plugin
type DynamicMetricsScorer struct {
handle framework.Handle
cache *NodeMetricsCache
}
func (s *DynamicMetricsScorer) Name() string {
return "DynamicNodeMetricsScorer"
}
// Filter out nodes under severe physical stress
func (s *DynamicMetricsScorer) Filter(ctx context.Context, state *framework.CycleState, pod *v1.Pod, nodeInfo *framework.NodeInfo) *framework.Status {
metrics, err := s.cache.GetNodeMetrics(nodeInfo.Node().Name)
if err != nil {
// Fallback: If metrics missing, allow node to pass filter
return framework.NewStatus(framework.Success, "")
}
// Hard boundary: Do not schedule onto nodes with >95% actual memory usage
if metrics.MemoryUsagePercent > 95.0 || metrics.CPUStealTimePercent > 15.0 {
return framework.NewStatus(framework.Unschedulable, "Node experiencing critical resource pressure")
}
return framework.NewStatus(framework.Success, "")
}
// Score ranks suitable nodes based on real-time headroom
func (s *DynamicMetricsScorer) Score(ctx context.Context, state *framework.CycleState, p *v1.Pod, nodeName string) (int64, *framework.Status) {
metrics, err := s.cache.GetNodeMetrics(nodeName)
if err != nil {
return 50, framework.NewStatus(framework.Success, "") // Default baseline score
}
// Calculate composite score (0 - 100)
// Higher headroom = higher score
cpuHeadroom := 100.0 - metrics.CPUUtilization1m
memHeadroom := 100.0 - metrics.MemoryUsagePercent
// Normalize and weight components (60% Memory, 40% CPU)
compositeScore := int64((memHeadroom * 0.6) + (cpuHeadroom * 0.4))
return compositeScore, framework.NewStatus(framework.Success, "")
}
3. Guardrails, Failures, and Edge Cases
- Stale Telemetry Handling:
- Each
NodeMetricsupdate includes an atomic timestamp. IfcurrentTime - metricTimestamp > 10 seconds, mark the node data as Stale. - On staleness, the plugin bypasses dynamic scoring for that node and falls back to standard
NodeResourcesFitdefault scoring.
- Each
- Thundering Herd & Optimistic Pessimism:
- If multiple large pods schedule in rapid succession within a single 2-second telemetry window, the dynamic metric will lag.
- Mitigation: Implement a Reserve Phase hook. When a pod is assigned to a node in memory, the plugin optimistically subtracts the pod’s declared requests from the node’s cached real-time capacity until the next fresh metric heartbeat arrives.
- Missing Telemetry (Cold Start):
- Newly added nodes receive a neutral score (50/100) until the first telemetry heartbeat is verified.
4. Safe Rollout and Validation Strategy
Shadow Scheduling Mode (Phase 1)
Deploy the plugin registered only to the Score extension point in Log-Only / Shadow Mode. The custom plugin calculates scores and logs the proposed placement choice, but returns a neutral score (0) to the scheduler framework so actual pod placement remains driven by standard rules.
Canary Deployment (Phase 2)
Run the custom scheduler binary alongside default-scheduler using a distinct schedulerName: dynamic-telemetry-scheduler. Assign a non-critical subset of workloads (e.g., 10% of batch workers) to the custom scheduler.
Quantitative Metrics for Success
Evaluate effectiveness across three key production metrics over a 14-day observation window:
- OOM-Kill Rate: Compare total
OOMKilledpod events between nodes managed by standard vs. dynamic scheduling. Target: >50% reduction. - CPU Throttling Ratio: Measure container CPU throttling metric
container_cpu_cfs_throttled_periods_total / container_cpu_cfs_periods_total. Target: >30% reduction. - P99 Scheduling Latency: Measure
scheduler_framework_extension_point_duration_seconds{extension_point="Score"}. Ensure custom plugin execution adds < 2ms overhead per pod.