Library

Volume 5 · Master Q&A Bank

Notebook
Sign in

Section 9

Architecture & System Design Questions

1,860 words · about 8 min

Q1. Walk me through the architecture of the most complex system you’ve designed. Use the template: context → requirements (scale, latency, users) → high-level design layer by layer → 2-3 key decisions with rejected alternatives → failure modes designed for → measured outcomes → what you’d change with hindsight. Always include real numbers (QPS, data volume, team size) — vague answers signal you didn’t actually build it. Close with a lesson learned, not just a win.

Q2. You have a UI where a user uploads a CSV with 5 million rows, edits data, and clicks Submit — the loading spinner hangs. How do you fix the UX and architecture? Never push a multi-million-row file through the API: issue a short-lived SAS token (pre-signed URL) so the browser uploads the raw CSV directly to blob storage, and only send the small JSON diff to the API. The API drops a message on a queue (Service Bus) and immediately returns HTTP 202 + JobID so the spinner clears. A background worker applies diffs and uses SqlBulkCopy/bulk-insert in batches of ~50K rows (disabling non-clustered indexes during load, rebuilding after) instead of EF Core row-by-row. Push progress back to the UI over SignalR so the user sees a real progress bar instead of a frozen spinner.

Q3. A 5GB file arrives daily at noon and must be written to both a SQL and a NoSQL database, with more sinks likely later. How do you architect this? Don’t parse a 5GB file in a normal API process — it will OOM. If nothing needs the data in real time, let Azure Data Factory ingest the file and fan out via multiple native Sinks (SQL, Cosmos DB) in one pipeline — adding a third database later is just a new Sink, zero code change. If live microservices (billing, notifications) must react immediately, use ADF only to shred/parse the file safely, then publish each row as an event to a Service Bus Topic; each downstream system is an independent subscriber to the same topic, so adding a consumer never touches the ingestion logic. The deciding factor is whether consumers need to react in real time (pub/sub) or just eventually land in a store (batch fan-out).

Q4. How would you design real-time document ingestion where a new upload must be searchable within 5 minutes? Event-driven: blob upload triggers a pipeline (parse → chunk → embed → index), not a nightly batch. Rough per-doc budget: parse 10s, chunk 1s, embed ~100ms/chunk × 20 chunks ≈ 2s, index upsert ~1s — well under 5 minutes even with retries. The real design challenge is burst handling (100 docs land at once) — use a queue in front of the pipeline with autoscaled workers rather than processing inline on upload.

Q5. How do you implement row/document-level access control in a RAG or search system so departments only see their own data? Store ACL metadata (department, classification, owner groups) on every chunk/row and apply it as a pre-filter at retrieval time — never post-filter, because similarity ranking on unfiltered results can leak the existence/content of restricted documents through what gets ranked highly. Map corporate directory groups (Entra ID/Azure AD) into the ACL, support shared cross-department documents via multi-value ACL lists, and log every retrieval for audit. Azure AI Search supports this natively via OData security-trimming filters combined with vector search.

Q6. How do you decide between a managed AI/cloud service and self-hosting? Score five factors: data sensitivity (self-host if PHI/regulatory and BAA complexity), cost at volume (self-hosting breaks even roughly around 5K+ high-volume queries/day), team’s ops capability (managed if no ML infra experience), customization need (self-host for fine-tuning freedom), and latency (self-host removes the network hop). Default recommendation: start managed for time-to-value, migrate the highest-volume or most sensitive workloads to self-hosted once volume/requirements justify the ops burden.

Q7. How do you ensure data consistency across microservices without a shared database? Each service owns its own data exclusively — no service ever reads another’s database directly. Cross-service consistency comes from events (Service A publishes OrderCreated, Service B updates its own store, accepting sub-second eventual consistency lag), the Saga pattern for multi-service transactions, and API composition or materialized views for cross-service queries.

Q8. Design a multi-tenant SaaS system — how do you handle isolation, auth, and scale? Three isolation tiers by cost/isolation trade-off: database-per-tenant (highest isolation/cost, use for regulated large tenants), schema-per-tenant (middle ground), or row-level security in a shared database with TenantId in every table plus an EF Core global query filter and composite indexes like (TenantId, Status). Put TenantId in the JWT claims so every request is routed and filtered without trusting client input. Scale by adding read replicas and a cache layer per tenant tier; use Azure Policy/governance to keep tenant resource sprawl under control.

Q9. How do you approach migrating a legacy on-prem monolith to the cloud? Use the “6 R’s” framework (rehost, replatform, refactor, repurchase, retire, retain) to categorize components rather than a single strategy for everything. Apply the Strangler Fig pattern — route traffic through a facade and incrementally replace slices of the monolith with cloud-native services, never a big-bang rewrite. Use a Cloud Adoption Framework and landing zone to get governance/networking right before migrating any workload, and validate each slice with parallel/shadow running before cutover.

Q10. Design a strategy to expose internal microservices securely to external partners. Front everything with an API gateway (APIM) that terminates OAuth2/Entra ID auth, enforces rate limiting/quotas per partner, and applies request/response transformation so internal contracts aren’t exposed directly. Never expose internal service URLs; the gateway is the only public surface. Add subscription keys or client-credentials flow per partner for accountability, and version APIs with a deprecation policy so partner integrations aren’t broken by internal refactors.

