Instructor: Now let's have a look at what we need to know
from a Memcached perspective regarding scaling.
So we have a Memcached Cluster and it has two cache nodes.
And as we can know, Memcached cluster can have up to one
between one and 40 nodes. Okay.
This is a soft limit.
That means that if you want to do horizontal scaling,
then you need to add and remove nodes from the cluster.
And then using auto-discovery
that I will show you in the next slide,
your app will be able to find these new notes.
So that means that if you want to do horizontal scaling,
well, you just add cache nodes to your cluster.
And you're good to go with the auto-discovery mechanism.
Now, in case of vertical scaling,
we can scale up and down to larger or smaller node types.
And the scale up process is essentially going to create
a new cluster with a new node type.
Then you're going to update your application
to use the new cluster's endpoints.
And then you're going to delete the old cluster.
This is something you have to do manually.
And then as you know,
Memcached does not have a backup system.
So that means that Memcached cluster or nodes
will start out without any data.
And that means your application has to
fill the data yourself. Okay.
So it's different than Redis that has a backup mechanism.
So if you ever look at the old Memcached cluster,
for example, it's running a smaller instance type,
we're going to have the application
connected to it right now,
but we're going to create a new Memcached cluster, okay,
with a larger cache type.
And as we know, this cluster will be empty.
So application side, we update the endpoints.
I mean that we stop being connected to the old cluster
and we started being connected to the new cluster
and our application, if it's well programmed,
will start populating data into this Memcached cluster.
Okay. Now from Memcached Auto Discovery, what it is?
Well, we have a cluster, say for example, with four nodes
and a client wants to connect to all of them.
So typically we need to have the client
reference each of these four nodes, okay,
using the DNS endpoints to connect to them.
But if we start adding new nodes over time,
how does the client get updated with all these nodes?
So there's auto-discovery
and the idea is that's all the cache nodes in the cluster
know about all the other nodes.
So that means that the client from a
con perspective will seamlessly connect to all of them.
So what that means is that
the clients will connect to the configuration endpoints,
will get back to the IP address of cache node one, okay.
Then it will connect directly into the Cache Node 1
and the Cache Node 1 will respond
with a metadata of the IP addresses
of all the nodes in the cluster
and the client can use that to connect to any nodes
to find the right data in your cluster.
Okay. Finally, some metrics to monitor,
which is very similar to Redis.
So we have Evictions,
which is the number of non-expired items
that the cache evicted to allow space for new writes
and so the solution is to use a new eviction policy
or to set up a larger node types
or to scale out by adding more nodes.
CPUUtilization, which is if it's too high,
well, you need to scale up to a larger node type
or to scale out by adding more nodes.
SwapUsage, same as before
and CurrConnection as well,
which has a number of connections,
between your application and Memcached.
So make sure that your application
does not have a bad behavior
to open too many connections.
And then FreeableMemory, which is the amount of free memory
on the host. Okay?
So hopefully that makes sense.
Hopefully you're good to go with Memcached now
and I will see you in the next lecture.