Storage layers

Let’s start with the storage layer. Understanding how it works helps to understand what is happening on the higher layers.

The storage layer provides:

✓ Concurrency and efficiency.

In other words, it is competitive access. That is, when we try to benefit from concurrency, the problem of concurrent access inevitably arises. We simultaneously go for one resource, which may not be recorded correctly, be beaten during the recording and, God knows what else, may work out at the same time.

✓ Reliability: disaster recovery.

The second problem is a sudden crash. When reliability is ensured, this means that we not only provided the maximum disaster recovery solution, but it is also important that we are able to quickly recover if something happens.

Competitive access

When I talk about integrity, foreign keys and so on, everyone somehow chuckles and says that they check all this at the code level. But as soon as you offer: “Let’s take an example on your salary! Your salary is being transferred, but it hasn’t arrived, ”- for some reason it becomes immediately clear. I do not know why, but immediately there is a sparkle in the eyes and interest in the topic of foreign keys, constraints.

Below is the code in a non-existent programming language.

account_a {
balance = 1000,
curr = ‘RUR’
}

send_money (account_a, account_b, 100);
send_money (account_a, account_c, 200);
account_a-> balance = ???

Let’s say we have a bank account with a balance of 1,000 rubles and there are 2 functions. How they are arranged inside is not important to us now, these functions are transferred from account a to other bank accounts of 100 and 200 rubles.

Attention, the question: how much money will end up on the balance of account a? Most likely, you will answer that 700.

Related Post

One thought on “Storage layers

Leave a Reply

Your email address will not be published. Required fields are marked *