Q11. How do you handle schema evolution in a vector database / search index as document types grow? Version the metadata schema so new fields can be added without breaking old queries, and track which embedding model version produced each vector — a model upgrade requires re-embedding, not just re-indexing. Use blue-green index migration (build the new index/collection alongside the old, cut over on validation) rather than in-place mutation. Maintain backward compatibility for existing chunks during the transition window.

Q12. Orchestration vs. choreography in multi-agent or event-driven systems — when do you use each? Orchestration: a central controller (state machine / LangGraph) manages transitions — use when order matters, you need checkpointing, or a human-in-the-loop gate is required. Choreography: services/agents react to events with no central controller — use for loose coupling and parallel, independent processing. In production, most teams default to orchestration because choreography is materially harder to debug and trace at scale; reserve choreography for genuinely decoupled domains.

Q13. Design an event-driven system ingesting high-volume IoT telemetry. Ingest through Event Hubs (or Kafka) partitioned by device ID for ordered, parallel consumption; use consumer groups to let multiple downstream systems (alerting, storage, analytics) read the same stream independently. Land raw telemetry in a data lake / Cosmos DB for hot-path queries and route anomalies through Stream Analytics or a rules engine for near-real-time alerting. Partition strategy and consumer lag monitoring are the two things interviewers probe hardest here.

Q14. What’s your methodology for capacity planning / sizing a new system? Back-of-envelope: peak QPS = users × actions/user/hour ÷ 3600, storage = records/day × record size × retention, memory = working set + cache footprint, network = QPS × avg payload size. Add 3x headroom for spikes, then validate with load testing rather than trusting the math alone. Example: 10K users × 20 actions/hour ÷ 3600 ≈ 55 QPS average, ~165 QPS at peak with a 3x multiplier.

Q15. How do you design for graceful degradation under load? Feature flags to shut off non-critical functionality first; circuit breakers that return cached/stale data instead of erroring; priority queues that shed low-priority work before high-priority; and separate liveness (process is up) from readiness (can serve traffic) health checks so the load balancer stops routing to a struggling instance before it dies entirely.

Q16. How do you handle database schema changes with zero downtime? Expand-contract, always: add the new column/table while keeping the old, deploy code that writes to both, backfill historical data, deploy code that reads only from the new structure, then drop the old column in a later release. Each step is independently deployable and rollback-safe — never a single migration that renames/drops in place.

Q17. How would you architect a GenAI or data system for an air-gapped / offline environment? Self-hosted open models (Llama/Mistral class) served via vLLM on local GPUs, a self-hosted vector DB (Qdrant/Milvus), containerized on-prem Kubernetes, and an open embedding model (e.g., BGE-large). Model and index updates go through a manual, staging-tested update cycle since there’s no cloud auto-scaling or provider patching. Be upfront about the trade-off: lower ceiling than a hosted frontier model, but it’s the only option that meets the security requirement.

Q18. How do you architect for disaster recovery (RTO/RPO)? Define RTO/RPO targets first — they drive every other decision. Multi-AZ for the primary region, cross-region async replication for DR (Azure SQL auto-failover groups, Cosmos DB multi-region, geo-redundant storage). Keep infrastructure as code so a region can be rebuilt from scratch, not just failed over to a pre-built replica. Run DR drills on a schedule (quarterly is typical) — an untested DR plan is not a DR plan.

Q19. What’s your approach to evaluating and introducing a new technology into the stack? Structured gate: (1) business case — what can’t existing tools do? (2) evaluation matrix — performance, community, licensing, learning curve, support, (3) a time-boxed POC (about a week) on a representative feature, (4) buy-in from the team that will actually use it daily, (5) incremental adoption — one non-critical service first, expand after a few months of production evidence.

Q20. Describe a time you made a deliberate architectural compromise under time pressure. Frame it honestly: name the ideal architecture, the constraint that ruled it out, the pragmatic alternative you shipped, and — critically — that you documented the debt and had a concrete follow-up plan rather than letting “later” mean “never.” Example shape: shipped a modular monolith instead of full microservices/event sourcing for a 6-week MVP, extracted 2-3 services in the following quarter once real usage data justified the split.

Q21. How do you design consistent APIs when multiple teams must integrate? API-first: agree the OpenAPI spec before any implementation, enforce it with contract testing (Pact) in CI so producer and consumer changes can’t silently diverge, default to backward-compatible semantic versioning, and require a minimum deprecation window (e.g., 3 months) with a review board sign-off for any breaking change.

Q22. Design a disaster-recovery-aware architecture specifically for an AI/LLM platform. Model artifacts in blob storage (11-nines durability), vector DB snapshots replicated on a schedule, prompt/config versions in git (trivially available anywhere), and in-flight requests buffered durably in a queue so no data is lost mid-failover. Bedrock/Azure OpenAI-class services are available in multiple regions — failover is largely an endpoint config change, not a rebuild. Still run scheduled DR drills because the AI-specific pieces (index rebuild time, model endpoint quota in the DR region) are easy to overlook.