Architecture of a multi-tenant DuckDB gateway
QoD puts DuckDB behind one secure endpoint that a whole team can share. Your BI tools, notebooks and applications connect to QoD as they would to a database server. QoD signs each user in, applies the access rules you set, and runs the query on one of several DuckDB nodes, all reading the same tables. This page explains how the parts fit together. If you work on QoD's code, the Architecture map has the component-level view.
How it fits together
QoD has three parts:
- The QoD manager is the one address your tools connect to. It signs users in, checks every query against your access rules, and sends it to a node. It also serves the admin UI and the REST API you use to create tenants, databases, pools and users.
- DuckDB nodes run the queries. A pool holds one or more nodes, and you add nodes when you need more capacity. Every node of a pool reads the same tables, so any node can answer any query.
- Storage that you provide: a PostgreSQL database for QoD's settings and the catalog of your tables, and an object store (S3, GCS, Azure Blob Storage, or a local disk) for the data itself, as Parquet files.
The manager listens on three ports that your tools reach:
| Port | What connects to it |
|---|---|
| 31338 | SQL tools over Arrow Flight SQL with TLS: JDBC, ADBC, BI tools, Python |
| 9494 | DuckDB clients that ATTACH a QoD database over DuckDB's own protocol |
| 20900 | The admin UI and the REST API |
Your tools never connect to the nodes. On a single server the nodes are processes next to the manager, on Kubernetes they are pods, and in a fleet each server runs one node; there, the nodes also call the manager on port 20901, so keep that port open between your servers.
Tenants, databases and pools
QoD organizes what you host in three levels (see Tenancy model):
- A tenant is an organization or a team, isolated from the others. It has its own users and its own way of signing them in: passwords, or your identity provider.
- A database belongs to a tenant and holds your tables: a DuckLake catalog in PostgreSQL, and data files in object storage (see DuckLake catalogs).
- A pool is a group of DuckDB nodes serving one database. Your tools connect to a pool, and you size each pool for its workload, for example one pool for dashboards and another for batch jobs.
What happens to a query
Every query takes the same path, whichever protocol your tool speaks. A query your access rules do not allow never reaches a node.
- Sign-in. QoD checks the user's credential: a password, a token, or a sign-in through your identity provider (OIDC). See Authenticating.
- Access rules. QoD applies what you granted: the tables the user may read or change, the rows they see, and the columns that are masked. A query that reaches beyond the user's rights is refused and recorded in the audit log. See the Access control model.
- Routing. QoD sends the query to the least busy node of the pool that can run it, preferring a node that already has the tables in its cache. All the statements of a transaction go to the same node. See Routing and Sessions and transactions.
- Execution. The node runs the query on your data and streams the results back to your tool.
The rules are checked against what the query actually reads, once DuckDB has resolved its views, macros and functions. A view or a query() call cannot reach a table the user is not allowed to see.
Where your data lives. QoD keeps two kinds of state in PostgreSQL, in separate databases that can share one cluster: its own settings (tenants, pools, users and grants), and for each of your databases the DuckLake catalog that lists your tables. The table data itself is Parquet files in your object storage. See State storage and DuckLake catalogs.
Why it is built this way
- Fast queries on shared tables. Each node is a full DuckDB engine. Your tables live in shared storage, not inside a node, so every node sees the same data and you scale a pool by adding nodes.
- One address for your tools. Your tools only know QoD. It spreads the queries over the nodes, keeps each transaction on one node, and retries a query on another node when one fails, so nodes can come and go without any change on the client side.
- The same rules however you connect. Flight SQL and DuckDB's own protocol go through the same sign-in, the same access rules and the same audit log. The protocol a tool uses changes its driver, not what its user can see.
- One set of rules for all your tables. The same grants cover the tables QoD hosts and the external tables you attach through federation.
Where to go next
- Try QoD: Local deployment, then Single-server deployment to run it in production on one machine.
- Set up your tenants and databases: Tenants and databases.
- Connect your tools: Connecting clients.
- Work on QoD's code: the Architecture map and Extending the manager.