InterviewStack.io LogoInterviewStack.io

Error Handling and Defensive Programming Questions

Covers designing and implementing defensive, fault tolerant code and system behaviors to prevent and mitigate production failures. Topics include input validation and sanitization, null and missing data handling, overflow and boundary protections, exception handling and propagation patterns, clear error reporting and structured logging for observability, graceful degradation and fallback strategies, retry and backoff policies and idempotency for safe retries. Also address concurrency and synchronization concerns, resource and memory management to avoid exhaustion, security related input checks, and how to document and escalate residual risks. Candidates should discuss pragmatic trade offs between robustness and complexity, show concrete defensive checks and assertions, and describe test strategies for error paths including unit tests and integration tests and how monitoring and operational responses tie into robustness.

MediumTechnical
23 practiced
Implement an LRU cache decorator in Python to cache model predictions keyed by an input hash. The decorator should support a configurable maximum size, be thread-safe for concurrent access, and update recency on both reads and writes. Include a short usage example wrapping a dummy predict(input) function.
MediumTechnical
25 practiced
How would you design inference orchestration to tolerate partial failures such as tokenizer timeouts, feature-store slowdowns, or remote model-shard unavailability? Describe timeout and deadline policies, circuit-breakers, how to return partial results with metadata, and how to avoid cascading failures.
MediumTechnical
22 practiced
Design a set of monitoring alerts and thresholds to detect model input schema mismatches and model performance drift (e.g., sudden distribution shifts, rising error rate). For each alert describe mitigation steps, who to notify, and the on-call runbook for triage and rollback.
EasyTechnical
31 practiced
In Python, describe idiomatic exception-handling patterns for an AI inference microservice. For cases like model-load failure, corrupted input, and downstream timeouts, when should the service catch the exception locally and transform it (e.g., return 4xx/5xx) versus allowing it to propagate to an upper-level orchestrator or monitoring system?
HardSystem Design
43 practiced
Design a GPU cluster scheduler that defends against resource exhaustion from misbehaving jobs. Include per-user and per-team quotas, preemption policies, OOM detection and automated mitigation, container/cgroup isolation, graceful eviction with checkpointing, and fairness policies. Explain how to balance throughput, fairness, and responsiveness for interactive jobs.

Unlock Full Question Bank

Get access to hundreds of Error Handling and Defensive Programming interview questions and detailed answers.

Sign in to Continue

Join thousands of developers preparing for their dream job.