Course contentsShow
← System Design
Lesson 998 of 1,91926. Idempotency and RetriesFree lesson

What is Idempotency?

Define idempotency: operations that produce the same result when executed multiple times with identical inputs.

What is Idempotency?

What you'll learn: You'll understand what idempotency means and why it's a critical property for building reliable distributed systems.

The Core Idea

Idempotency is a property of an operation where executing it multiple times with the same inputs produces the same result as executing it once. In other words, repeating an idempotent operation doesn't change the outcome beyond the initial application.

Think of it like a light switch labeled "ON." No matter how many times you flip it to the ON position, the light stays on—the end state is identical whether you flipped it once or a hundred times.

Why This Matters

In distributed systems, network failures, timeouts, and retries are inevitable. Without idempotency, retrying a failed operation could cause unintended side effects:

  • Charging a customer's credit card twice
  • Creating duplicate records in a database
  • Sending the same notification multiple times

Idempotent operations are retry-safe: you can safely retry them without worrying about corrupting data or creating inconsistent states.

Examples in Plain English

Idempotent operations:

  • Setting a value: SET temperature = 72°F (setting it again doesn't change anything)
  • Deleting a specific record: DELETE user WHERE id = 123 (already deleted? No problem)

Non-idempotent operations:

  • Incrementing a counter: ADD 1 to balance (repeating it adds more each time)
  • Creating a new record without checking: INSERT new order (creates duplicates)

Key Distinction

Idempotency focuses on the result, not the process. An idempotent operation might execute internal logic multiple times, but the observable outcome remains consistent.

Key Takeaway: Idempotency means an operation can be safely retried because multiple executions with identical inputs produce the same end result—a fundamental property for building resilient systems that gracefully handle network failures and retries.