KatInterview

Building a Multi-Tenant SQL Gateway on Iceberg Data Lakes

System DesignModel answer
HardModel answerSystem Designsystem-designapache-icebergdistributed-query

Last updated

Architect a hosted service that accepts SQL from a UI or API, plans and runs it against Iceberg tables on shared compute, and returns results while isolating tenants and handling writes.

You are asked to design a hosted platform where people write SQL and receive answers, and where every table lives in Apache Iceberg format on object storage. Users reach it through a browser console or a programmatic API. The platform takes each statement, executes it against the relevant Iceberg tables, and delivers the output.

Walk through your design as you would in a system design discussion. Before diving in, state which assumptions you would confirm, for example:

  • Is the platform read-only, or must it also support INSERT, UPDATE, DELETE and MERGE?
  • Are the workloads interactive, scheduled batch, or a mix, and what latency does each need?
  • Is it multi-tenant, and how strongly must tenants be isolated in terms of load and data access?
  • Do we write our own engine, or wrap an existing distributed engine?
  • What are the expected concurrency, table sizes and result sizes?
  • Which catalog manages the tables, and do other systems write to them too?

Your answer should address:

  1. The API and the lifecycle of a query: submit, poll status, cancel, and fetch results that may be very large.
  2. How planning uses the catalog, snapshots, manifests and column statistics to skip irrelevant files, and how a query sees one consistent view of a table.
  3. Distributed execution, scaling of workers, admission control and tenant isolation.
  4. Write and commit behavior, including what happens when two writers target the same table.
  5. Failure handling, authorization on tables and on storage, table maintenance, and observability for each query.

Hints

Hint 1

Pin the query's view of the table at planning time by resolving the table to a single snapshot ID, and carry that ID through every task. Think about what this buys you for retries and for repeatable results.

Hint 2

Iceberg metadata forms a tree: catalog pointer, metadata file, manifest list, manifests, data files. Each level carries statistics (partition ranges, column min/max, counts) that let the planner discard work before any data file is opened.

Hint 3

For writes, think optimistic concurrency: writers produce new files first, then atomically swap the catalog's metadata pointer. Consider what a loser of that race must do, and why row-level deletes and compaction add complications.

Hint 4

Separate the control plane (API, scheduler, planner, catalog access) from the data plane (stateless workers), and put a queue with per-tenant quotas in between so one tenant cannot starve others.