Architecture Walkthrough and Defense of a System You Led
Medium · System Design · Software Engineer · Onsite
Prompt
Rather than designing a hypothetical service from scratch, select a substantial production software system that you personally drove from initial design through live operation, walk the interviewer through its end-to-end architecture, and defend your engineering choices under deep technical questioning.
Begin by aligning on the interview ground rules: - Whether the chosen work must be a distributed backend service or if any complex software component with meaningful state, performance, or reliability constraints qualifies. - How to frame collaborative team systems while drawing an unmistakable boundary around your individual design and implementation scope. - How to budget time between your opening architectural walkthrough and the interviewer-led deep dive. - How to anonymize internal codenames and round sensitive employer metrics while keeping capacity math internally consistent.
Structure your walkthrough and defense across two phases: 1. System Overview: Frame the user problem, business motivation, concrete traffic/latency targets, and measurable post-launch impact. Present a clear architecture diagram tracing primary write, read, and recovery flows across services and data stores, explicitly distinguishing components you built and operated from partner-team infrastructure. 2. Architectural Defense & Retrospective: Justify your data stores, inter-service communication models, and consistency guarantees by contrasting each choice against plausible alternatives you ruled out. Dive deeply into one non-trivial production bottleneck or incident—from initial symptoms and diagnostic evidence to root cause and verified fix—and close with operational practices (observability, safe rollouts, schema migrations), next-order scaling ceilings, and candid design regrets.
Scope & Expectations
- Choose a system for depth of personal ownership rather than company-wide prestige, ensuring you can explain schemas, transaction boundaries, retry semantics, and failure modes firsthand.
- Ground your overview in 4–5 internally consistent scale numbers (throughput, payload volume, data growth, skew, and latency SLOs) so capacity trade-offs can be verified quantitatively.
- Pair every major technology decision with at least one rejected alternative and the specific requirement or constraint that eliminated it.
- Present an evidence-backed debugging narrative and an honest retrospective on what breaks at 10x load and what you would build differently today.
Step-by-step walkthrough
Clarify the round format and rules
Unlike a standard system design prompt ("design Twitter"), this format lets you bring a production system from your own career, explain how it works end to end, and defend your engineering choices as the interviewer drills into specific components. Spend the first two minutes aligning on four ground rules:
- Scope of eligible systems: While any complex software component you led is fair game, interactive probing centers on storage engines, consistency guarantees, failure recovery, and scaling ceilings — so choose a service with meaningful state or data movement.
- Separating personal vs. team scope: Production software is almost always built collaboratively. Be explicit with "I" versus "we" ("the infra group ran the Kafka brokers; I authored the Protobuf contract and built the stateful aggregator"). Taking credit for the entire diagram and stalling on an unfamiliar box is the quickest way to lose trust.
- Pacing the clock: Target a crisp 10-minute walkthrough in a 45-to-60-minute session, leaving 35–50 minutes for interviewer-guided deep dives.
- Protecting proprietary employer details: Keep the genuine architecture and debugging history, swap internal codenames for generic infrastructure terms ("edge gateway", "object storage"), and round commercial figures ("roughly 1.7 billion events/day") while keeping the underlying arithmetic consistent.
Especially when interviewing with distributed-database teams (such as engineers building distributed SQL engines like CockroachDB), expect pointed questions on transaction isolation (the rules controlling what concurrent database transactions can see of each other's uncommitted or simultaneous writes), row-lock contention, crash recovery, and failover — regardless of which database your project used.
The remaining steps walk through one complete illustrative project — a real-time API usage-metering pipeline for customer billing — in the exact order to present and defend it. When you prepare, swap in your own project and your own real numbers using the same blueprint.
Pick the right project and build your 10-minute map
Prioritize firsthand depth over résumé flash. A focused service where you can explain every SQL query, retry loop, and outage beats a famous company-wide platform where you only wrote one endpoint. Pick a project that satisfies five criteria:
- Clear personal ownership: a major slice was yours from design doc through on-call operations.
- Real trade-offs: you chose between competing databases, messaging patterns, or consistency models.
- One deep debugging story: a non-obvious production problem you diagnosed from metrics or logs.
- Before-and-after metrics: concrete latency, accuracy, or throughput numbers proving the outcome.
- Fresh recall: recent enough that you remember schema columns, failure modes, and edge cases.
Build a five-piece map before the interview: - One-sentence elevator pitch: who uses it and what business problem it solves. - Five driving numbers: event rate, payload size, tenant skew, freshness target, and accuracy target. - One clean diagram showing the write path, read path, and reconciliation path. - One rejected alternative for every major component, tied to a specific constraint. - One end-to-end war story: symptom, evidence, root cause, fix, and measured result.
The sample project context: A B2B developer platform bills ~4,500 enterprise tenants per API request unit and per gigabyte transferred. Originally, a nightly batch job parsed text log files copied from edge gateways. That caused two painful problems: tenant usage dashboards were 24–36 hours stale, and rotated or dropped log files caused billing disputes on 0.7% of monthly invoices. You designed, built, and operated the streaming replacement.
Frame the users, outcomes, scale, and ownership boundary
Start your 10-minute presentation with the users, measurable outcomes, back-of-the-envelope math, and ownership boundary. Leading with results tells the interviewer the project shipped and mattered.
Users and success targets - Enterprise tenants: view near-real-time usage on a web dashboard (target freshness: <= 90 seconds at the 99th percentile, or p99) and receive accurate monthly invoices. - Quota service: checks current-month usage to enforce tenant rate plans without slowing down live API traffic. - Billing system: reads finalized monthly totals to issue invoices.
Measured outcome - Dashboard staleness dropped from 24–36 hours to under 90 seconds at p99 (and under 4 seconds of pipeline lag after fixing the contention bug in Step 8). - Invoice disputes caused by metering errors fell from 0.7% of invoices to under 0.04%. - Live customer API latency saw 0 ms added, because gateways emit usage events asynchronously after returning the HTTP response.
Scale math (rounded numbers that fit together)
Billable traffic 1.728B (~1.7B) events/day -> 1,728,000,000 / 86,400 s = ~20,000 events/s average -> 3x daily peak = ~60,000 events/s peak Raw data volume ~250 bytes/event x 1.728B = ~432 GB/day Kafka (7 days x 3 replicas) = 432 GB x 21 = ~9.1 TB disk Tenant skew ~4,500 tenants total; largest single tenant = ~20% of traffic -> ~12,000 events/s at peak from one tenant alone Meters & dimensions 6 billable meters (request_units, egress_bytes, ...), 4 cloud regions Aggregated volume ~8,000 active (tenant_id, meter, hour) combinations per hour -> 8,000 x 24 = ~192,000 rows/day -> ~70M rows/year Outage tolerance Gateways can buffer up to 72 hours of events on local diskExplain why these numbers shaped the architecture: 432 GB/day of raw events is noisy, but once summed into hourly buckets per
(tenant, meter, hour), a full year is only ~70 million rows — small enough for a single relational database. The hard engineering problem is not storage volume; it is counting 60,000 events/s accurately across crashes, retries, and skew without slowing down API gateways.Explicit ownership boundary - Owned by me: Protobuf event schema, gateway producer library, streaming aggregator service, Postgres schema, usage read API, hourly/monthly reconciliation jobs, and cutover migration. - Owned by partner teams: API gateways calling my producer library (gateway team), managed Kafka and Postgres host infrastructure (platform team), and invoice PDF/charging pipeline (billing team).
Show the API contracts and database schema you owned
Interviewers quickly test ownership by asking "what fields were in the message?" and "what was the primary key?". Showing concrete schemas immediately establishes credibility.
Usage Event (Protobuf, validated via Schema Registry) event_id UUID -- equals the gateway's unique API request ID tenant_id int64 -- customer tenant identifier meter enum -- REQUEST_UNITS = 1, EGRESS_BYTES = 2, ... (strict enum, not free text) quantity int64 -- integer units (1 unit, or exact bytes) event_ts timestamp -- when the gateway served the call; determines the billing hour region string -- e.g., "us-east-1" Usage Read API (REST, owned by me) GET /v1/tenants/{id}/usage?meter=REQUEST_UNITS&from=...&to=...&granularity=hour|day -> { "rows": [{ "hour": "2026-11-27T15:00:00Z", "meter": "REQUEST_UNITS", "quantity": 24610 }], "complete_through": "2026-11-27T15:58:50Z" } GET /v1/usage/closed-months/{yyyy-mm} -> finalized monthly per-tenant totals for invoice generation-- Monthly range-partitioned table so dropping old partitions is instant metadata work CREATE TABLE usage_hourly ( tenant_id bigint NOT NULL, meter smallint NOT NULL, hour timestamptz NOT NULL, quantity bigint NOT NULL, PRIMARY KEY (tenant_id, meter, hour) ) PARTITION BY RANGE (hour); -- Stores each Kafka partition's next unread offset in the SAME Postgres database CREATE TABLE consumer_offsets ( topic text NOT NULL, partition int NOT NULL, next_offset bigint NOT NULL, PRIMARY KEY (topic, partition) );Two design details to explain up front: -
complete_throughis a low-watermark (a timestamp guaranteeing that every partition has processed all on-time events older than this point; if a partition is caught up to the end of its Kafka log with zero lag, its watermark tracks current gateway clock minus a few seconds). The UI labels data newer thancomplete_throughas "still updating", and marks the trailing 72 hours as "provisional" in case a disconnected gateway uploads buffered events later. Our freshness SLI (service-level indicator) is simplynow - complete_through. -consumer_offsetssits in Postgres alongsideusage_hourlyso that adding usage counts and advancing our Kafka read position happen inside one atomic database transaction.Draw the architecture and trace one event end to end
Draw one clean diagram, then trace a single API call through every hop so the interviewer can point at any box and ask "what happens if this crashes?".
Customer API Request | v +--------------+ 1. Respond to caller first; enqueue event in memory -> Kafka | API Gateways | (idempotent producer, acks=all; 72h local disk fallback) +------+-------+ | key = tenant_id v +--------------------------------------------+ | Kafka: telemetry-usage-v2 (64 partitions) |----\ archival connector +------+-------------------------------------+ \---> Object Storage (Parquet, 13 mos) | 2. consumer group raw events for audit & replay v +--------------------------------------------+ | Aggregator Service (mine, 8 instances) | | 3. Pre-sum per (tenant, meter, hour) | | in memory over 1-second windows | | 4. Commit 1 Postgres txn per partition | | (advance offset + upsert counters) | +------+-------------------------------------+ | v +------------------+ sync +-----------------+ async (<1s) +--------------+ | Postgres Primary |-------->| Sync Standby DB |-------------->| Read Replica | +--------+---------+ +-----------------+ +------+-------+ | 6. month close (day 4, 00:00 UTC) | 5. queries v v +------------------+ +----------------+ | Billing Service | | Usage Read API | +------------------+ +--------+-------+ | Reconciler (hourly): compares gateway Prometheus counters vs DB v Monthly Audit: recounts DISTINCT event_id from Parquet before billing Dashboard & QuotaWalk one concrete event along the three paths: - Write path: Tenant
408makes an API call at15:14:02 UTC. The gateway returns the HTTP response immediately, then hands aUsageEvent(tenant_id=408, meter=REQUEST_UNITS, quantity=1) to my background producer library, which writes it to Kafka partition11(hash(408) mod 64). Aggregator instance3(which owns partition11) sums all events arriving on partition11during that 1-second tick in memory, then runs one Postgres transaction that updatespartition 11'snext_offsetand adds the summed delta to(408, REQUEST_UNITS, 15:00). - Read path: When Tenant408opens the dashboard, the Usage Read API queries the asynchronous read replica (replication lag < 1 s), keeping dashboard queries completely off the primary writer. - Month-close billing path: On day 4 of the next month at00:00 UTC(after the 72-hour late-event window closes) and after the Parquet recount passes within0.01%, the Billing Service reads finalized totals from the Postgres primary.Defend data store and consistency choices against alternatives
In Part 2, every "why did you pick X?" question is really asking "what requirement ruled out Y?". Tie every answer back to the numbers from Step 3:
Component chosen Rejected alternative Specific requirement that ruled it out Postgres for hourly counters Cassandra distributed counters Cassandra counter increments are not idempotent (safe to repeat without changing the result): retrying a timed-out increment counts the usage twice, and Cassandra cannot update a counter table and a Kafka offset row in one atomic transaction. Postgres for hourly counters DynamoDB TransactWriteItemsDynamoDB was our closest contender because TransactWriteItemscan atomically update counters plus an offset item. However, DynamoDB caps a transaction at 100 items. Across 64 partitions, ~5,000 active keys/s at peak is already ~78 counter rows + 1 offset row per 1-second batch, and catching up after an outage spans multiple hours (hundreds of rows per batch), blowing past the 100-item ceiling. SQL also made month-close and reconciliation queries trivial.Postgres as source of truth ClickHouse / columnar warehouse Columnar stores excel at scanning billions of raw rows (and we used Parquet scans for our monthly audit), but lack lightweight row-level OLTP transactions for atomic offset-plus-counter updates every second. At ~70M aggregated rows/year, Postgres fits comfortably. Single primary + sync standby Application-sharded Postgres Pre-aggregating for 1 second collapses 60,000 events/s into ~5,000 row updates/s at peak — well under what our benchmarked primary sustained. Sharding early would have complicated cross-tenant billing and audit queries for zero immediate gain. State four consistency rules explicitly: - Isolation level: Postgres's default
READ COMMITTEDis sufficient becauseINSERT ... ON CONFLICT DO UPDATE SET quantity = usage_hourly.quantity + EXCLUDED.quantitytakes a row-level write lock and atomically increments the committed counter value, while our offset compare-and-set serializes batches per partition. - Event time, not processing time: An event delayed for 2 hours on a gateway disk still carries its originalevent_ts, so it increments the hour when the customer actually used the API. - Eventual consistency for dashboards, strong consistency for invoices: Dashboards tolerate < 1 s replica lag; monthly billing reads the primary after the late window closes. - 72-hour late-event cutoff: Closing January's bill at00:00 UTCon February 4 gives a full 72 hours afterJan 31 23:59:59 UTCfor recovering gateways to flush disk buffers. Anything older routes to a dead-letter queue (DLQ) (a side topic holding unprocessable messages for inspection) for manual credit/debit review.Defend communication patterns, delivery guarantees, and zombie fencing
Why asynchronous Kafka on the write path, but synchronous REST on the read path? Putting a synchronous RPC to the metering service inside every customer API request would add network latency to every call and let a metering bug take down the main API product. Decoupling through Kafka (backed by a 72-hour local disk buffer on each gateway) means a total metering outage has zero impact on live API availability — usage dashboards simply fall behind until the aggregator catches up. Conversely, dashboards and billing jobs want simple request/response queries, where synchronous REST with HTTP caching is simplest.
End-to-end delivery guarantees — never claim "magic exactly-once" without breaking it down per hop:
Hop 1: API response -> Gateway producer At-least-once (if a gateway crashes mid-flush, its disk journal can resend; Parquet audit measured < 0.001% dupes) Hop 2: Gateway producer -> Kafka broker Idempotent within producer session (Kafka sequence numbers drop network-retry duplicates; acks=all prevents broker loss) Hop 3: Kafka partition -> Postgres DB Effectively exactly-once (offset + counter increments commit together in one atomic Postgres transaction)Why not use Kafka's built-in transactions? Kafka transactions only guarantee atomic read-process-write back into Kafka. Because our sink is Postgres, storing offsets inside Postgres in the same transaction as the counter updates is simpler and truly atomic.
Fencing "zombie" consumers during a Kafka rebalance: Suppose Consumer A owns partition
11starting at offset540200, freezes during a garbage-collection pause, and loses partition11to Consumer B. Consumer B processes540200..546899and commitsnext_offset = 546900. Seconds later, zombie Consumer A wakes up and tries to commit its stale batch. We stop it using a compare-and-set (an update that succeeds only if the current value still matches the expected old value) as the first statement of the transaction:BEGIN; -- Step 1: Claim the offset baton FIRST. If another consumer took over partition 11, -- next_offset is no longer 540200, so 0 rows update and we immediately ROLLBACK -- before touching any usage_hourly rows. UPDATE consumer_offsets SET next_offset = 546900 WHERE topic = 'telemetry-usage-v2' AND partition = 11 AND next_offset = 540200; -- Application checks: if updated_rows == 0 -> ROLLBACK! -- Step 2: Upsert pre-summed hourly deltas, sorted by (tenant_id, meter, hour) -- so lock acquisition order is always deterministic. INSERT INTO usage_hourly (tenant_id, meter, hour, quantity) VALUES (408, 1, '2026-11-27 15:00+00', 6100), (408, 2, '2026-11-27 15:00+00', 890) ON CONFLICT (tenant_id, meter, hour) DO UPDATE SET quantity = usage_hourly.quantity + EXCLUDED.quantity; COMMIT;Walk through one hard production challenge from symptom to proof
Prepare one deep failure or bottleneck story with real diagnostic evidence rather than guesswork ("it was slow, so we added Redis").
Symptom: Three weeks after launch, consumer lag spiked to ~45 minutes every weekday during the 9:00 a.m. traffic peak, turning dashboards stale. Strangely, Postgres CPU sat at just 32%, disk IOPS were low, and scaling the aggregator from 8 instances to 16 made lag worse, not better.
Step-by-step diagnosis: 1. Check partition balance: Lag grew at the exact same rate across all 64 Kafka partitions, proving the bottleneck was downstream in Postgres rather than a single slow consumer. 2. Inspect database wait events: Querying Postgres's
pg_stat_activityshowed 14 of 16 aggregator connections idle inwait_event_type = 'Lock'(transactionid), with p99 transaction commit latency at 2.1 seconds. Postgres wasn't CPU-bound; sessions were waiting in a single-file line for row locks! 3. Pinpoint the locked rows: Joining waiting sessions againstpg_blocking_pids()revealed every blocked worker was waiting on the exact same 3 current-hour rows belonging to our largest tenant (20% of all events). 4. Trace why every worker touched the same tenant: Version 1 partitioned Kafka byevent_id("to spread events evenly across partitions"). Because that largest tenant's events landed on all 64 partitions, all 16 aggregator instances tried to update that tenant's row in every batch — serializing behind one row lock, and occasionally deadlocking when batches updated keys in different orders!v1 (key = event_id): 64 partitions ---> ALL 8-16 workers lock Tenant A's row -> 2.1s lock queue! v2 (key = tenant_id): Tenant A hashes to Partition 11 ONLY ---> 1 worker updates Tenant A -> 0 lock waits!Three-part fix and zero-downtime migration: - Re-key Kafka by
tenant_id(telemetry-usage-v2) so at most one consumer owns a given tenant's rows at any moment, eliminating cross-worker lock contention completely. - Pre-aggregate 1 second in memory and sort rows by(tenant_id, meter, hour)beforeINSERT ... ON CONFLICT, slashing peak DB row writes from ~60,000/s to ~5,000/s and guaranteeing deadlock-free lock ordering. - Replace the 600 GB per-eventprocessed_eventsdedupe table with the lightweight 64-rowconsumer_offsetstable above, trading away gateway-crash duplicate filtering inside Postgres (which our monthlyDISTINCT event_idParquet audit already catches at < 0.001%) for a 10x write reduction. - Cutover: Gateways switched fromv1tov2region by region on an hour boundary while aggregators drainedv1and consumedv2simultaneously; every event went to exactly one topic.Verification & result: Replaying a recorded peak hour from Parquet at 3x traffic in staging held lag under 8 seconds. In production, weekday peak lag dropped from 45 minutes to < 4 seconds, p99 commit time fell from 2.1 s to 30 ms, and deadlocks dropped to zero.
Cover failure modes, scaling limits, operations, and honest regrets
Wrap up by showing you operated the system in production and know exactly where its next limits sit.
Failure handling summary
Failure scenario System behavior & recovery Aggregator instance crashes or deploys Kafka reassigns its partitions; new owner reads next_offsetfrom Postgres and resumes with zero double-counting.Postgres primary hardware failure Synchronous standby promotes in ~30 s with zero committed data loss; aggregators retry buffered batches and drain lag within a minute. Kafka cluster unreachable from gateways Producer library spills events to a 72-hour local disk ring buffer; if disk fills, drops are counted on a paging metric — live API calls never block. Poison / malformed message Schema-invalid payload routes to the dead-letter topic with partition/offset metadata and triggers an alert without stalling the partition. Operations & observability - Key metrics: consumer lag measured in seconds (messages alone hide whether 10,000 queued messages mean 0.2 s or 10 minutes), freshness (
now - complete_through), DB commit p99, DLQ rate, and hourly gateway-counter vs. Postgres reconciliation diff (pages if > 0.1% for any tenant-hour). - Zero-downtime schema changes: expand-and-contract migrations (add nullable column -> deploy dual-writing code -> backfill -> switch reads -> drop old column).Honest retrospective — what breaks next and what you would change: - Next bottleneck at 10x scale: Partition
11holding the largest tenant (~12,000 events/s today -> ~120,000 events/s at 10x) will saturate a single consumer thread before Postgres runs out of write headroom. Fix: key salting (appending#0..#7to split hot tenants across 8 partitions into partial rows summed at read time). - Why distributed SQL alone wouldn't skip pre-aggregation: Moving from single-primary Postgres to a distributed SQL database like CockroachDB removes the single-node write ceiling when tenant count grows 100x, but two concurrent transactions incrementing the exact same hot(tenant, meter, hour)row still conflict under serializable isolation — so single-writer partitioning and 1-second pre-aggregation remain essential. - What I would do differently from day one: Enforce strict Protobuf enums and hourly reconciliation before onboarding the first tenant, key bytenant_id(with hot-key salting hooks) instead ofevent_id, and run 3x peak replay tests before launch rather than after the first lag spike.
Intuition & how it works
Think of a "present and defend your own project" interview like walking a seasoned building inspector through a house you designed and plumbed yourself, rather than sketching a dream mansion on a whiteboard. Because you choose the system, the interviewer already expects your high-level boxes and arrows to look reasonable; what they are actually testing is whether you laid the pipes with your own hands — why you chose one material over another, how you tracked down a hidden leak under pressure, and what you would build differently today.
The naive approach is to pick the biggest, most famous platform at your company, spend 25 minutes reciting an architecture slide deck, and justify choices with buzzwords like "we chose Kafka and Postgres because they scale." That falls apart the moment Part 2 begins: when the interviewer zooms into a single arrow and asks what happens if a worker crashes mid-commit or why CPU stayed low during an outage, surface-level familiarity is exposed immediately. Picking a focused system you truly owned end to end — and preparing concrete numbers, rejected alternatives, and diagnostic evidence — lets you answer three levels deep with calm authority.
To see how a concrete defense works in our sample API usage-metering pipeline (counting ~1.7 billion request units/day for billing), trace three events e1, e2, and e3 (1 unit each) from Tenant 408 during the 15:00 hour:
1. Route by owner: All three events hash tenant_id = 408 to Kafka partition 11 (offsets 540200, 540201, 540202), so exactly one aggregator worker owns Tenant 408 and never fights another worker for database row locks.
2. Pre-sum and fence: Over a 1-second window, that worker sums e1 + e2 + e3 = +3 in memory, then opens one Postgres transaction that first updates consumer_offsets for partition 11 from 540200 to 540203 via compare-and-set (an update that only succeeds if next_offset is still 540200, blocking any stale "zombie" worker) and then adds +3 to (tenant 408, REQUEST_UNITS, 15:00) via an atomic upsert (insert the row if missing, otherwise add to the existing row).
3. Crash safety: If the worker crashes a millisecond after COMMIT, its replacement reads next_offset = 540203 from Postgres and resumes at 540203, guaranteeing e1..e3 are counted once and never double-billed.
Key trade-offs
- Impressive team platform vs. focused system you owned deeply. Presenting a massive flagship system sounds impressive in minute one, but invites questions about components other teams built. Choosing a smaller, self-contained pipeline you owned from schema to on-call lets you explain every lock, retry, and trade-off firsthand.
- 10-minute map vs. exhaustive monologue. Spending 10 minutes on the problem, five driving numbers, and one end-to-end diagram leaves 35+ minutes for interactive defense, which is where interviewers collect almost all of their hiring signal. Overrunning the intro starves the deep dive.
- Rounded real numbers vs. vague adjectives or invented numbers. Rounding confidential metrics ("~20,000 events/s average, ~60,000/s peak") protects employer IP while keeping every capacity calculation verifiable (
1.728B / 86,400 s = 20k/s). Vague words ("massive traffic") sound evasive, and invented numbers collapse when the interviewer multiplies them out. - Asynchronous messaging vs. synchronous billing calls (sample project). Emitting usage events asynchronously through Kafka (with a 72-hour gateway disk buffer) ensures metering outages add zero latency or downtime to customer APIs, at the acceptable cost of dashboards lagging by seconds or minutes during incidents.
- Postgres with transactional offsets vs. NoSQL or columnar stores (sample project). Storing hourly counters (~70M rows/year) and partition offsets in one Postgres database gives atomic "advance offset + add usage" commits and simple SQL for month-end billing, trading away horizontal write scaling until active tenant keys grow by an order of magnitude.
- Tenant-keyed partitions vs. event-keyed partitions (sample project). Keying Kafka by
tenant_idcompletely eliminates cross-worker database row-lock contention and deadlocks, at the cost of concentrating our largest tenant (20% of traffic, ~12,000 events/s at peak) onto a single partition that eventually needs key salting (splitting one hot key acrossNsub-keys like408#0..408#7).
Common mistakes
- Giving no concrete numbers. Saying "high throughput" and "low latency" gives the interviewer nothing to reason against; always state requests/sec, payload bytes, row growth per year, and p99 latency before and after.
- Drawing boxes without tracing a single request. Static architecture diagrams hide race conditions; walk one event step by step along the write path, read path, and failure recovery path.
- Naming tools instead of constraints. Saying "we used Kafka and Postgres" invites "why not DynamoDB or ClickHouse?"; always pair each chosen component with the runner-up alternative and the exact constraint (such as DynamoDB's 100-item transaction limit) that eliminated it.
- Saying "we" for everything. Blurring personal work with team work destroys trust the moment you have to say "actually, another team wrote that part" during probing; draw the ownership boundary up front in minute three.
- Telling a debugging story with no diagnostic evidence. Jumping straight from "lag was high" to "so we re-keyed Kafka" skips the engineering signal; show the intermediate measurements (
32% CPU+pg_stat_activityrow-lock waits +pg_blocking_pids()) that proved why lag spiked. - Claiming end-to-end "exactly-once" delivery as a blanket slogan. Distributed hops have different guarantees; break delivery down per hop (gateway -> Kafka vs. Kafka -> Postgres) and state openly what an out-of-band audit catches.
- Defending mistakes instead of owning regrets. Pretending version 1 was flawless looks inexperienced; naming concrete improvements you would make today demonstrates senior engineering judgment.
Follow-up questions
- At 10x your current peak load, where is the first saturation point in your architecture, and what early signals would expose it ahead of customer impact? In the sample pipeline, the single Kafka partition and aggregator worker carrying our largest tenant would saturate first (~12,000 events/s today becomes ~120,000 events/s on one thread), whereas Postgres row writes barely budge because 1-second pre-aggregation scales with active tenant keys rather than raw event count. The fix is key salting for top-tier tenants — hashing
tenant_id#0..7across 8 partitions, writingsaltas part of the hourly table key, and summing the 8 rows on read. We catch this months before customers feel it by running monthly 3x and 10x Parquet replay benchmarks in staging and alerting when any single partition crosses 60% of the tested single-consumer ceiling. - Describe a real outage or data-correctness incident on this service—how monitoring surfaced it, how you stopped the bleeding, what caused it, and what structural guardrails followed? A gateway deployment accidentally changed a free-text meter string from
"request_units"to"REQUEST_UNITS", causing the aggregator to write a separate row and making tenant dashboards show an apparent 30% drop in traffic. Our hourly reconciliation job (comparing gateway request counters againstusage_hourly) paged on-call 40 minutes later when the discrepancy crossed 0.1%. We rolled back the gateway release first, then ran one atomic SQL transaction adding each"REQUEST_UNITS"row's quantity into"request_units"and deleting the uppercase rows — crucially, we did not blindly replay Kafka, because additive counters would have double-counted the 70% of gateways that were still emitting lowercase"request_units". Root cause was an untyped string contract across teams, which we permanently fixed by movingmeterto a versioned Protobufenum, validating in my producer library, and routing unknown enum values to the dead-letter queue with an alert. - What cutover strategy allowed you to ship or migrate this pipeline while keeping live customer traffic uninterrupted? First, we ran the streaming pipeline in shadow mode (processing 100% of live traffic in parallel without serving customers or invoices) alongside the legacy nightly batch job for two full monthly billing cycles. A daily comparison script diffed every
(tenant, day, meter)total between the two systems and investigated every variance over 0.01% — confirming that nearly all differences were rotated log files the old batch job had silently dropped. Next, we switched the live dashboard behind a per-tenant feature flag (internal test accounts -> 10% -> 100% for instant one-click rollback), and finally cut invoice generation over while keeping the batch job warm for one extra month as an emergency fallback. - Looking back with hindsight, which architectural or operational decisions would you change on a clean-sheet rebuild? First, I would enforce a strict Protobuf schema registry contract and build the hourly reconciliation job before shipping the dashboard, which would have prevented or caught the casing incident within minutes. Second, I would partition Kafka by
tenant_idwith a built-insaltcolumn (0by default,0..7for whale accounts) from day one instead of learning the hard way that keying byevent_idserializes database row locks on hot tenants. Third, I would start directly with the 64-row transactionalconsumer_offsetstable in Postgres rather than wasting weeks operating a 600 GB per-event deduplication table, and make 3x Parquet replay testing a mandatory pre-launch gate.
Follow-up questions
- At 10x your current peak load, where is the first saturation point in your architecture, and what early signals would expose it ahead of customer impact?
- Describe a real outage or data-correctness incident on this service—how monitoring surfaced it, how you stopped the bleeding, what caused it, and what structural guardrails followed?
- What cutover strategy allowed you to ship or migrate this pipeline while keeping live customer traffic uninterrupted?
- Looking back with hindsight, which architectural or operational decisions would you change on a clean-sheet rebuild?
Similar questions
- Historical Key-Value Lookups by Timestamp
- Global Live Video Streaming Platform
- Multi-User Collaborative Document Editor
- Burst-Resilient Multi-Channel Notification Platform
- Prior Authorization Status Engine, Clinical Worklists, and Digests
- Diagnosing and Optimizing Full-Stack Web Request Latency