Cloud Compute Options and Trade-offs Questions
Choosing among compute abstractions independent of provider: virtual machines, containers, managed container services, serverless functions, and bare metal. Covers the cost, control, cold-start, scaling, and operational trade-offs of each model; how to pick an instance family or hardware accelerator (general-purpose, compute-optimized, memory-optimized, GPU, TPU) and a purchasing model (on-demand, reserved, spot); and how workload characteristics (latency, statefulness, burstiness) drive the decision. Managed-versus-self-managed reasoning lives here.
Describe the main autoscaling approaches available for cloud compute: horizontal autoscaling (of pods or instances), vertical scaling, scheduled scaling, and predictive autoscaling. For each approach, explain typical use cases, benefits, and the pitfalls it can introduce in production.
Sample Answer
Direct answer
There are four main ways cloud compute scales: horizontal autoscaling (adding or removing instances or pods), vertical scaling (resizing an existing instance or pod), scheduled scaling (changing capacity at known times), and predictive autoscaling (forecasting demand from historical patterns and scaling ahead of it). They aren't mutually exclusive: most mature systems combine horizontal scaling as the default mechanism with scheduled or predictive scaling layered on top to compensate for the lag horizontal scaling can't avoid.
Structured elaboration
| Approach | How it works | Best fit | Pitfall it introduces |
|---|---|---|---|
| Horizontal autoscaling | Add or remove replicas (instances, pods, or function concurrency) in response to a metric like CPU utilization, queue depth, or request rate | Stateless services with roughly linear per-replica capacity; the default choice for web tiers and APIs | Scale-out lag: a new replica has to boot, warm up, and pass a readiness check before it can take traffic, so a sharp spike still causes a window of overload before capacity catches up. It also silently assumes the workload is stateless, if it isn't, adding replicas doesn't add usable capacity |
| Vertical scaling | Resize the CPU/memory of an existing instance or pod (or a Kubernetes Vertical Pod Autoscaler adjusting requests/limits) | Single-instance workloads that can't be easily distributed (a monolith with in-memory caching, a stateful database primary) or right-sizing chronically over- or under-provisioned pods | Almost always requires a restart to apply, so it can't respond to a live spike; it also has a hard ceiling, the largest instance size in the family, after which you must re-architect regardless of budget |
| Scheduled scaling | Pre-set capacity changes tied to a calendar (scale up before a known 9am traffic ramp, scale down overnight) | Traffic with a reliable, human-understood rhythm: business-hours SaaS traffic, a nightly batch window, a known marketing-campaign launch time | It only knows what you tell it. Any deviation from the assumed schedule (a flash sale that lands outside the pre-scaled window, a holiday that breaks the usual weekday pattern) leaves you exactly as exposed as having no autoscaling at all |
| Predictive autoscaling | A model trained on historical load forecasts near-term demand and scales ahead of it, so new capacity is already warm when the spike actually arrives | Workloads with enough historical signal and gradual-enough traffic curves that a forecast has time to act on, recurring but not perfectly calendar-based load | It's only as good as the history it was trained on: a genuinely novel event (a product launch, a viral spike, a first Black Friday) has no precedent in the training data, so the model under-forecasts exactly when you need it most, and a noisy or misconfigured model can also over-trigger, causing cost-wasting scale-up/scale-down thrashing |
Worked example
Take a Kubernetes Horizontal Pod Autoscaler (HPA) targeting 70% average CPU utilization, currently running 3 pods:
- Traffic doubles. Average CPU crosses 70%, the HPA computes a new desired replica count and requests more pods, say scaling toward 6.
- Each new pod needs to be scheduled onto a node (if there's capacity), pull its container image if it isn't cached, start the process, and pass its readiness probe. If that pipeline takes 45 seconds end to end and traffic doubled in 15 seconds, there's a 30-second window where the existing 3 pods are absorbing load meant for 6, likely with elevated latency or dropped requests.
- Layering scheduled scaling on top (if this spike happens at a known daily peak, pre-scale to 5 pods 10 minutes beforehand) removes that 30-second gap entirely for the known case, while horizontal autoscaling still handles the unknown residual variance around it. That combination, not either mechanism alone, is what most production systems actually run.
Trade-offs and pitfalls
- Horizontal autoscaling only helps if the workload can actually be replicated; a service holding local, unshared state (an in-memory cache with no replication, a long-lived stateful connection) needs to externalize that state first, or scaling out just multiplies inconsistent copies of it.
- Aggressive scale-in policies save money but risk oscillation: scaling down too eagerly right after a scale-up, then scaling back up seconds later as the same traffic returns. A stabilization window (only scale in if the metric has stayed low for several minutes) trades a little cost for a lot of stability.
- Vertical and horizontal scaling solve different problems and are sometimes used together (vertically right-size a pod's per-replica footprint, then horizontally scale the number of replicas), not as competitors.
- Predictive autoscaling adds real operational cost of its own: someone has to own model retraining, drift detection, and a fallback path for when the forecast is simply wrong, it's not a "set and forget" layer on top of the simpler mechanisms.
You must host a REST API with predictable traffic peaking at 100 requests/sec, per-request compute under 50ms, and a compliance requirement to retain logs for 7 years. Choose between VMs, containers on managed Kubernetes, and serverless functions. Explain your recommended compute platform, the logging and storage choices that satisfy retention and compliance, a minimal monitoring stack, and the trade-offs you considered.
Sample Answer
Direct answer
Recommend containers on managed Kubernetes for the compute platform. A hundred requests per second with sub-50-millisecond per-request compute is comfortably within a small, steady container fleet's capability with no cold-start risk, and the seven-year log-retention requirement is a storage and compliance decision that's largely independent of which compute model is chosen, so it shouldn't itself rule serverless in or out. It's the combination of steady, moderate traffic and a tight latency figure that favors always-warm containers here.
Compute platform choice
At 100 requests per second with a 50-millisecond compute budget, all three options, virtual machines, containers on managed Kubernetes, and serverless, can technically hit the latency target once warm. The discriminator is that serverless risks an occasional cold-start outlier against a tight budget for no offsetting benefit, since traffic here is steady rather than spiky, which is serverless's main advantage. A self-managed virtual-machine fleet takes on manual scaling and patching for no benefit over managed Kubernetes at this traffic level. Containers on managed Kubernetes, with a small autoscaled replica count sized with headroom above the 100 requests-per-second baseline, is the balanced choice: predictable latency, moderate operational burden, and room to grow.
Logging and storage for retention and compliance
Separate "hot" operational logs, recent logs used for debugging and monitoring, kept in a fast-query store for a much shorter window such as weeks to a few months, from the long-term compliance retention copy, shipped to durable, low-cost object storage with a retention policy that enforces the seven-year minimum and prevents early deletion. A compliance retention requirement usually implies genuine immutability, not just logs happening to still be around. Make the retention policy, access controls, and any required audit trail on who accessed the logs explicit and tested, since a compliance requirement is about provable retention and access control, not accidental survival.
Minimal monitoring stack
Track request rate, error rate, and latency percentiles, especially the 95th and 99th, against the 50-millisecond compute budget, since an average latency figure would hide exactly the tail risk this workload cares about. Track container and pod health and replica count as the platform-level signal. And add a specific alert on the health of the log-shipping and retention pipeline itself, since that pipeline failing silently, logs simply stopping short of the long-term store, is a distinct and easy-to-miss failure mode separate from the application being healthy.
Trade-offs considered
Choosing containers over serverless gives up serverless's near-zero idle cost, but this workload isn't idle-heavy, since 100 requests per second is steady rather than spiky, so that trade is a clear win for latency predictability. Choosing managed over self-managed Kubernetes gives up some control-plane customization (fine-grained control over the cluster's own management components, such as the API server and scheduler) in exchange for not owning control-plane operations, the right trade for a team whose actual requirement here is compliance and latency, not control-plane customization. Separating hot and long-term log storage adds a second storage system and a pipeline between them, versus dumping everything into one store for seven years, but a single store sized and priced for seven-year retention of every operational log line would be needlessly expensive and slow to query for day-to-day debugging.
Trade-offs and pitfalls
A common pitfall is treating the seven-year retention requirement as a compute-platform decision, when it's really a storage and pipeline decision; don't let it push the compute choice away from what actually fits the latency and traffic profile. A second is measuring against average latency instead of the tail, when the stated requirement implies every request needs to hit the compute budget, not just most of them; validate the 50-millisecond figure against the percentile that matters and load-test the tail specifically, not just the mean.
Explain the operational trade-offs between using managed GPU clusters from a cloud vendor versus running your own self-hosted GPU clusters on Kubernetes. Cover productivity, cost predictability, hardware control, scheduling complexity, portability, and long-term maintenance.
Sample Answer
Direct answer
Managed graphics processing unit (GPU) clusters trade a real cost premium for productivity and predictability: someone else handles driver and firmware updates, hardware failures, and scheduling, and you get GPU capacity on demand without a capital commitment. Self-hosted GPU clusters on Kubernetes (an open-source system for running and scaling many containers across a fleet of machines) trade that convenience for cost efficiency at sustained high utilization and full control over the hardware and stack. The crossover isn't about which is "better," it's about whether your utilization is sustained enough, and your team large enough, to make owning the operational burden pay off.
Structured elaboration
| Dimension | Managed GPU clusters | Self-hosted GPU on Kubernetes |
|---|---|---|
| Productivity | High: request capacity, get a working cluster, focus on the workload | Lower initially: you own driver/firmware compatibility, GPU device plugin configuration, and node health, all before a single training job runs |
| Cost predictability | Pay-as-you-go or reserved pricing, invoiced regularly, easy to forecast | Large upfront capital cost (or a long-term reservation) amortized over time; predictable if utilization stays high, unpredictable if hardware sits idle or fails |
| Hardware control | Limited to what the provider exposes (instance shapes, GPU generations they offer) | Full: choose exact GPU models, interconnect topology (how GPUs within and across nodes are networked for multi-GPU training), and firmware versions |
| Scheduling complexity | Provider's scheduler handles GPU allocation; you consume it through the platform's interface | You own GPU-aware scheduling in Kubernetes (device plugins, topology-aware placement so multi-GPU jobs land on GPUs with fast interconnects, not scattered ones), a genuinely hard problem at scale |
| Portability | Tied to whichever provider you're consuming from; migrating means re-provisioning capacity elsewhere | Higher, since the workload runs on standard Kubernetes primitives, though the underlying hardware and drivers are still specific to whatever you bought |
| Long-term maintenance | Provider's responsibility: replacing failed hardware, patching firmware, handling driver updates | Yours: hardware failures need physical or remote-hands intervention, firmware and driver drift across a heterogeneous fleet needs active management |
Worked example
Consider two teams with different utilization profiles:
- A team running occasional fine-tuning jobs, a few days a month, with long idle stretches between them. Managed GPU capacity is the clear fit: paying only for the days actually training, with zero standing hardware to maintain, easily wins over carrying idle, depreciating GPU hardware between jobs. The productivity gain (no driver or scheduler debugging before the first job even runs) matters even more for a small team without dedicated infrastructure staff.
- A team running near-continuous, large-scale training as its core, ongoing workload, effectively saturating GPU capacity around the clock for a sustained period. Here the on-demand premium that managed capacity charges compounds daily at high utilization, and a self-hosted (or long-term-committed) cluster starts to pay for itself; the team can also tune hardware topology and scheduling precisely for its own workload shape, a lever managed capacity doesn't expose. This trade only pays off because the team is large and sustained enough to also own driver drift, hardware failures, and GPU-aware scheduling as ongoing responsibilities, not a one-time setup cost.
The deciding question isn't "how much would we save on paper," it's "does the utilization curve stay high enough, for long enough, that the savings exceed what it costs to staff the operational burden being taken on."
Trade-offs and pitfalls
- The most common wrong turn is comparing only the headline hourly price difference between on-demand managed GPU capacity and owned hardware, without pricing in the operational staffing cost of running GPU-aware Kubernetes scheduling and hardware lifecycle management well; that cost is real and ongoing, not a one-time setup fee.
- A hybrid posture is common and often correct: a self-hosted baseline sized to sustained, predictable demand, with managed GPU capacity absorbing bursts above that baseline, capturing most of the cost benefit of ownership without needing to size owned hardware for peak demand that only occurs occasionally.
- What would flip the recommendation: a sudden drop in a self-hosted team's utilization (a project pausing, demand shrinking) turns previously cost-efficient owned hardware into a straight liability, since unlike managed capacity, idle owned GPUs still cost the same to have bought and still need maintaining.
Design an architecture to host interactive developer sessions (remote IDEs) that need long-running connections per user with predictable latency and cost controls; serverless functions are unsuitable here because of execution limits. Explain your compute choice, session persistence, autoscaling strategy for sessions, idle-session cleanup, security isolation, and how costs are allocated per user.
Sample Answer
Direct answer
Host each user's session as a dedicated, isolated compute unit, either a container on an orchestrator or a lightweight virtual machine for the strongest isolation, created when the session starts and torn down or suspended when it goes idle, rather than a shared multi-tenant process. Long-lived per-user connections and predictable per-user resource limits are exactly what serverless functions cannot provide, since they cap execution duration and don't hold a warm, stateful process open for the tens of minutes to hours a coding session runs. The right compute primitive here is one dedicated unit per session, on an orchestrator designed for many small, short-lived, per-tenant workloads.
Architecture
flowchart LR
U[User browser] --> GW[Gateway or router]
GW --> SCH[Session scheduler]
SCH --> C1[Per-user container or microVM]
C1 --> VOL[(Per-session persistent volume)]
SCH --> AS[Autoscaler: node pool]
SCH --> REAPER[Idle-session reaper]
REAPER --> SNAP[(Workspace snapshot store)]
C1 --> METER[Usage metering per user]
Compute choice. Containers give fast start time and good cost efficiency when isolation between users is enforced at the operating-system level, using process namespaces and resource limits (Linux mechanisms that separate and cap what each process can see and use). If the code being run is genuinely untrusted, add a stronger sandboxing boundary, such as a lightweight virtual machine (a microVM, which boots close to container speed but gives kernel-level isolation). The right choice tracks how trusted the running code is: internal tooling can use lighter container isolation, while a public product that runs strangers' code needs the stronger microVM boundary.
Session persistence. Each session gets its own persistent volume, or a workspace snapshot saved to object storage, mounted into its container or microVM, so a session that's paused and resumed later, even on a different host, reattaches to the same files. Persist workspace state on every meaningful checkpoint, such as a periodic snapshot or an idle transition, not only on a clean shutdown, since a crashed host must never silently lose a user's work.
Autoscaling strategy for sessions. Scale the underlying node pool on aggregate concurrent-session count, not compute utilization alone, since an idle-but-open session still holds a slot. Bin-pack sessions onto nodes by their per-session resource reservation, and keep a small pool of pre-warmed, ready nodes so a new session doesn't wait on a full node boot.
Idle-session cleanup. Track per-session real activity, such as keystrokes or terminal input and output, not just an open network connection, since a connection can sit open with no real activity. On an idle timeout, snapshot the workspace, then suspend or destroy the compute unit and release its resources, while keeping the persisted snapshot available for a fast resume. Make the idle threshold and any "about to be reclaimed" warning visible to the user, so cleanup is never a surprise data-loss event.
Security isolation. Run each session's code under an isolation boundary matched to trust level, enforce per-session network policy so no session can reach another session's compute or the control plane (the orchestrator's own management and scheduling systems, separate from user workloads) by default, and cap per-session resource limits, such as compute, memory, disk, and process count, so one runaway or malicious session cannot degrade the node for everyone else.
Cost allocation per user. Meter actual resource consumption per session (compute-seconds while active, storage for the persisted workspace, and any network egress, meaning data sent out to the internet or another region, which most providers bill per byte) tagged by user or account, aggregate it into a per-user cost record, and clean up idle sessions aggressively, since the biggest silent cost driver in this architecture is sessions left open and billed while genuinely idle.
Worked example
Each session reserves 1 unit of compute and 2 gigabytes of memory; a node offers 8 units of compute and 16 gigabytes of memory, so it fits 8 sessions on either dimension, meaning the node is balanced for this session shape with no wasted headroom on either axis. If the observed idle-session ratio at any given time is 40 percent, an idle reaper reclaiming those slots after, say, 20 minutes of no keystroke activity lets the same node pool serve roughly 1−0.41≈1.67 times as many registered users as concurrently active ones, so capacity planning should be based on concurrent active sessions, not total registered users.
Trade-offs and pitfalls
The most costly pitfall is sizing the node pool for average concurrency and getting caught by a correlated burst, such as a course start time or a scheduled workshop, where hundreds of sessions start within the same minute; keep a pre-warmed buffer sized to the worst observed burst, not the average. The second is treating an open connection as proof of activity, which under-detects idle sessions and wastes cost, or setting the timeout so aggressively that it kills a session mid-thought; use real activity signals, not connection liveness, to decide when a session is truly idle.
Compare the core compute models available in public cloud: virtual machines, containers, serverless functions, and bare-metal instances. For each, describe typical startup latency, isolation level, and operational burden, and give a concrete use case where that model is the right choice.
Sample Answer
Direct answer
The four models sit on a spectrum of isolation versus overhead. Bare metal gives a dedicated physical machine with no virtualization layer, fastest and most isolated from noisy neighbors but slowest and most manual to provision. Virtual machines virtualize hardware so many isolated operating-system instances share one physical machine, giving strong isolation, minutes-scale boot time, and full patching responsibility per instance. Containers share the host's kernel and isolate at the process level, much lighter and faster to start than a virtual machine, but with a weaker isolation boundary, since a kernel vulnerability can potentially cross containers on the same host. Serverless functions go a layer further and abstract the server away entirely, trading control and consistently low latency for near-zero operational burden and per-invocation billing.
Comparison
| Model | Startup latency | Isolation level | Operational burden | Example use case |
|---|---|---|---|---|
| Bare metal | Provisioning lead time is the time to allocate a physical machine, not something spun up on demand; no virtualization overhead once running | Strongest: dedicated hardware, no other tenant shares compute, memory, or disk | Highest: you own the operating system, drivers, and the hardware lifecycle end to end | Latency-sensitive workloads that can't tolerate virtualization jitter, high-performance computing, or licensing tied to physical cores |
| Virtual machines | Boot time on the order of the guest operating system's own boot, slower than a container, much faster than bare-metal provisioning | Strong: hypervisor-enforced isolation between instances on the same host | Moderate to high: you patch and manage the guest operating system yourself | Full operating-system or kernel control, custom kernel modules, or an application that can't be containerized cleanly |
| Containers | Fast, typically seconds, since there's no operating system to boot, just a process starting in an isolated namespace | Moderate: isolated by the kernel's namespace and resource-limiting mechanisms, but every container on a host shares one kernel | Lower for the application itself, though you still own the orchestration layer if self-managed | Microservices, build agents, most modern stateless application backends |
| Serverless functions | Fast when warm, with a cold-start penalty when a new execution environment must be provisioned | Provider-managed sandboxing per invocation; the isolation mechanism is the vendor's concern, not yours | Lowest: no servers, operating system, or orchestration to manage; you own only the function code and its configuration | Event-driven, bursty, or low-average-utilization work, such as a webhook handler or an image-processing trigger on upload |
Trade-offs and pitfalls
The common mistake is treating this as a strict ladder from bare metal to serverless, where more abstracted always means better. Each model fits a specific shape of workload, and defaulting to "most abstracted is most modern, use serverless everywhere" leads to fighting that model's constraints, such as execution limits, forced statelessness, and cold starts, on workloads that bare metal, a virtual machine, or a container would have handled cleanly. Choose based on the workload's isolation needs, its tolerance for startup latency, and how much operational control the team is actually equipped and willing to own, not on which model happens to be newest.
Unlock Full Question Bank
Get access to all 36 Cloud Compute Options and Trade-offs interview questions and detailed answers.
Sign in to ContinueJoin thousands of developers preparing for their dream job.