Idempotency అంటే ఒక ఆపరేషన్ ఒకసారి లేదా చాలాసార్లు నిర్వహించినా ఒకే ఫలితాన్ని ఉత్పత్తి చేయడం. ఇది డిస్ట్రిబ్యూటెడ్ సిస్టమ్లలో అత్యంత ముఖ్యమైనది ఎందుకంటే retries మరియు duplicate messages అనివార్యమైనవి — idempotent operations ఈ వాటిని సురక్షితం చేస్తాయి.
Idempotency అంటే ఏమిటి
An operation is IDEMPOTENT if doing it MULTIPLE times has the SAME effect as doing it ONCE:
→ "set balance to 100" → idempotent (same result however many times)
→ "add 100 to balance" → NOT idempotent (each call changes it → wrong if duplicated!)
→ in HTTP: GET, PUT, DELETE are idempotent; POST typically is NOT
డిస్ట్రిబ్యూటెడ్ సిస్టమ్లలో ఇది ఎందుకు ముఖ్యమైనది
Retries and duplicates are INEVITABLE in distributed systems:
→ a request times out → the client RETRIES → but the original may have succeeded →
the operation runs TWICE (e.g. a payment charged twice! an order placed twice!)
→ message queues often guarantee AT-LEAST-ONCE delivery → duplicates happen
→ network issues, failures → operations get retried
→ if operations are IDEMPOTENT, duplicates/retries are SAFE (no harm from repeating)
→ this is essential for correctness and safe retries.
