Glossary termConcept

Idempotence

Also known as: Idempotency

Property of an operation that produces the same result whether it is applied once or many times, important for safe retries and automation.

An operation is idempotent if performing it several times has the same effect as performing it once. Pressing an elevator call button is a familiar example: pressing it again does not summon a second elevator. In mathematics, taking an absolute value is idempotent, since applying it twice gives the same result as applying it once. In computing, setting a user's email address to a particular value is idempotent, whereas adding ten dollars to an account balance is not, because each repetition changes the outcome. The term was introduced by the American mathematician Benjamin Peirce in 1870.

Idempotence matters wherever operations might be repeated, which in distributed systems is almost everywhere. Networks drop responses, so a client often cannot tell whether a request succeeded and must retry it. In HTTP, the methods GET, PUT and DELETE are defined as idempotent while POST is not, which is why browsers warn before resubmitting a form. Payment services and other APIs commonly accept an idempotency key, a unique identifier sent with a request, so that a retried request is recognized and not processed twice, preventing duplicate charges.

The property is a core principle of infrastructure as code and configuration management. Tools such as Ansible and Terraform describe a desired state, such as a package being installed or a server existing, and running them again changes nothing once that state is reached, which makes automation safe to rerun after failures. Webhook handlers and message queue consumers are designed to be idempotent because many delivery systems guarantee at-least-once delivery, meaning duplicates can arrive. Designing for idempotence turns retries from a risk into a routine recovery mechanism.

Key points

  • An idempotent operation has the same effect whether it is performed once or many times.
  • In HTTP, GET, PUT and DELETE are idempotent methods, while POST is not.
  • Idempotency keys let APIs recognize retried requests and avoid duplicate actions such as double charges.
  • Infrastructure tools rely on idempotence so that configuration runs can be repeated without unintended changes.

Related entries

Glossary term

HTTP

ProgrammingCybersecurity

Stateless request-response protocol that web browsers, servers and other clients use to request and transfer resources such as web pages and data.

Glossary term

REST API

ProgrammingAI

Web interface that follows the REST architectural style, exposing resources at URLs that clients manipulate with stateless HTTP requests.

Glossary term

Webhook

ProgrammingAI

HTTP callback in which one system automatically sends data to another the moment a specific event occurs, instead of waiting to be asked.

Glossary term

Practice of defining and provisioning servers, networks and other infrastructure through machine-readable files rather than manual configuration.

Glossary term

Discipline and tooling for establishing and maintaining a known, consistent state for systems, software and their settings over time.

Technology

Ansible

DevOpsFOSS

Open-source, agentless automation tool that configures servers, deploys software and orchestrates IT tasks using YAML playbooks run over SSH.

Technology

Terraform

DevOps

Infrastructure-as-code tool from HashiCorp that provisions cloud and on-premises resources from declarative configuration files.

Glossary term

Pure Function

Programming

Function that always returns the same output for the same inputs and has no side effects, such as modifying outside state or performing I/O.