Performance Cost Optimization & Resource Efficiency Questions
Optimizing for the money and resources a given level of performance consumes, not just raw speed. Covers cost-per-request, training-cost and cost-per-inference reasoning, right-sizing and cost-driven autoscaling of compute, memory and storage, choosing between on-demand, reserved and spot capacity, storage tiering and egress-cost reduction, cloud-bill diagnosis and reduction plans, and cost allocation or chargeback across teams and tenants. A question belongs here when the primary deliverable is a cost or resource-consumption calculation, decision or reduction plan, not when cost is one line among several unrelated technical considerations. Distinct from defining or measuring latency, percentiles, SLOs and latency budgets on their own, from profiling and bottleneck diagnosis such as flame graphs, hotspots and query tuning, from production incident and on-call triage, from general multi-axis trade-off frameworks where cost is incidental to a decision about latency, freshness or complexity, from concurrency, batching and thread-safety mechanics, and from garbage-collection and memory-leak tuning: those are covered by dedicated sibling topics.
Implement (in Python) a function that estimates cost-per-request for inference given: model_flops_per_inference, instance_flops (FLOPS per second), instance_hourly_price, expected_gpu_utilization (0-1), network_bytes_per_request, egress_price_per_gb, and target_requests_per_second. The function should return dollars per request and recommended instance count to meet the target_requests_per_second at a utilization cap (e.g., 70%). Show your calculations and assumptions in comments.
Given a small Transformer model where average token generation cost is 5ms on GPU versus 20ms on CPU, GPUs cost 5x per hour relative to CPUs, and expected inference workload is 200 tokens/sec, describe how you would decide to serve on GPU or CPU. Include calculations for cost-per-token, batching effects, latency SLO considerations, and how utilization affects the decision.
Estimate monthly cost for an image-classification inference service given: steady average 500 RPS, average request upload 50KB, response 10KB, 30% of traffic egresses to EU from us-east-1, GPU instances cost $2.5/hr and provide 100 RPS at 70% utilization, model storage is 200GB at $0.02/GB-month. Break down compute, egress, and storage costs monthly and propose a plan to reduce total cost by ~30% with concrete levers.
Write a Python function that selects the cheapest instance type (CPU or GPU) and the required instance count given: per-instance throughput and hourly cost for CPU and GPU, predicted average request rate, and latency SLO (max latency). Assume a per-instance utilization target (e.g., 70%). Include comments describing assumptions and how you handle rounding/over-provisioning.
Your team is choosing hardware for a specific model and workload from a shortlist that includes NVIDIA A10, A100, AWS Inferentia, and CPU instances. Walk through how you would calculate and optimize FLOPS-per-dollar for each candidate, what you would benchmark to get there, and what decision criteria beyond raw FLOPS would actually change your recommendation.
Unlock Full Question Bank
Get access to all 34 Performance Cost Optimization & Resource Efficiency interview questions and detailed answers.
Sign in to ContinueJoin thousands of developers preparing for their dream job.