Quick revision
The short answer
All 30 services authenticate as web-apps, and with no client-id quotas they share one producer budget of 20 MB/s per broker; in the evening the other services use it up, so every member, checkout included, is throttled. The broker delays responses and mutes the connection, so checkout's sends wait about 700 ms while broker request metrics stay normal, which only the client throttle metrics and per-user broker throttle metrics reveal. The real fix is a principal per service with its own quota and a larger one for checkout; a user plus client-id quota for checkout is a stopgap, and throttle-time alerts make it visible next time.
What to remember
In this answer, we saw that quotas are tracked per entity, so 30 services sharing user web-apps share one 20 MB/s per-broker budget, and in the evening the heavy ones exhaust it and checkout is throttled with them. Throttling delays the response and mutes the connection outside the broker's measured handling time, so broker latency looks normal while client throttle metrics show 700 ms. The fix is a principal and quota per service, with a user plus client-id quota as a stopgap, and alerts on throttle time.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
All 30 services authenticate as web-apps, and with no client-id quotas they share one producer budget of 20 MB/s per broker; in the evening the other services use it up, so every member, checkout included, is throttled. The broker delays responses and mutes the connection, so checkout's sends wait about 700 ms while broker request metrics stay normal, which only the client throttle metrics and per-user broker throttle metrics reveal. The real fix is a principal per service with its own quota and a larger one for checkout; a user plus client-id quota for checkout is a stopgap, and throttle-time alerts make it visible next time.
Why this question is asked
This is a puzzling incident at first sight. Latency rises 60-fold every evening, but every broker dashboard is green. The clue is in the numbers: produce-throttle-time-avg of 700 ms explains almost all of the 900 ms p99. Interviewers ask this to see whether we know how quotas are accounted and why throttling hides from broker-side latency metrics. In this answer, we will recap how quota entities work, explain what happens every evening, see why broker metrics look healthy, fix the root cause, apply a stopgap, and add alerts.
1A Quick Recap: Quotas Are per Entity
A Kafka quota is tracked per quota entity, the user, the client id, or the pair, and every connection that maps to that entity draws from the same budget. The broker does not know or care that 30 different services sit behind one user. If they all authenticate as web-apps and the only quota is producer_byte_rate=20971520 on user web-apps, then on each broker all their produce traffic together may not exceed 20 MB/s.
That budget is per broker, because each broker enforces quotas on its own. So the shared limit is not a cluster-wide 20 MB/s, but on any single broker the 30 services compete for the same 20 MB/s.
2What Happens Every Evening
During the day the 30 services together stay under 20 MB/s per broker, so nobody is throttled and checkout's p99 is 15 ms. In the evening, traffic peaks: perhaps a recommendations service and a click-tracking service send much more. Together they reach the budget, and from then on the broker throttles every request that comes in under user web-apps, whichever service sent it. Checkout sends little, but its requests are counted against the same exhausted budget and get the same delay.
So checkout is not the cause; it is a victim of sharing. The quota did its job of protecting the cluster, but it protected it from the wrong unit, because the unit is a group of unrelated services.
- p99 send latency 15 ms -> 900 msevery evening
- Broker request latency high?YesLook at broker saturationNoLook at the client
- produce-throttle-time-avg high?YesQuota throttlingNoNetwork or batching
- Which entity is throttled?user web-apps, 20 MB/s per broker
- Who shares that entity?30 services, one budget
5 steps in order. Play them, or step through them one at a time.
3Why Broker Latency Metrics Look Healthy
Broker request metrics such as TotalTimeMs for Produce measure how long the broker took to handle the request. With throttling, the broker handles the request quickly, then delays the response and mutes the connection. The waiting happens outside the measured handling time, so the request latency graphs stay flat while the client waits.
The evidence is on both sides if we know where to look. The producer reports its throttle time, and the broker keeps quota metrics per entity, under the Produce quota group, with the byte rate and throttle time for each user and client id.
Notice how clear the picture becomes. The two heavy services use almost the whole 20 MB/s, and checkout, sending a fraction of that, gets throttled for about 700 ms. The exact metric names vary a little between versions, so check your version, but the per-user and per-client quota metrics have existed for a long time.
4The Real Fix: One Principal per Service
The root cause is shared identity. Each service should authenticate as its own principal, such as User:checkout and User:clicks, with a quota sized from its declared needs. Checkout then gets its own budget, for example 10 MB/s per broker, far above its real use, and no other service can consume it. The heavy services get budgets that match their actual peaks, and if they exceed them, only they slow down.
This also fixes everything else that shared identity breaks: ACLs can be narrowed per service, audit logs say which service did what, and capacity reports can attribute traffic correctly. It takes a credential per service and a rollout, so it is the change to plan, not the one to make at 19:00 tonight.
5A Stopgap: a User and Client-Id Quota
While identities are split, we can give checkout its own budget inside user web-apps. A quota on the pair of user and client id is more specific than the user quota, so connections from web-apps with client id checkout use it instead of the shared budget.
There is a catch: this only works if checkout sets a stable client.id of checkout and no other service uses the same string. Client ids are not authenticated, so any service could claim checkout and use its budget. That is acceptable as a short-term measure inside one company, but it is why the real fix is separate principals.
6Making Throttling Visible
This incident lasted many evenings because nothing alerted on throttling. We add alerts on throttle time per user and client, from the broker's quota metrics, for example when average throttle time exceeds 100 ms for ten minutes, routed to the owning team and the platform team. Latency-sensitive services also alert on their own produce-throttle-time-max. Then throttling shows up as what it is, a budget problem, before it turns into a latency incident.
7Follow-up questions
Would raising the web-apps quota to 60 MB/s fix it?
It would hide it until the heavy services grow again, and it would remove the protection the quota gives other tenants. The latency-sensitive service would still share a budget with batch-like traffic, so the problem would return at the next peak.
Why did the p99 reach 900 ms when throttle time was 700 ms?
Throttle time adds to the normal send path: batching delay, network and broker handling, plus the queueing of records in the producer's buffer while the connection is muted. 700 ms of throttling plus the rest gives roughly the 900 ms p99 the service saw.
Could request_percentage be causing this instead?
It could in a similar way, since request quotas are also per entity. The producer metric would still show throttle time, and the broker's Request quota metrics for web-apps would show it, so we check both quota groups before deciding.
8Conclusion
In this answer, we saw that quotas are tracked per entity, so 30 services sharing user web-apps share one 20 MB/s per-broker budget, and in the evening the heavy ones exhaust it and checkout is throttled with them. Throttling delays the response and mutes the connection outside the broker's measured handling time, so broker latency looks normal while client throttle metrics show 700 ms. The fix is a principal and quota per service, with a user plus client-id quota as a stopgap, and alerts on throttle time.
Open with
Quotas are tracked per quota entity, and all 30 services authenticate as web-apps, so with only a user quota they share one budget of 20 MB/s on each broker.
Then, if they want more
In the evening the heavy services use it up, and from then on every request under web-apps is throttled, checkout included, even though checkout sends very little. Throttling does not show in broker latency metrics, because the broker handles the request normally, then delays the response with throttle_time_ms and mutes the connection; the wait happens outside the measured time.
The client's produce-throttle-time-avg of about 700 ms is the evidence, and on the broker the per-user and per-client quota metrics show the byte rate of each service and the throttle time. The real fix is identity: give each service its own principal and set quotas from its needs, with a comfortable separate budget for checkout.
That also improves ACLs, audit and cost attribution. As a stopgap tonight, I would add a user plus client-id quota, entity-type users web-apps with entity-type clients checkout, giving checkout its own budget. That only works if checkout sets a stable client id that nobody else uses, since client ids are not authenticated.
Finally, I would alert on throttle time per user and client so this shows up before it becomes a latency incident.
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 "The checkout service shares the SASL user web-apps with 30 other services, and that user...": https://scrivio-interview-library.netlify.app/spring-boot/kafka-operations/df43289ccb/