Covers the read and the write path. What happens at the cluster level when a query is performed?
What I’m going to be showing you right now is an example
of what happens when we read or write data to the database.
And again, this is what’s happening under the hood.
So this is for you to understand how ScyllaDB works.
As you saw in the lab that. I showed you at the beginning,
when I interact with the database,
when I perform a query, I don’t have to worry about all this,
how ScyllaDB replicates data, how it knows
which node is responsible for the data and so on.
But it is important to understand how it works.
Mostly, so you can create the data model
for your application and understand
different trade-offs of how you can use the database.
So we have an example here.. We have a cluster
with five different nodes V, W, X, Y, and Z.
The replication factor
here is defined as
three. RF equals three.
And if you remember, that means that
each piece of data is going to be
replicated to three different nodes.
going to hold three copies of each piece of data and each
copy is going to be stored in a different node.
The consistency level is defined as quorum.
And that means that in order
for an operation or a query to be successful,
it would require that quorum, which in our case
is two out of three nodes, acknowledge that query.
If that happens, the query is going to be successful.
So let’s see the example.
What happens here?. We have a client.
That client sends a request to one of the nodes
in this example, Node V, and it wants to write a piece of data.
Let’s call that piece of data “one”
just to simplify things and not look at the entire row.
For this specific example node V
is designated the coordinator node.
It’s the coordinator node only for this specific request and
that means that it’s responsible for executing this query.
Now, if you remember what I showed you before, node
V would execute the consistent hash function
or the practitioner on the partition key of
the piece of data “one.” According to
the hash, it would
know which of the three nodes in
the cluster are responsible for this piece of data.
In this example, say these are the nodes W, X and Z
so the coordinator node would pass that information
along, the request write the piece of data “one”
to those three replica nodes.
And in this case, we can see
that the data is indeed added to those three nodes.
They write the data
and they send an acknowledgment back to our coordinator node.
They send the ack back.
Now, in this specific example,
the acknowledgment from nodes. W and Z indeed passed
back to the coordinator node,
but for some reason the acknowledgment from node
X did not pass to the coordinator node.
Say there is a network failure and
node X cannot pass the information along.
So what do you think would happen in this case?
If you can quickly write that in the chat window,
would knode. V return success to the client?
Or would the operation fail?
If you can quickly
write in the chat window what you think would happen.
So I see
a few people think it would be successful.
I see one person thinks it’s a failure.
Okay, so I see most of you think that it’s
going to be successful.
Some think it’s going to fail.
So the answer is that this specific operation
is going to be considered successful and the coordinator
node V passes an acknowledgment back to the client.
The operation was successful.
The reason for this being that we define the consistency level
to be quorum.
So two out of three nodes,
replica nodes need to acknowledge the request for it
to be successful, and that’s why the operation is successful.
And we return success to the client.
If in this same exact
example we would define the operation
to have a consistency level of All instead of quorum,
in that case, then the operation would be considered a failure.
Node V would not return an acknowledgment
and success to the client and the operation would fail.
so it really depends
on the replication factor and the consistency level
and that’s something to keep in mind
when you’re writing your application,
when you create your data model.
And I’m going to touch more on this
in the next talk “Core concepts in ScyllaDB”
the one in the essentials track right after this one.