Requirements Gathering and Scoping Questions
Eliciting, analyzing, and translating stakeholder and user needs into clear, scoped requirements and specifications. Covers cross-functional discovery, distinguishing needs from requests, and writing specs engineering can build against. Assesses the ability to bridge business intent and buildable definition.
Design a low-latency, multi-region model serving architecture to support 10,000 QPS with a 10ms median latency SLO and 99.99% availability. Address model replication, feature consistency, model update propagation (rolling/canary), cross-region failover, storage choices, and explain how scoping decisions (e.g., per-region models vs single global model) impact cost and complexity.
Sample Answer
Requirements:
- Functional: 10k QPS globally, 10ms median inference SLO, 99.99% availability.
- Constraints: multi-region (geo-proximity), strong feature consistency for inference inputs, safe model rollout.
High-level architecture:
- Global DNS + Geo-routing -> Regional Edge LB (CDN / Regional ALB) -> Regional API Gateway -> Per-region Model Serving Cluster (K8s/EC2 with GPU/CPU pods) -> Feature Store + Cache -> Central Control Plane (model registry, rollout manager, metrics).
Key components & choices:
- Model replication
- Maintain one active model per region (replicated binaries/artifacts from central registry to minimize cross-region RTT).
- Use immutable model artifacts (S3/GCS + signed manifests). Pull by regional cluster on deployment.
- Keep model weights local to serving nodes (warm containers) to meet 10ms median.
- Feature consistency
- For low-latency, perform feature lookup locally: use regional Feature Store (Redis/Memcached for hot features) populated via async CDC from primary datastore.
- For features requiring global consistency (user profile updates), use last-write-wins with per-request version/timestamp and fall back to strongly-consistent read only when necessary (rare), accepting slightly higher tail latency.
- Model update propagation (rolling/canary)
- Central control plane triggers staged rollout:
- Canary: deploy to small % of nodes in one region; run shadow traffic and A/B eval.
- Metrics-driven promotion: automated MLOps pipeline checks latency, accuracy, resource usage, and rollback on anomaly.
- Rolling updates across pods then regions to prevent simultaneous multi-region risk.
- Use traffic-splitting at the API gateway for canary.
- Cross-region failover
- Active-active regions with geo-routing; failover via health checks + DNS TTLs (short TTL ~30s) and client-side retry with region fallback.
- Replicate state (models, feature snapshots) asynchronously; ensure idempotent requests and sticky session avoidance.
- Storage choices
- Model artifacts: object store (S3/GCS) + CDN for quicker pulls.
- Feature store: regional Redis clusters for hot reads, regional OLAP for cold features (Bigtable/Spanner/Cassandra) with CDC pipeline.
- Metadata: central SQL/NoSQL (highly available) for registry and rollout state.
Scoping trade-offs (per-region vs global model)
- Per-region models (region-specific tuning): lower latency, better locality, compliance benefits; higher cost (multiple training/validation runs, storage, ops complexity) and model divergence risk.
- Single global model: simpler ops, consistent behavior, lower training cost, but may increase latency if inference routed cross-region or require larger model to cover all distributions.
Recommendation: hybrid — single global model replicated per-region for serving; optionally region-adapted fine-tuning overlays (small adapter layers) to balance cost and accuracy.
Scaling & reliability:
- Provision capacity with headroom (10k QPS -> per-region partitioning, autoscale pods using HPA/metrics), use request batching where possible, GPU pooling for heavy models.
- SLOs achieved by local replicas, warm pools, aggressive caching, and circuit-breakers for downstream feature stores.
Metrics & monitoring:
- Track per-region p50/p99 latency, error rates, feature freshness, model drift, rollout KPIs. Automated rollback when safety thresholds breached.
This design prioritizes low-latency and availability by keeping serving and hot features regional, while centralizing control for safe, observable rollouts and cost-effective training.
The business goal is described as 'increase engagement.' For a recommendation engine, propose four concrete KPIs with precise numerator and denominator definitions, describe how to instrument each KPI reliably, and note one potential pitfall or gaming risk for each KPI (for example, incentivizing clickbait).
Sample Answer
- KPI: Click-Through Rate (CTR) on recommendations
- Numerator: number of recommendation impressions that received at least one click.
- Denominator: total number of recommendation impressions.
- Instrumentation: emit deterministic impression and click events with recommendation_id, user_id, position, timestamp; deduplicate server- and client-side; store in event pipeline (Kafka → analytics DB) and compute daily/weeky aggregates. Tie clicks to the exact recommended item via unique impression_id.
- Pitfall/gaming: models may surface clickbait or sensational items that increase clicks but reduce downstream satisfaction.
- KPI: Short-term Retention (session continuation rate post-recommendation)
- Numerator: number of sessions where a user performed at least one meaningful action (e.g., view > X sec, add-to-cart, watch > 50%) within 10 minutes after engaging with a recommended item.
- Denominator: number of recommendation engagements (clicks) in the period.
- Instrumentation: track engagement events with timestamps and content metadata; compute time-window joins to attribute follow-up actions to the preceding recommendation click.
- Pitfall/gaming: publishers could create auto-play or micro-interactions that artificially inflate “meaningful” actions.
- KPI: Long-term Engagement Lift (7-day active users attributable to recommendations)
- Numerator: number of distinct users who were active (>=1 meaningful session) within 7 days after being exposed to recommendations and were not predicted to be active without them (requires uplift or attribution model).
- Denominator: number of distinct users exposed to recommendations.
- Instrumentation: use randomized holdout or causal inference (AB test with holdout) to attribute incremental DAUs; log exposures and downstream activity; compute uplift.
- Pitfall/gaming: segmentation or sample leakage across treatment/control can bias uplift estimates.
- KPI: Satisfaction / Quality Rate (positive feedback rate)
- Numerator: number of recommendation interactions with explicit positive feedback (like, thumbs-up, save) or high implicit satisfaction signal (long dwell > threshold).
- Denominator: total number of recommendation interactions (clicks or impressions depending on product).
- Instrumentation: capture explicit feedback events and normalized dwell times per content type; combine into a single labeled satisfaction flag using deterministic rules; back this with periodic user surveys for calibration.
- Pitfall/gaming: users might be prompted to give positive feedback (UI nudges) or incentives could induce biased responses.
Notes: ensure consistent event schemas, deterministic impression IDs, server-side recording where possible, and regularly validate telemetry (QA tests, ingestion alerts, and replay checks) to prevent measurement drift or loss.
Create a requirements checklist to migrate an on-premise ML pipeline to a managed cloud platform. Include items for data transfer validation, security and compliance checks, latency impact assessment, model parity tests, CI/CD adjustments, monitoring replication, rollback plan, and cost impact assessment.
Sample Answer
Requirements checklist — migrating an on‑prem ML pipeline to a managed cloud platform
Scope & constraints
- List pipeline components (data sources, feature store, training infra, model registry, inference endpoints, orchestration, logging, secrets).
- Compliance/regulatory constraints (data residency, GDPR, HIPAA), SLAs (latency, availability), budget.
Data transfer validation
- Inventory data types, schemas, sizes, and change rate.
- Choose transfer method (VPN/DirectConnect, Snowball, streaming via Kafka/Cloud PubSub).
- Validate integrity: checksums, row counts, schema validation tests after transfer.
- Performance tests: measure bandwidth, initial bulk seed time, ongoing sync lag.
- Acceptance: zero data loss on parity checks; <X minutes lag for streaming.
Security & compliance checks
- Network: private VPC, least-privilege firewall rules, VPC endpoints for storage.
- Identity: RBAC/IAM policy mapping from on‑prem roles to cloud roles.
- Data at rest/in transit encryption (KMS-managed keys), key rotation policy.
- Secrets management: migrate to cloud secret store (HashiCorp/Secret Manager).
- Audit & logging: enable audit trails, retain logs per compliance retention rules.
- Compliance evidence: run security scan, provide artifacts for compliance officers.
Latency impact assessment
- Identify latency-sensitive components (online inference, feature fetch).
- Baseline on‑prem latencies; run synthetic and canary tests from client regions to cloud endpoints.
- Evaluate network hop cost; consider hybrid (edge, cloud regions, regional caches).
- Acceptance: latency within SLA or design mitigations (edge caching, model quantization).
Model parity tests
- Define parity suite: unit tests, offline evaluation, shadow/parallel A/B tests.
- Reproduce training environment (same framework versions, hardware/GPU types, random seeds).
- Validate numerical parity: metrics within acceptable delta (precision/recall A/B).
- Inference parity: run identical input batches through on‑prem and cloud models; compare outputs and performance.
- Statistical significance testing and roll-forward gating.
CI/CD adjustments
- Update pipelines to cloud build systems (Cloud Build, Jenkins, GitHub Actions with cloud runners).
- Containerize training/serving, store artifacts in cloud registry.
- Automate infra-as-code (Terraform/CloudFormation) for reproducible environments.
- Add deployment gates: model tests, canary rollout, automatic rollback triggers.
- Ensure dev/test/prod isolation and approval workflows.
Monitoring replication
- Mirror on‑prem metrics: model performance (drift, accuracy), infra (CPU/GPU, memory), data quality (schema drift, null rates), request/response metrics.
- Integrate with cloud observability (Prometheus/Cloud Monitoring, logging, alerts).
- Implement anomaly detection and alert playbooks; dashboard parity for stakeholders.
- Retention & cost tuning for logs/metrics.
Rollback & recovery plan
- Maintain immutable model artifacts and versioned infra templates.
- Define rollback triggers (metric degradation thresholds, increased errors).
- Practice runbooks: automated rollback (traffic shift back), manual escalation flow.
- Backup plan for data and feature store snapshots; RTO/RPO targets defined.
Cost impact assessment
- Estimate ongoing costs: storage, data egress, compute (training/serving), managed services, monitoring retention.
- Run cost simulations with expected traffic and training cadence; include peak scenarios.
- Identify cost controls: autoscaling, reserved instances, data lifecycle policies, budget alerts.
- Acceptance: cost within budget or identified trade-offs documented.
Validation & cutover plan
- Stage migration (pilot subset, shadow mode, canary, full cutover).
- Success criteria per stage (data parity, latency, model metrics, error rates).
- Rollback window and post-mortem scheduled.
Deliverables
- Migration runbook, test plans, IAM mappings, cost model, monitoring dashboards, rollback playbooks, compliance artifacts.
This checklist should be adapted to your org’s SLAs, compliance, and budget; for each item assign owner, test, acceptance criteria, and rollback action.
For a health-care ML product operating under HIPAA and GDPR, enumerate the non-functional requirements you would include in the PRD (data residency, encryption-at-rest/in-transit, access controls/role-based access, audit trails, model interpretability, retention and deletion policies). Explain how you would validate compliance and how these requirements would change scoping and timelines.
Sample Answer
Requirements (non-functional) — list and rationale:
- Data residency: store/process PHI only in approved jurisdictions; use region-restricted cloud tenants to meet GDPR data transfer and HIPAA state requirements.
- Encryption: AES-256 at-rest; TLS 1.2+ in-transit; customer-managed keys (BYOK) for critical PHI.
- Access controls / RBAC: least-privilege roles, multi-factor auth for admins, just-in-time elevation, separation of duties, SCIM integration for SSO.
- Audit trails & logging: immutable, tamper-evident logs of data access, model predictions, config changes with retention for regulatory windows; alerts for anomalous access.
- Model interpretability & transparency: per-request explanations (SHAP/Integrated Gradients) for high-risk decisions, model card + data provenance for audits.
- Retention & deletion policy: configurable retention windows, secure deletion workflows, and proof-of-deletion for GDPR Right-to-ERASURE and HIPAA disposal guidance.
- Data minimization & anonymization: minimize PHI used in training; use pseudonymization, differential privacy for analytics.
- Monitoring & incident response: real-time monitoring, IR runbooks, 72-hour breach notification pipelines aligned to GDPR/HIPAA.
- Testing & assurance: regular penetration tests, red-team, and privacy impact assessments (DPIA).
Validation / Compliance:
- Technical: automated compliance checks (IaC linters), encryption/key audits, RBAC policy tests, E2E integration tests that assert data never leaves allowed regions.
- Processual: DPIA, DPA contracts with processors, BAA signed, vendor risk assessments, documented SOPs.
- Evidence: immutable logs, model cards, test reports, pentest/VA reports, deletion receipts, and external audit reports (SOC2/HIPAA readiness).
- Independent audit: yearly third-party audit and continuous internal compliance dashboard.
Impact on scope & timelines:
- Adds upfront time for legal/vendor agreements, infra setup (region-restricted tenants, KMS BYOK) — estimate +4–8 weeks.
- Engineering: implementing RBAC, audit pipelines, and explainability hooks +2–6 weeks; testing & pentest cycles +2–4 weeks.
- Iterative: require privacy-preserving model experimentation (adds training complexity and compute cost) and separate staging with synthetic data.
- Risk buffer: include compliance review gates in milestones; plan for rollback/mitigation windows for incidents.
Overall: budget ~15–30% more time and 20–40% higher infra/operational costs; schedule explicit compliance milestones and deliverables in PRD.
Design a sampling and labeling plan to collect representative ground truth across multiple user segments for a model. Include stratification strategy, minimum sample sizes per stratum (statistical power reasoning), labeling quality assurance processes, estimated labeling cost and time, and stopping criteria to know when data collection is sufficient.
Sample Answer
Situation: We need a reproducible plan to collect representative ground truth across multiple user segments so models are accurate and fair.
Stratification strategy
- Primary strata = user segments relevant to downstream fairness/performance (e.g., geo, device, age-group, power-users vs casual).
- Create mutually exclusive strata by crossing up to 2–3 highest-impact variables (avoid explosion).
- Within each stratum, sample randomly from recent production traffic, then apply quota/weighting to reflect population or to purposely oversample rare-but-critical strata (collect weights for re-weighting during training/eval).
Minimum sample size per stratum (statistical power)
- For estimating a proportion with margin-of-error E at confidence 1−α, use:
n = (Z_{1−α/2}^2 * p*(1−p)) / E^2.
Use conservative p=0.5 if unknown. For 95% CI (Z≈1.96) and E=0.03 → n ≈ 1,067 per stratum. - To detect difference between two strata proportions with power 1−β and minimum detectable effect (MDE) δ, use two-sample formula:
n_per_group ≈ [(Z_{1−α/2}+Z_{1−β})^2 * (p1(1−p1)+p2(1−p2))]/δ^2.
Example: α=0.05, β=0.2, p≈0.5, δ=0.05 → n≈784. - Practical rule: set a floor (e.g., min 800–1,200 labels) for any stratum used in comparative analysis; oversample rare strata proportionally more if they’re critical.
Labeling quality assurance
- Annotator recruitment: qualification tests with gold set; require ≥80–90% agreement to qualify.
- Primary QA pipeline:
- Gold (pre-labeled) questions mixed ~5–10% per batch to measure ongoing accuracy.
- Dual labeling: 20–30% of items labeled by two independent annotators; compute inter-annotator agreement (Cohen’s kappa / Krippendorff’s alpha).
- Adjudication: items with disagreement go to expert adjudicator or majority consensus (3rd label).
- Calibration sessions weekly for annotators, update guidelines, track label drift.
- Monitor per-annotator metrics (accuracy on gold, agreement, throughput); remove low performers.
- Periodic blind audits (sample labeled externally) to estimate real-world error.
- Track label uncertainty and attach confidence metadata for downstream weighting.
Estimated cost and time (example numbers)
- Assume average labeling time per item = 2 minutes (30 items/hour).
- Labeler cost (including overhead) = $25/hour → cost/label ≈ $0.83.
- For 10 strata × 1,100 labels ≈ 11,000 labels → ~367 hours → cost ≈ $9,200.
- Add dual-labeling for 25%: +2,750 labels → +92 hours → +$2,300.
- Adjudication (10% of original): ~1,100 labels × 3 min = 55 hours → +$1,375.
- Total approximate cost ≈ $12–13k; timeline with 5 annotators concurrently ≈ 2–3 weeks.
Stopping criteria
- Statistical: stop when CI for key metrics within target margin E for each critical stratum, and when differences you care to detect (MDE) are powered.
- Stability: model evaluation metrics (accuracy/F1 per stratum) stabilize across two sequential batches (e.g., <1% change) and bootstrap variance low.
- Diminishing returns: marginal gain in metric/uncertainty reduction per additional 1,000 labels falls below threshold (cost vs benefit).
- Operational: reached max budget or minimum samples per stratum floor.
Other practical notes and alternatives
- Use adaptive sampling: start with pilot (e.g., 200/stratum), estimate p and variance, then compute final n to avoid over-collection.
- For extremely rare strata, use targeted recruitment, synthetic augmentation, or active learning to prioritize high-uncertainty examples.
- Always store sampling weights and metadata so analysis can re-weight back to population distribution.
This plan balances statistical rigor (power, CI), label quality (gold, adjudication), cost/time realism, and practical stopping rules (CI targets + stability + diminishing returns) suitable for production ML workflows.
Unlock Full Question Bank
Get access to all 40 Requirements Gathering and Scoping interview questions and detailed answers.
Sign in to ContinueJoin thousands of developers preparing for their dream job.