Scrivio Interview library
DesignAdvanced6 min read · updated 12 November 2026

Fifty teams create Kafka topics in different ways: some from application code with NewTopic beans, some by ticket to the platform team, some with scripts. Topics without owners, wrong retention and replication factor 1 keep causing incidents. How do you design topic administration for the organization?

We make topics declarative infrastructure: every topic is defined in Git, through a Terraform provider, Strimzi KafkaTopic resources or a self-service portal backed by the same definitions, reviewed and validated automatically against standards such as naming with domain and owner, replication factor 3 and min.insync.replicas 2, retention and partition limits. Applications lose create rights in production and auto creation is disabled, ownership and data classification are stored with each topic, unused topics are found and retired, and the self-service path is fast enough that nobody needs to work around it.

Why this question is asked

When fifty teams create topics in fifty ways, the cluster slowly fills with topics nobody owns, settings nobody chose and risks nobody sees until an incident. A topic with replication factor 1 loses data when one broker dies, and a topic with infinite retention fills disks. Interviewers ask this design question at senior levels because the answer is mostly about process and incentives, not about Kafka commands: rules that slow teams down get bypassed, so the design has to make the right way the easy way. In this answer, we will look at why the current situation produces incidents, then design the source of truth, the policies, the permissions, ownership and clean-up, and finally the self-service experience that holds it all together.

1Why Three Creation Paths Cause Incidents

Each current path loses information. A NewTopic bean in application code is created with whatever the developer typed, often copied from a local example with one replica. A ticket to the platform team captures intent in a free-text field that nobody can query later. A script run from a laptop leaves no record at all. None of the three records an owner, and nothing checks the settings against a standard, so the cluster's state is the only truth and it cannot explain itself.

So the design goal is simple to state: one source of truth for every topic, checked automatically, with an owner attached, and a path that is faster than the workarounds.

2Topics as Declarative Infrastructure

We describe each topic as data in a Git repository, in a format our tooling understands. On Kubernetes with Strimzi, that is a KafkaTopic custom resource that the topic operator applies to the cluster. Elsewhere, a Terraform provider for Kafka, or a managed service's own resources, plays the same role. A pull request adds or changes a topic, automated checks validate it, the owning team and the platform team review it, and a pipeline applies it.

YAML
apiVersion: kafka.strimzi.io/v1beta2 # check your Strimzi version
kind: KafkaTopic
metadata:
name: payments.card-authorised.v1
labels:
strimzi.io/cluster: prod-eu
owner: payments-team
data-class: confidential
spec:
partitions: 12
replicas: 3
config:
min.insync.replicas: 2
retention.ms: 604800000 # 7 days
cleanup.policy: delete
Step throughTopic administration stack
  1. Self-service portal or pull requestteams request topics in minutes
  2. Policy checks in CInaming, RF 3, min ISR 2, retention, partition limits
  3. Git repositorysingle source of truth, owner and data class per topic
  4. Operator or Terraform pipelineonly identity allowed to create topics
  5. Kafka clustersauto creation off, app principals have no create rights

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

Notice that ownership and data classification travel with the definition. Because the files are plain data, a validator can read every topic in the organisation, and the history of each change, with its reviewer, is in Git.

3Encoding the Standards as Policies

The standards must be checks, not a wiki page. A naming convention such as <domain>.<event>.<version> tells us at a glance which domain owns a topic, and the validator rejects names that do not match. Replication factor must be at least 3 and min.insync.replicas at least 2 for production, which, together with producers using acks=all, means one broker can fail without losing acknowledged writes. Retention needs an upper limit, say 30 days unless an exception is approved, and partition counts get a limit, for example 1 to 100, because each partition costs broker resources.

We enforce the same rules in two places. CI checks give fast feedback on the pull request, and a broker-side policy, Kafka's create topic policy plugin or the managed service's equivalent, rejects anything that reaches the cluster another way. Exceptions are possible, but they are explicit, recorded in the definition with a reason and an approver.

