Scrivio Interview library
DesignAdvanced6 min read · updated 13 November 2026

You are designing tenancy for a shared Kafka platform where 60 teams create topics, some produce terabytes a day, and one team once created 5,000 partitions by mistake.

Design the isolation model: namespaces, quotas, limits on partitions and topic configs, protection from noisy neighbours, and when a tenant gets its own cluster.

Give each team a topic namespace by prefix, enforced with prefixed ACLs, and create topics only through a pipeline or operator. On the brokers, CreateTopicPolicy and AlterConfigPolicy plugins reject too many partitions, replication factor below 3, missing retention or forbidden configs, and controller_mutation_rate limits how fast a tenant can create or delete partitions. Kafka has no per-tenant partition or storage quota, so budgets per namespace live in the provisioning system with retention.bytes caps on unpredictable topics, while produce, consume and request_percentage quotas per principal isolate throughput. A tenant gets its own cluster when it is a large share of the load, needs different SLOs or upgrade timing, or must be physically separated.

Why this question is asked

Sixty teams on one cluster is a great deal for the company, until one team's mistake becomes everyone's outage. The 5,000-partition accident is typical: nothing in a default Kafka setup stops it, and the cost lands on the controllers and every broker. Interviewers ask this to see whether we know which isolation Kafka gives us natively, which we must build around it, and when sharing stops making sense. In this answer, we will set up namespaces and topic creation, add broker-side policies, build the budgets Kafka does not enforce, isolate throughput with quotas, and decide when a tenant gets its own cluster.

1Namespaces and Who Creates Topics

Each team gets a namespace, a topic name prefix such as payments.orders. or the pattern team.domain.topic. Prefixed ACLs give a team's principals rights on its prefix, so a team can only see and use its own topics, plus any it has been granted explicitly.

Teams do not get the right to create topics directly. Instead, they declare topics in a Git repository or through a Kubernetes operator custom resource, and the pipeline creates them with an administrative principal after checks. That gives one place to enforce naming, partitions, replication and retention, one record of who asked for what, and a catalogue of owners for free.

Step throughTenant isolation, outside to inside
  1. Provisioning pipelinenamespaces, budgets, owners, reviews
  2. Broker policiesCreateTopicPolicy, AlterConfigPolicy
  3. Quotas per principalbytes, request time, controller mutations
  4. ACLs per namespaceprefixed grants, deny by default
  5. Dedicated clusterfor tenants sharing cannot serve

5 layers, from the top down. Step through them one at a time.

Each layer catches what the one above it lets through.

2Broker-Side Policies as the Backstop

A pipeline can be bypassed, by an admin script or a tool with too many rights. So the brokers enforce the essential rules themselves. create.topic.policy.class.name names a plugin that validates every topic creation, and alter.config.policy.class.name one that validates every config change. They can reject a topic with more than, say, 48 partitions, a replication factor below 3, a topic without an explicit retention, or a config such as min.insync.replicas=1 or unclean.leader.election.enable=true.

Java
public class TenantConfigPolicy implements AlterConfigPolicy {
private static final Set<String> FORBIDDEN = Set.of("unclean.leader.election.enable", "message.timestamp.type");
@Override public void configure(Map<String, ?> configs) { }
@Override
public void validate(RequestMetadata req) throws PolicyViolationException {
for (String key : req.configs().keySet()) {
if (FORBIDDEN.contains(key)) {
throw new PolicyViolationException(key + " may not be changed by tenants");
}
}
}
@Override public void close() { }
}
// alter.config.policy.class.name=com.example.TenantConfigPolicy (on brokers and controllers)
// kafka-configs.sh --alter --entity-type topics --entity-name payments.x --add-config unclean.leader.election.enable=true
// -> PolicyViolationException: unclean.leader.election.enable may not be changed by tenants

For the speed of changes, controller_mutation_rate is a quota on how many partitions a principal may create or delete per second. Set as a default for all users, for example 10 per second, it turns a 5,000-partition mistake into a slow trickle that the pipeline or an alert catches long before it hurts the controllers. Requests over the rate are rejected with a throttling error rather than delayed, so scripts see the limit.

3Budgets Kafka Does Not Enforce

Kafka has no built-in quota for the number of partitions or the bytes stored per tenant. Byte-rate quotas limit speed, not volume. So the provisioning system keeps the budget: for each namespace, the partitions it may own and the storage it may retain, computed from its topics' partitions, replication factor and retention. A request that would exceed the namespace budget needs a review.

