Exactly-Once Effects From an At-Least-Once Card Event Consumer

Last updated: November 29, 2026

Quick Overview

Implement the core of a Kafka consumer for card authorization events that may be redelivered and processed out of order, so that each event changes a balance exactly once and the committed offset per partition only advances past offsets that are fully processed.

Nubank
Software Engineering Fundamentals
Software Engineer
Nubank
November 29, 2026
Software Engineer
Technical Screen
Software Engineering Fundamentals
Medium

0

0

0 solved


Implement the core of a Kafka consumer for card authorization events that may be redelivered and processed out of order, so that each event changes a balance exactly once and the committed offset per partition only advances past offsets that are fully processed.

Nubank's services talk mostly through Kafka, and consumers are expected to be idempotent because redelivery after a rebalance or crash is normal. The interviewer checks that you understand at-least-once semantics, separate dedupe from offset tracking, and know which steps must be atomic.

What the Interviewer Expects
  • Explains why at-least-once delivery requires idempotent handlers
  • Dedupes by a business event id, not only by offset
  • Tracks a contiguous committed offset with a set of completed offsets above it
  • Identifies that the balance write, processed-id record and offset must commit atomically
  • Discusses retention of processed ids
Key Topics to Cover
Kafka semantics
idempotency
offset management
atomicity
event-driven microservices
How to Approach This
  1. Apply SOLID principles. Single Responsibility makes code testable, Open/Closed makes it extensible.
  2. Choose data structures based on access patterns, not familiarity.
  3. Prefer immutable data and message passing over shared mutable state for concurrency.
  4. Design APIs with RESTful conventions, versioning, meaningful errors, and pagination from day one.
Possible Follow-up Questions
  • What breaks if you commit the offset before applying the change?
  • The same event appears on a different partition after a producer retry. Does your design still work?
  • How long must you keep processed ids, and how do you expire them safely?
  • How would you handle a poison message that always fails?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice System Design Problems
Sample Answer
Requirements

Messages carry (partition, offset, event_id, account, amount). They can be redelivered, and with parallel workers they can complete out of order. Each event_id must move money once. The committed ...

High-Level Design

Two independent guards. Dedupe by event_id so producer retries that create new offsets are caught. Offset tracking keeps the lowest unfinished offset per partition, holding completed higher ...


Submit Your Answer
Markdown supported

Related Questions