Interview Study Guide
β’ 12 min read
How to use this. Each line is one concept with its short answer. A line is done only when you can say it out loud without looking, then answer “why?” and “what breaks?” about it. Tick as you go. Order = most likely to be asked first.
Deeper notes: Go Runtime & Concurrency Β· DBMS Β· Distributed Systems
1. Your story and numbers (asked in every interview)
- 60-second intro β who you are β what you build at Samsung (Go services, data pipelines, AI tooling) β one big number β why Singapore / this role.
- For every number (1M assets/day, 500K/day at 99%, β54.6% / $610K, 1β2h β 10 min, 405 ms, 14x) know: where it came from, the baseline, the time window, how it was measured, and one caveat.
- For every bullet know: the problem, your part vs the team’s, the design, one trade-off, the hardest bug, what breaks at 10x, what you’d change now.
- “3-stage”, “2-service”, “4-component” on the SG resume β name each stage/service/component.
2. Go
- Goroutine vs thread β managed by the Go runtime; starts with ~2 KB growable stack (threads ~1β8 MB fixed); switch is in user space, so it’s cheap.
- G/M/P scheduler β G = goroutine, M = OS thread, P = processor (run queue, count =
GOMAXPROCS). An M needs a P to run Gs. Idle Ps steal work. Blocking syscalls hand the P to another M. - Channels β unbuffered = sender and receiver meet (sync); buffered = queue of N. Send on closed channel panics; receive from closed returns zero value. Nil channel blocks forever.
-
selectβ waits on many channel ops; picks a random ready one;defaultmakes it non-blocking. -
contextβ carries cancellation, deadlines, request values down the call tree. Goroutinesselectonctx.Done()to stop. Alwaysdefer cancel(). -
sync.Mutex/RWMutexβ protect shared data; RW allows many readers or one writer. -
sync.WaitGroupβ wait for N goroutines;Addbeforego,Donein a defer. -
sync/atomicβ lock-free counters/flags. - Race detector β
go test -race; only finds races that actually execute in the test. - Goroutine leak β goroutine blocked forever on a channel no one reads; fix with context/close/buffer.
- Worker pool β N goroutines read jobs from one channel β bounded concurrency + backpressure.
- Errors β values, not exceptions; wrap with
fmt.Errorf("...: %w", err), check witherrors.Is/As.paniconly for bugs. - Interfaces β implicit; small interfaces (
io.Reader). Nil interface vs interface holding nil pointer gotcha. - Slices β pointer + len + cap over an array;
appendmay reallocate; two slices can share memory. - Maps β not safe for concurrent writes (runtime panic); use mutex or
sync.Map. - GC β concurrent mark-and-sweep, low pause; tune with
GOGC; reduce allocations to reduce GC. - Escape analysis β compiler decides stack vs heap; returning a pointer to a local moves it to the heap (
go build -gcflags=-m). - pprof β CPU, heap, goroutine profiles; how you’d find a slow path.
3. Python
- GIL β only one thread runs Python bytecode at a time. Threads help I/O-bound work (network, disk β GIL released while waiting); CPU-bound work needs
multiprocessing. - threads vs processes vs asyncio β threads: I/O, simple; processes: CPU, separate memory; asyncio: one thread, thousands of I/O tasks, cooperative (
await). - Bounded concurrency β
asyncio.Semaphore(n)orThreadPoolExecutor(max_workers=n). - Timeouts / retries β
asyncio.wait_for; retry with exponential backoff + jitter; only retry transient errors. - Generators β lazy iteration with
yield; constant memory over big data. - Decorators, context managers (
withβ__enter__/__exit__), mutable default args gotcha, list vs tuple vs dict vs set complexity.
4. Concurrency (general)
- Race condition β result depends on timing of unsynchronised access to shared data.
- Deadlock β circular wait. Needs: mutual exclusion, hold-and-wait, no preemption, circular wait. Avoid: always lock in the same order; timeouts.
- Livelock / starvation β threads keep reacting but no progress / one thread never gets the resource.
- Mutex vs semaphore β mutex = 1 owner; semaphore = N permits.
- Backpressure β slow consumer pushes back on producer (bounded queue blocks / rejects) instead of memory blowing up.
- Producerβconsumer β bounded queue between them.
5. SQL and databases
- Joins β inner, left, right, full; NULLs don’t equal each other (
IS NULL). - GROUP BY / HAVING, window functions (
ROW_NUMBER,RANK,LAG, running totals), CTEs. - Classic queries β top-N per group, dedupe (keep latest), second highest, running total, gaps.
- Index = B+ tree β sorted keys β row location; lookup O(log n) vs full scan; leaves linked for range scans. Writes slower: every index updated.
- Composite index β leftmost-prefix rule: index (a, b) helps
WHERE a=anda= AND b=, notb=alone. - Covering index, when an index isn’t used (function on column, low selectivity, leading
%LIKE). -
EXPLAIN ANALYZEβ read seq scan vs index scan, rows estimated vs actual. - ACID β Atomic (all or nothing), Consistent (constraints hold), Isolated (concurrent tx don’t interfere), Durable (committed survives crash, via WAL).
- Isolation anomalies β dirty read, non-repeatable read, phantom, lost update, write skew.
- Isolation levels β Read Committed (Postgres default), Repeatable Read, Serializable.
- Lost update fix β atomic
UPDATE ... SET x = x - 1 WHERE x >= 1;SELECT ... FOR UPDATE; optimistic lock with version column. - MVCC β readers see a snapshot, don’t block writers.
- WAL β write log first, then data; crash recovery replays it.
- Normalisation vs denormalisation β fewer anomalies vs faster reads.
- Replication β primary takes writes, replicas lag β stale reads; read-your-writes by reading the primary after a write.
- Sharding β split data by key; hot shards; cross-shard queries are hard.
- SQL vs NoSQL β choose by access pattern, consistency need, scale.
- TimescaleDB β Postgres extension; hypertable auto-split into time chunks; retention = drop old chunks; compression; continuous aggregates = auto-refreshed rollups.
6. Kafka
- Topic β partitions β offsets β a partition is an append-only log; offset = position.
- Ordering β only within a partition. Same key β same partition. Adding partitions remaps keys.
- Producer acks β
acks=0fire-and-forget,1leader wrote,allall in-sync replicas wrote. - Replication β leader + followers; ISR = in-sync replicas; leader dies β an ISR member takes over.
- Consumer group β each partition read by one consumer in the group; more consumers than partitions = idle consumers.
- Rebalance β consumer joins/leaves β partitions reassigned; processing pauses.
- Offset commit β commit after processing = at-least-once (duplicates possible); before = at-most-once (loss possible).
- Exactly-once β idempotent producer + transactions; in practice: at-least-once + idempotent consumer (dedupe by event ID).
- Consumer lag β latest offset β committed offset; the main health metric.
- Retention β by time/size; log compaction keeps the latest value per key.
- Dead-letter topic β park poison messages so the partition keeps moving.
- Kafka vs RabbitMQ/SQS β Kafka: replayable log, high throughput, ordering per partition; queues: per-message ack, delete on consume.
7. Distributed systems
- CAP β during a network partition, pick consistency (refuse) or availability (serve possibly stale).
- Consistency models β strong/linearizable, read-your-writes, eventual.
- Replication β leader-follower, multi-leader, leaderless (quorum: W + R > N).
- Partitioning β range vs hash; consistent hashing moves few keys when nodes change.
- Consensus (Raft) β elect a leader, replicate a log to a majority; survives minority failures. Used by etcd, Kafka KRaft.
- Leader election, split brain β two leaders; fixed by majority quorum + fencing tokens.
- Clocks β wall clocks drift; use logical clocks / versions for ordering.
- Distributed transactions β 2PC (blocking); saga = local steps + compensations.
- Outbox pattern β write event to DB table in same tx, relay to Kafka β no lost/dual writes.
- Idempotency β same request twice = same effect; idempotency key.
- Retries β exponential backoff + jitter; retry budget to avoid retry storms.
- Circuit breaker β stop calling a failing dependency, fail fast, probe later.
- Timeouts everywhere, bulkheads (isolate resources), graceful degradation.
8. Backend / API design
- HTTP methods β GET/PUT/DELETE idempotent; POST not. Status codes β 200, 201, 204, 400, 401, 403, 404, 409, 429, 500, 503.
- Pagination β offset (simple, slow + shifting) vs cursor (stable, fast).
- Auth β authN = who you are (JWT, OAuth, API keys); authZ = what you may do.
- Rate limiting β token bucket / sliding window; return 429.
- Caching β cache-aside (read cache β miss β DB β fill); on write update DB then delete key; TTL as safety net. Stampede fix: lock or early refresh. Write-through vs write-back.
- Versioning, consistent error format, input validation at the boundary.
- Microservices β clear boundaries, sync (HTTP/gRPC) vs async (queue), service discovery, each hop needs timeout + retry + metric.
- Observability β logs (what), metrics (how much β RED: rate, errors, duration), traces (where time went).
9. Networking
- URL β response β DNS (name β IP) β TCP handshake (SYN, SYN-ACK, ACK) β TLS handshake (certs, keys) β HTTP request β load balancer β app β DB β response.
- TCP vs UDP β TCP: connection, ordered, reliable, flow + congestion control. UDP: no guarantees, low latency (video calls, DNS, games).
- HTTP/1.1 vs 2 vs 3 β keep-alive; multiplexing over one connection; QUIC over UDP.
- TLS β encrypts + authenticates the server with a certificate.
- Load balancer β L4 (TCP) vs L7 (HTTP, path routing); health checks; round robin / least connections.
- DNS β records (A, CNAME), TTL caching. CDN, reverse proxy.
- WebSocket vs polling, gRPC (HTTP/2 + protobuf).
10. OS and Linux
- Process vs thread β threads share heap, code, globals, file descriptors; each has own stack + registers. Thread switch cheaper (no address-space change).
- Context switch β save/restore registers; process switch also changes page tables (TLB flush).
- Virtual memory β each process sees its own address space; page tables map to physical; page fault loads a page.
- Stack vs heap β stack: function frames, automatic; heap: dynamic, GC/free.
- File descriptors, signals (SIGTERM graceful, SIGKILL not catchable), pipes.
- I/O models β blocking, non-blocking, epoll (how Go’s netpoller handles thousands of connections).
- Page cache,
fsync. - Debug commands β
top/htop,ps,lsof,netstat/ss,strace,df,free,journalctl,curl -v,dig.
11. Data stack
Airflow
- DAG of tasks; scheduler; executor (Local/Celery/K8s); retries + timeouts per task; pools cap concurrency; tasks must be idempotent (re-runs, backfills); XCom only for small data.
Spark / EMR
- Driver plans, executors run tasks; lazy transformations, actions trigger a job.
- Narrow (map, filter) vs wide (groupBy, join β shuffle). Shuffle = expensive network + disk.
- Skew β one key dominates β one slow task; fix: salting, broadcast join.
- Broadcast join for small tables; partitions sizing; caching; fault tolerance via lineage.
- EMR β managed Spark cluster on EC2; data in S3; autoscaling; spot instances for cost.
Snowflake + dbt
- Storage separate from compute; virtual warehouses (XSβ¦4XL) billed in credits per second while running; auto-suspend/resume; queuing when busy.
- Bigger warehouse = faster but more credits/hour; right-sizing = route each workload to the smallest warehouse that meets its SLA (your $610K story).
- Result cache, micro-partitions, clustering keys, query profile.
- dbt β SQL models + dependencies (DAG), materialisations (view, table, incremental), tests, docs.
12. AI stack
- Embeddings β text β vector; similar meaning = close vectors (cosine similarity).
- RAG β chunk docs β embed β store in vector DB β at query time retrieve top-k β put in prompt β generate.
- Chunking, top-k, reranking (cross-encoder rescoring), metadata filters.
- Vector index β HNSW (graph-based approximate nearest neighbour); Qdrant uses it.
- Evaluate separately β retrieval (did we fetch the right schema?) vs generation (is the SQL correct?).
- Text-to-SQL safety β read-only role, parse/validate SQL, row limits, timeouts, allow-listed tables, audit log.
- LangGraph β state graph: nodes (steps/agents), edges (conditional routing), shared state, retries, stop condition. Why multi-agent: separate retrieve / generate / validate / fix steps.
- MCP β protocol letting AI apps call tools: host β client β server; server exposes tools with JSON schemas. Risks: prompt injection, over-broad permissions β least privilege, validate inputs.
- Bedrock β AWS managed LLM API; quotas, throttling β retries; data stays in AWS.
- FastAPI β ASGI, async endpoints, Pydantic validation, dependency injection; never block the event loop with CPU work.
- LLM serving basics (for AI-infra roles) β tokens, prefill vs decode, KV cache, batching, latency (TTFT) vs throughput.
13. Infra and DevOps
- Docker β image = layers; container = running image; layer caching (copy deps first); multi-stage builds; volumes; non-root user.
- Kubernetes β Pod, Deployment (replicas + rolling update), Service (stable IP/DNS), Ingress; ConfigMap/Secret.
- Probes β liveness (restart if dead), readiness (send traffic only when ready), startup.
- Requests/limits β scheduling vs cap; over memory limit β OOMKilled.
- HPA β scale pods on CPU/custom metrics. Rollback β
kubectl rollout undo. - Helm β templated K8s manifests + values; releases with rollback.
- AWS β EC2 (VMs), S3 (object store, strongly consistent now), IAM (roles + least privilege), VPC basics.
- CI/CD β build β test β deploy; blue-green vs canary vs rolling; secrets never in repo.
- Git β merge vs rebase, resolving conflicts, revert vs reset.
14. System design
Method (use every time): requirements (functional + scale numbers) β back-of-envelope (QPS, storage) β API β data model β high-level diagram β deep dive on the bottleneck β failures + scaling β trade-offs.
- Numbers to know: 1 day β 86,400 s β 10^5 s; 1M/day β 12/s avg; memory ~100 ns, SSD ~100 Β΅s, same-region network ~0.5 ms, cross-region ~100 ms.
- Your three designs β (1) 500K/day creative validation pipeline; (2) Narad at 10x logs; (3) safe text-to-SQL.
- Classics β URL shortener, rate limiter, notification system, chat, news feed, distributed cache, job scheduler, web crawler (you built one!).
15. DSA (live coding)
- Protocol β clarify β examples β brute force β complexity β optimise β code β dry run β edge cases. Talk the whole time.
- Patterns β two pointers, sliding window, binary search (incl. on answer), prefix sums, hashing, stack/monotonic stack, heap/top-k, BFS/DFS, topological sort, union-find, Dijkstra, DP (1D, 2D, knapsack, intervals), backtracking, tries, intervals, LRU cache.
16. Other languages on the resume (be honest)
- Rust β ownership, borrowing, lifetimes,
Result/Option,Arc<Mutex>,Send/Sync, async (tokio). Explain one web-shooter request path. - C++ β RAII, smart pointers, move semantics, STL complexity, virtual functions.
- Java β JVM/GC, collections,
equals/hashCode, executors,volatile/synchronized. - If you can’t defend one, say “used it for X, not production depth” β or remove it.
17. Behavioural
- STAR stories (situation, task, action, result with a number) for: hardest bug, a conflict, a failure, ownership beyond your role, a tight deadline, disagreeing with a senior, learning something fast.
- Logistics β why Singapore, notice period, EP sponsorship needed, expected salary, start date.
- Questions to ask them β team’s biggest technical problem, on-call, how success is measured in 6 months.