A topic in the Open Knowledge Graph — a free, open map of 15,495 topics and the order to learn them in.

Exactly-Once Delivery Semantics

Graduate Depth 105 in the knowledge graph ☐ I know this ☆ Set as goal
553prerequisites beneath it
See this on the map →
Introduction to Distributed SystemsAt-Least-Once Delivery Semantics+1 more→
semantics delivery correctness

Core Idea

Exactly-once semantics guarantee that a message is delivered and processed exactly one time, neither zero nor multiple. This is the strongest correctness guarantee but requires deduplication state and coordination. It is essential for operations with side effects (charging a payment, updating a counter) where duplicates would cause data corruption.

Explainer

From your distributed systems overview, you know that networks are unreliable — messages can be lost, duplicated, or delayed. This creates a fundamental delivery spectrum. At-most-once delivery sends a message and never retries; the message might be lost, but it will never be processed twice. At-least-once delivery retries until an acknowledgment is received; the message will definitely arrive, but it might be processed multiple times if the acknowledgment is lost and the sender retries. Exactly-once semantics aim for the best of both: the message is processed exactly one time, no matter what goes wrong with the network.

Here's why exactly-once is hard. Suppose a payment service sends a "charge $50" message to a billing system. The billing system processes the charge and sends back an acknowledgment, but the ack is lost in the network. The payment service, having received no confirmation, retries the message. Now the billing system receives "charge $50" again. Without additional machinery, it processes the charge a second time — the customer is billed $100 instead of $50. At-least-once delivery guarantees the charge gets through, but it doesn't prevent this duplication.

Exactly-once semantics are achieved not by preventing duplicate delivery (which is impossible in an unreliable network) but by ensuring that duplicate processing has no additional effect. The standard technique is deduplication: each message carries a unique identifier, and the receiver maintains a log of all message IDs it has already processed. When a duplicate arrives, the receiver recognizes the ID, skips processing, and re-sends the original response. This requires the receiver to maintain deduplication state — a potentially large table of processed message IDs — and to make the check-and-process operation atomic so that no window exists where a duplicate could slip through.

In practice, exactly-once semantics are often described more precisely as effectively-once: the message may be *delivered* more than once, but the *effect* occurs exactly once. Systems like Apache Kafka achieve this through a combination of producer-side sequence numbers, broker-side deduplication logs, and transactional writes that atomically commit message processing and offset advancement. The cost is real — deduplication state must be stored reliably, lookups add latency, and the state must eventually be garbage-collected. For operations without side effects (reading a value, computing a pure function), at-least-once delivery with idempotent processing is simpler and cheaper. Exactly-once semantics are worth the overhead specifically when operations have non-reversible side effects: financial transactions, counter increments, inventory adjustments, or any mutation where "do it twice" and "do it once" produce different outcomes.

Practice Questions 5 questions

Prerequisite Chain

Understanding Zero → The Number Zero → Counting to Five → Counting to 10 → Counting to 20 → Counting a Set of Objects Up to 20 → Cardinality: The Last Number Counted → Matching Numerals to Quantities → Subitizing Small Quantities → Combining Small Groups Within 5 → Number Bonds Within 5 → Number Bonds to 10 → Tens and Ones Place Value → Reading and Writing Three-Digit Numbers → Comparing Three-Digit Numbers → Comparing and Ordering Three-Digit Quantities → Comparing and Ordering Whole Numbers → Comparing Numbers 1 to 20 → Ordering Numbers to 20 → Number Line 0 to 20 → Addition Within 20 → Doubles and Near Doubles → Doubles Facts Within 10 → Near Doubles Facts Within 20 → Mental Math Strategies for Addition → Mental Math: Adding and Subtracting Tens → Addition Within 100 → Repeated Addition as Multiplication → Multiplication as Equal Groups → Multiplication: Arrays → Basic Multiplication Facts (0s, 1s, 2s, 5s, 10s) → Multiplication Facts Within 100 → Division as Equal Sharing → Division as Grouping (Measurement Division) → Division: Grouping (Repeated Subtraction) Model → Division: Fair Sharing Model → Division as Equal Sharing → Division as Grouping → Basic Division Facts → Division Facts Within 100 → Multiplication and Division Fact Families → Relationship Between Multiplication and Division → Division Facts as Inverse of Multiplication → Remainders and Quotients in Division → Division Word Problems → Multi-Step Word Problems → Solving Multi-Step Word Problems → Multiplication Word Problems → Division Word Problems → Introduction to Long Division → Factors and Multiples → Prime and Composite Numbers → Equivalent Fractions → Relating Fractions and Decimals → Decimal Place Value → Integers and the Number Line → Opposites and Additive Inverses → Absolute Value → Adding Integers → Subtracting Integers → Multiplying Integers → Introduction to Exponents → Order of Operations → Integer Order of Operations → Variable Expressions → The Distributive Property → Variables and Expressions Review → Introduction to Polynomials → Adding and Subtracting Polynomials → Multiplying Polynomials → Factorial → Permutations → Combinations → Counting Principles: Addition and Multiplication Rules → Introduction to Graph Theory → Propositional Logic Foundations → Logical Equivalences → Boolean Algebra → Boolean Type and Truth Values → Comparison Operators and Boolean Tests → Logical Operators and Boolean Algebra → Boolean Algebra and Fundamental Laws → Logic Gates Fundamentals → Implementing Boolean Functions with Gates → Karnaugh Map Simplification → Combinational Circuit Design → Flip-Flops and Latches → Finite State Machines (FSMs) → Deterministic Finite Automata (DFA) → Nondeterministic Finite Automata (NFA) → Regular Language Recognition Algorithms → DFA Properties and Minimization Algorithms → Regular Languages: Definition and Characterization → Context-Free Grammars (CFGs) → Context-Free Grammar Properties and Ambiguity → Parse Trees, Derivations, and Ambiguity in CFGs → Context-Free Grammars in Compiler Design → Abstract Syntax Trees (ASTs) → Symbol Tables and Scope Resolution → Semantic Analysis Phase → Scope and Binding Resolution → Scope, Shadowing, and Variable Lifetime → Parameter Passing: Value vs. Reference → Remote Procedure Calls (RPC) → At-Least-Once Delivery Semantics → Exactly-Once Delivery Semantics

Longest path: 106 steps · 553 total prerequisite topics

Prerequisites (3)

Leads To (0)

No topics depend on this one yet.