Idempotence and Race Conditions
Revision as of 14:51, 19 June 2022 by Sven the Barbarian (talk | contribs) (Created page with "= Overview = When receiving messages in an distributed serverless system a single action might be called multiple times, eg: # If Lambda halts part way through execution it w...")
Overview
When receiving messages in an distributed serverless system a single action might be called multiple times, eg:
- If Lambda halts part way through execution it will retry
- SQS guarantees at least once delivery, meaning it might deliver a message multiple times
- Two requests from different sources might trigger the same function, but we only want to process one request
- I single source might send the same request multiple times, eg if a Lambda halts and is retried
Some of the solutions to idempotence can also be used to check for race conditions (eg storing timestamps).
Race conditions in a serverless system can include
- Two functions running at the same time making adjustments to the same data that overwrite each other
- Messages received out of the order they were sent