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

Idempotent vs Non-Idempotent Operations

Distinguish between naturally idempotent operations (GET, PUT, DELETE) and non-idempotent ones (POST).

Idempotent vs Non-Idempotent Operations

What you'll learn: How to distinguish between operations that can be safely retried and those that can't based on their idempotency characteristics.

The Core Distinction

In distributed systems, some operations naturally produce the same result no matter how many times you execute them—these are idempotent. Others create new effects with each execution—these are non-idempotent.

Think of a light switch: flipping it to "ON" is idempotent—if it's already on, flipping it again changes nothing. But pushing a "dispense cash" button on an ATM is non-idempotent—each press should dispense money again.

HTTP Method Characteristics

Naturally Idempotent Operations

  • GET: Reading data doesn't change state. Requesting the same resource 100 times returns the same result (ignoring external changes).
  • PUT: Updating a resource to a specific state. Setting user.name = "Alice" produces the same outcome whether you do it once or ten times.
  • DELETE: Removing a resource. Deleting an already-deleted item leaves you in the same state: the item doesn't exist.

Non-Idempotent Operations

  • POST: Typically creates new resources or triggers actions. Posting "create order" three times might create three separate orders—each request has a new effect.

Why This Matters

When network failures occur and you need to retry operations (as we learned in previous lessons), idempotent operations can be safely retried without side effects. Non-idempotent operations require careful handling with techniques like idempotency keys (which we'll explore next).

Key Takeaway: Idempotent operations (GET, PUT, DELETE) produce the same result regardless of repetition, making them safe to retry. Non-idempotent operations (typically POST) create new effects each time and require special handling in distributed systems.