Storage is the slippery one, because a topic with time-based retention grows with its traffic. For topics with unpredictable volume, we require retention.bytes as well as retention.ms. retention.bytes applies per partition, so a 12-partition topic with 50 GB per partition is bounded at 600 GB per replica set, whatever the traffic does.

4Isolating Throughput With Quotas

Every principal gets produce, consume and request_percentage quotas, sized from what the team declared when onboarding and reviewed in the capacity process. A conservative default applies to every user without an explicit quota, so a new service cannot surprise anyone. request_percentage matters as much as byte rates: a client sending thousands of tiny requests can exhaust request threads while staying far under its byte quota.

We also require distinct client ids per application, set from the application name. They are not a security boundary, but they make metrics and throttling per application visible, which turns a noisy-neighbour investigation from hours into minutes.

5When a Tenant Gets Its Own Cluster

Logical isolation through namespaces and quotas works until the tenant's needs differ from what a shared cluster can promise. Some cases are clear. A tenant that is a large share of the cluster's load, say 30 percent of its bytes, makes every capacity and incident decision about that tenant. A tenant needing a stricter latency SLO or a different upgrade timing forces the whole cluster to its pace. And compliance may require physical separation for regulated data.

Shared or dedicated
SignalShared is fineDedicated cluster
Share of cluster loadBelow about 20 percentA large share, say 30 percent or more
Latency SLOPlatform standardMuch stricter than standard
Upgrade timingPlatform scheduleMust differ from everyone else
ComplianceLogical separation enoughPhysical separation required

Because every cluster is built from the same automation, policies and monitoring, a dedicated cluster is not a snowflake. It costs hardware and a little attention, not a new set of runbooks, which makes the decision about the criteria rather than about effort.

6Follow-up questions

Can a CreateTopicPolicy see how many partitions a namespace already has?

Not by itself, because it receives only the request. A policy could query the cluster, but that adds a dependency inside the controller path. It is cleaner to keep namespace budgets in the provisioning system and let the policy enforce per-topic rules.

What does a tenant see when it hits controller_mutation_rate?

Its create or delete request fails with a throttling error that tells it how long to wait, rather than being delayed silently. The admin client can retry after that time, so pipelines handle it gracefully while runaway scripts are stopped.

How do we stop teams from bypassing the pipeline with admin rights?

By not giving them admin rights. Only the pipeline's principal can create topics or alter configs, and broker policies apply even to it, so a bug in the pipeline cannot create a 5,000-partition topic either.

7Conclusion

In this answer, we designed tenancy in layers: namespaces by prefix with prefixed ACLs and topics created only by a pipeline, broker policies for topic creation and config changes, controller_mutation_rate against partition storms, namespace budgets for partitions and storage kept in the provisioning system with retention.bytes caps, and produce, consume and request quotas per principal. A tenant gets its own cluster when it is a large share of the load, needs different SLOs or upgrade timing, or must be physically separate.

What to say in the interviewAbout 80 seconds aloud

Open with

I would build it in layers. Each team gets a namespace, a prefix like team.domain.topic, with prefixed ACLs, so it can only touch its own topics, and topics are created only by a pipeline or operator from requests in Git, never with direct admin rights.

Then, if they want more

On the brokers I would add a CreateTopicPolicy and an AlterConfigPolicy as a backstop, rejecting too many partitions, replication factor below three, missing retention or forbidden configs like unclean leader election. controller_mutation_rate as a default quota limits how fast anyone creates or deletes partitions, which would have stopped the 5,000-partition mistake.

Kafka has no per-tenant partition or storage quota, so the provisioning system tracks partitions and retained bytes per namespace against a budget, and unpredictable topics must have retention.bytes as well as retention.ms.

For noisy neighbours, every principal gets produce, consume and request_percentage quotas sized from declared needs, with a conservative default, and applications must set distinct client ids so throttling is visible. Finally, a tenant gets its own cluster when it is a large share of the cluster's load, needs a different SLO or upgrade timing, or compliance requires physical separation.

Since every cluster comes from the same automation, that extra cluster is cheap to run.

About this answer

Last updated
13 November 2026
Checked
Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
Where the question comes from
Written by Scrivio for practice. It is not taken from an interview.
Official documentation
Apache Kafka documentation
Report an issue with this answer

Copy the line below and send it to the author with what you found. It carries the address of this page.

Issue with "Design the isolation model: namespaces, quotas, limits on partitions and topic configs...": https://scrivio-interview-library.netlify.app/spring-boot/kafka-operations/a23e969615/