Standards and how they are enforced
StandardCheckWhy
Name domain.event.versionregex in CIowner and purpose visible in the name
Replication factor >= 3CI and broker policysurvive a broker loss
min.insync.replicas >= 2CIacks=all really means two copies
Retention <= 30 daysCI, exception needs approvalprotect disks and data limits
Partitions 1 to 100CIcontrol broker resource use
Owner and data classrequired labelssomeone to call, right access rules

4Removing the Back Doors

Policies only work if there is no other way in. In production we disable auto.create.topics.enable, so a typo in a consumer's topic name no longer creates a topic, and we remove Create permission from application principals with ACLs, so a NewTopic bean cannot create anything. Only the operator or pipeline identity may create topics. Applications keep NewTopic beans for local development and test containers, where they are convenient, and in production profiles spring.kafka.admin.auto-create is false, or the bean is harmless because it finds the topic already there.

5Ownership, Metadata and Clean-Up

Each topic records an owning team and a data classification, which drive alert routing and access rules: a confidential topic can require approval before another team gets Read access. Owners are also the people the platform asks when something looks wrong.

For clean-up, we collect activity data: bytes in per topic and consumer group offsets. A topic with no produce traffic and no consumer group activity for 30 days is flagged to its owner for review. Deletion is a pull request like any other change, with a waiting period, so a mistake can be caught before data is gone.

6Making the Right Way the Fast Way

The whole design fails if requesting a topic takes a week, because teams will find a workaround, such as reusing an existing topic for unrelated events. So self-service matters: a portal or a template pull request that fills in defaults, runs checks in seconds and lets a team create a compliant topic in, say, under 15 minutes without waiting for a platform engineer. We measure lead time from request to topic and the share of requests that need manual help, and treat a rising lead time as a platform bug.

7Follow-up questions

How would you clean up hundreds of unused topics safely?

First import every existing topic into the Git definitions as it is, so nothing is lost and we have an inventory. Then gather evidence for each one: produce rate, consumer groups with recent commits, and last write time. Topics with no activity for, say, 60 days go on a list sent to the owner we can find, or to the domain lead when there is none. After a notice period, we remove access first, by removing ACLs, so anything still using the topic fails loudly but the data remains, and only after another quiet period do we delete the topic through a pull request. Topics holding regulated data get an archive step before deletion.

Should applications ever create topics in production?

Usually not. Letting applications create topics brings back unchecked settings and missing owners. The exception is temporary topics owned by a framework, such as Kafka Streams internal topics, which get a narrowly scoped create permission on a name prefix.

8Conclusion

In this answer, we replaced three unrecorded creation paths with one declarative source of truth in Git, applied by an operator or Terraform. Standards for naming, replication factor 3, min.insync.replicas 2, retention and partition counts are checked in CI and by broker policy. Applications lose create rights and auto creation is off in production, while NewTopic beans remain for development. Every topic carries an owner and data class, unused topics are found and retired carefully, and a fast self-service path with a measured lead time keeps teams from working around the process.

What to say in the interviewAbout 80 seconds aloud

Open with

I would make topics declarative infrastructure with one source of truth. Every topic is a definition in Git, for example a Strimzi KafkaTopic resource or a Terraform resource, created through a pull request or a self-service portal that writes the same definition.

Then, if they want more

CI validates each definition against standards: a naming convention that includes the domain and version, replication factor at least 3 and min.insync.replicas 2 in production, a retention limit, partition limits, and required owner and data classification labels. A broker-side create policy enforces the same rules as a safety net.

Then I close the back doors: auto topic creation is disabled and application principals lose create rights through ACLs, so only the pipeline can create topics. Developers still use NewTopic beans locally and in tests.

The owner label drives alert routing and access approvals, and we track activity so topics with no producers or consumers for a month get flagged to their owner and retired through a careful process, removing access before deleting data.

The most important part is speed: if creating a topic takes days, teams work around it, so I would aim for a compliant topic in minutes and measure the lead time.

About this answer

Last updated
12 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.
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 "Fifty teams create Kafka topics in different ways: some from application code with...": https://scrivio-interview-library.netlify.app/spring-boot/kafka/8dbd17ffe6/