Async/Sync and Transactions and Idempotency Flashcards
What is Idempotency?
It means that the result of an action or calculation will always yield the same result with the same input.
So retrieving a user from the database always gives the same user.
It is like the database word: Determernistic.
When is the term used?
Talking about database calls.
When dealing with payment systems - to not allow double charges.
To handle exceptions.
Used when operations span over multiple systems andin case something goes wrong, the transaction can pickit up from where it failed last time
Used to ensure that data from a data storage isconsistent with the real world - A person can only create one account with an email address for example
What is Idempotency in API’s?
For a service endpoint to be idempotent, it means that clients can make the same call repeatedly while producing the same result.
So making multiple identical requests has the same result asmaking one call.
Which REST verbs are always considered Idempotent?
GET, HEAD, OPTIONS, TRACE are defined as safe as they are not intended to alter data, just retrieve.
Which verbs might produce different responses while producing the same result on the server?
PUT and DELETE.
successful DELETE will result in a 200 or 204
Consequent DELETE calls of the same resource will result in a 404 - unless the server is configured to mark a resource as soft deleted
Regardless of the response code, the server is still keptin a idempotent state
What are the benefits of idempotent calls and API’s?
It is safe to keep retrying requests.
Minimizes data inconsistencies
multiple identical requests from the same client do not result in a different final state
Minimises state
What does ACID stand for in Database context?
atomicity, consistency, isolation, durability.
These are the main characteristics of any transaction
What Is atomicity?
Atomicity stands for all or nothing
Either all instructions are successfully executed or nothing at all
Helpful when hardware fails, Connection times out, some other extraordinary event occurs. Limit what you are doing. creating a user should create a user only.
What is consistency?
A database should be consistent with the real world. If a user has 0 money in the bank it should indicate that. Otherwise the database is inconsistent.
what is Isolation?
Transactions are isolated from each other.
Isolation is needed for consistency
what is durability
Describes the storage as being trustworthy
A successful transaction is said to be committed
Changes made by a committed transaction must be durable or able to be persistent
Storage must be able to survive hardware failure
For async/sync programming go to gateways deck
For async/sync programming go to gateways deck
The subjects was in that slide so I put it there.
What is AirBnB’s “Orpheus” solution in regards to payment requests?
Its a system which actually saves the requests in a database so they can retry it if it fails rather than the user having to send the request again.