KatInterview

Execution Models, Go Concurrency, and Choosing a Database

System DesignModel answer
EasyModel answerSystem Designconcurrencygolangasync-io

Last updated

Explain how sync/async differs from blocking/non-blocking, when Go channels or mutexes fit best, and how relational and NoSQL stores compare for backend workloads.

Three short conceptual questions that a backend engineer should be able to answer with precise definitions and concrete examples.

Part 1: Execution models

  • Define synchronous and asynchronous execution.
  • Explain why this is a different axis from blocking and non-blocking I/O.
  • Give one backend example of each, such as serving an HTTP request or calling a downstream service.

Part 2: Concurrency in Go

  • Describe, at a high level, how Go runs concurrent code (goroutines and the runtime scheduler).
  • Compare coordinating work by passing messages over channels with coordinating it by sharing memory behind locks.
  • Say when you would choose each, and name the typical failure modes: deadlocks, data races, and goroutine leaks.

Part 3: Relational vs NoSQL databases

  • Compare relational databases with the main NoSQL families (key-value, document, wide-column).
  • Discuss the trade-offs in:
    • data modeling and query patterns
    • transactions and consistency
    • scaling (vertical vs horizontal)
    • operational burden
  • Give a few workloads where you would strongly pick SQL, and a few where you would strongly pick NoSQL.

Aim for a structured answer that separates concepts people tend to confuse and supports each claim with an example.

Hints

Hint 1

Treat sync/async as a question of how the caller's control flow relates to completion, and blocking/non-blocking as a question of what the thread does while waiting. Then try placing examples in a 2x2 grid.

Hint 2

For Go, a useful rule is: channels move ownership of data or orchestrate work; mutexes and atomics protect a small piece of shared state. For each pitfall, think of one concrete scenario that causes it and one tool that prevents it (context cancellation, the race detector, consistent lock ordering).

Hint 3

For databases, start from access patterns rather than technology: what are the queries, how much cross-entity consistency is needed, and how will the data grow? Remember that many NoSQL systems have gained transactions and many SQL systems can scale out, so frame differences as defaults and trade-offs.