Async/Sync and Transactions and Idempotency Flashcards

1
Q

What is Idempotency?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

When is the term used?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is Idempotency in API’s?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Which REST verbs are always considered Idempotent?

A

GET, HEAD, OPTIONS, TRACE are defined as safe as they are not intended to alter data, just retrieve.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Which verbs might produce different responses while producing the same result on the server?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What are the benefits of idempotent calls and API’s?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What does ACID stand for in Database context?

A

atomicity, consistency, isolation, durability.

These are the main characteristics of any transaction

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What Is atomicity?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is consistency?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

what is Isolation?

A

Transactions are isolated from each other.

Isolation is needed for consistency

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

what is durability

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

For async/sync programming go to gateways deck

A

For async/sync programming go to gateways deck

The subjects was in that slide so I put it there.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is AirBnB’s “Orpheus” solution in regards to payment requests?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly