How can you ensure that your data is stored consistently
and reliably across a distributed system? My name is Whitney Lee and I'm a Cloud
Developer here at IBM. etcd is an open source key value data
store used to manage and store data that help
keep distributed systems running. etcd is most well known for being one of
the core components of Kubernetes, where it stores and manages Kubernetes
state data, configuration data, and metadata. etcd can be relied upon
to be a single source of truth at any given point in time.
Today I'm going to go over some of the features of etcd that allow it to be so
effective in this way.
etcd is fully replicated.
This means that every node in an etcd cluster
has access to the full data store. etcd is also reliably consistent.
Every data read in an etcd cluster is going to return the most recent data
right. Let's talk about how this works. etcd
is built on top of the Raft algorithm that is used for distributed consensus.
So, let's make a very simple etcd cluster of only four nodes. An etcd cluster
always has a leader and then the other nodes in the cluster
are followers. It's a key value data store, so in this
case at key one we have the value of seven.
Let's say a web application comes in
and lets the leader node know at key one we want to store the value of 17 instead
of 7. The leader node does not change its own
local data store, instead it forwards that request to each
of the followers. When a follower changes its local data
store it returns that to the leader, so the
leader knows. When our leader node can see that the
majority of the nodes have been updated to the most current
data that's when the leader will update its own current data store
and return a successful write to the client.
Now client doesn't actually have to concern itself
about which node in the cluster is the leader. The client can make
read and write requests to any node in the cluster.
So, let's say, this all happens over a matter of milliseconds,
but let's say that the client makes a read request to the node that hasn't
updated yet and says what's the value at key one?
Well this follower node knows it's a follower node and knows it's not
authorized to answer the client directly. So what it's going to do is forward that
request into the leader node which will then respond the cluster's
current value at key 1 is 17. And so it will get a response of 17 to
the client. And that's how etcd is replicated.
So every every node in the cluster has access to the full data store
and it's consistent every data read is going to return
the most recent data right. etcd is also highly available.
This means that there's no single point of failure in the etcd cluster.
It can tolerate gracefully tolerate network partitions and hardware failure
too. So, let's say that our leader node goes
down. The followers can declare themselves a
candidate, they'll hold an election where each one
votes based on availability and a new node will be elected the
leader. That leader will go on to manage the
replication for the cluster and the data is unaffected.
etcd is also fast.
etcd is benchmarked at 10,000 writes per second.
With that said, etcd does persist data to disk.
So, etcd's performance is tied to your storage disk speed.
etcd is secure. etcd uses transport layer security with
optional SSL client certificate authentication.
etcd stores vital and highly sensitive configuration data,
so it's important to keep it protected. Finally etcd is simple to use.
A web application can read and write data to etcd uses a
simple http JSON tools.
So the other thing to talk about in etcd that's important
is the watch function. Kubernetes leverages this.
So, as i talked about at the beginning, etcd stores Kubernetes configuration data
and its state data.
So, etcd can use this watch function to compare these to each other. If they
ever go out of sync, etcd will let the Kubernetes
API know and the kubernetes API will reconfigure
the cluster accordingly.
etcd can be used to store your data reliably and consistently across your
distributed system. Thank you. if you have questions please
drop us a line below. If you want to see more videos like this
in the future, please like and subscribe. And don't forget you can
grow your skills and earn a badge with IBM CloudLabs,
which are free browser-based, interactive Kubernetes labs.