Instructor: Let's talk about Amazon ElastiCache.
So the same way you get RDS
to have managed Relational Databases,
ElastiCache is going to help you get managed Redis
or Memcached which are cache technologies.
So what are caches?
Well they are in-memory databases
with really high performance
and low latency and what the cache will help you with
is to help reduce a load off of databases
for read intensive workloads.
The idea that the common queries are going to be cache
and therefore the database will not be queried every time,
just your cache can be used every time
to retrieve the results of these queries.
What this also helps you do is makes your application
stateless by putting the state of your application
into Amazon ElastiCache.
And because we have the same benefits of RDS,
AWS will take the same maintenance
of the operating system, the patching, the optimizations,
the setup, configuration, monitoring,
failure recovery and backups.
Now if you use Amazon ElastiCache,
just so you know that it will require you
to do some heavy application code changes
for your application.
This is not something you just enable
and off you go, you have a cache.
You need to change your application to query the cache
before or after querying the database
and we'll see the strategies in a minute.
So now let's talk about the architecture
for using ElastiCache.
And there could be many but I'm just giving you an example.
So let's say we have an ElastiCache, an RDI database
and your application.
The application will query ElastiCache.
To see if the query hours are being made
and if it has already been made
and it is stored in the ElastiCache
then it's called a cache hit
and then it just gets the answers straight
from the ElastiCache
and we are saving a trip to the database to do the query.
Now in case of a cache miss, then we need to fetch
the data from the database.
We're going to read it from the database
and then for other application
or other instances where the same query will be made,
we can write the data back into the cache
so that the same query next time will result in a cache hit.
The idea that it will help to relieve load
from your RDS database
and because you're storing data in the cache,
there must be a cache invalidation strategy
to make sure that only the most current data
is used in there.
And this is the whole difficulty
around using caching technologies.
Another architecture is around storing the user session
to make your application stateless.
So the idea is that your user will do a login
into any account of your applications
and then the application will write the session data
into Amazon ElastiCache.
Now if your user is redirected to another instance
of your application,
then your application can retrieve this session cache,
the session directly from the Amazon ElastiCache
and therefore your user still logs in and he doesn't need
to log in one more time.
And so the idea is that now you made
your application stateless by writing the session data
of your user into Amazon ElastiCache.
Now something that can come up in the exam
is for you to understand the difference
between Redis and Memcached at a high level.
So Redis is a technology that allows you
to do multi AZ with Auto-Failover
and the Read Replicas are used to scale the reads
and also have high availability.
So this looks a little bit like RDS.
There is also Data Durability thanks to persistence
and you have backup and restore features.
So this looks a lot like RDS
whereas Memcached is using multi-node
for partitioning of data so it's called sharding.
There is no high availability.
There's no replication happening.
It's not a persistent cache.
There is no backup and restore
and this is a multi-threaded architecture
so we have multiple instances of together working
in cache with some sharding.
So the idea here that you need to remember
is that Redis really is here for high availability, backup,
Read Replicas, this kind of stuff
whereas Memcached is a pure case of distributed
where you can't afford to lose your data,
there's no high availability
and there's no backup and restore.
So these are the main differences that you are going to have
between the two technologies.
So that's it.
I hope you liked it
and I will see you in the next lecture.