- Now let's review an introduction to Amazon ElastiCache.
So with Amazon ElastiCache, we gain access
to a fully-managed, in-memory cache.
Now, with in-memory caching,
a classic example of this type of use case will be,
let's say that you had a relational database,
where certain queries were running slow.
And by slow, I mean maybe, up herds of one second.
And even though you may have indexed them by the book
and you're querying them by the book,
there's nothing more that you can do,
and I've seen this plenty of times
where just the nature of the data means that
the query is running slow.
And so, the idea there is that
you take the result set from the database,
and you store that result set in memory.
And then when you have a fleet,
let's say you have a fleet of web servers.
Maybe dozens or hundreds of web servers,
you don't want each one of them
storing those things in memory,
you want the same result set available to all of them.
And so you store that result set
in memory some place central,
like in memory caching servers,
specifically designed for in-memory cache.
And so, very much like RDS, ElastiCache gives us
that fully managed platform for
running that in-memory cache.
And so, very much like RDS, we are off-loading
the operational burdens of the operating system,
and the cache engine to the ElastiCache service,
and so, MAWS then becomes responsible
for doing patches to the operating system
as well as performing updates to the actual engine.
And with minor updates,
those can be performed automatically,
most of the time, those can be done in place
during a maintenance window.
ElastiCache also supports clustering,
so that you can add numerous nodes to an existing cluster
in order to gain access to larger sets of memory,
larger than any one server can actually handle.
In the case of ElastiCache,
we can gain a terabyte's worth of in-memory storage.
And now with ElastiCache, we do get
a couple of different options, of software.
We have the ability to run Redis or Memcached.
With Redis, Redis is more of an in-memory database.
Because we gain access to multiple data types,
like hashes, sets, sorted sets,
we can also do atomic operations.
So we can do in-place updates and increments and decrements,
we can do in-memory sorting in a number of
different operations that make Redis
a really really powerful in-memory cache.
Well, in in-memory database, it's more than just a cache.
In Redis, it's also backed to disk.
Every so often, and of course this is configurable
but every so often, the contents of memory
can be written to this, so that if there were
and some type of an issue or an error
with that underlying host,
then you could recover that by either
replacing the host or rebooting it,
and allowing memory to be re-populated from disk.
Redis also, because it is backed to disk
and also gives us the ability
to automate the backups of that disk,
and like I mentioned before,
automatically patching the operating system.
Now we also have Memcached.
Memcached is very popular, it's very performant,
but it is more of a simple in-memory cache rather than,
it doesn't have any kind of database functionality
like Redis does, it's a simple key/value store.
Key equals value, that's all you get.
You don't gain access to datatypes like hashes or sets
or anything beyond simple key equals value.
And of course, Memcached is not backed to disk.
So if a node were to fail, anything in its memory
would be completely gone.
There's no way to recover that from Memcached.
But we still get automated patching of the operating system
and automated minor updates to the engine itself.
So again, keep that in mind that if you have scenarios
in which you have certain types of data,
and again, it could be a result set from
a relational database query, it could be rendered HTML,
maybe there are pages within your web application
that take longer to render,
and you simply want whatever it is,
whatever that data is, you can take that
and store it in memory in order to make that
or in order to deliver that
to your in-used or much faster
than waiting on the database to run the query
or waiting on your web server to render that HTML.
Now when the case of something like Redis,
where you have in-memory sorting,
where you have atomic operations,
there is also the ability to instead of relying
on a relational database or no sequel data store,
where everything is going to disc directly,
the fact that with something like Redis,
the fact is everything is happening directly in memory,
means that you could potentially see microsecond latency.
So, with something like Redis,
even though you might not be cashing result set,
you could simply be storing a data set in memory
so that the functionality is much much faster
than it would be with other data stores.
So keep in mind, Amazon ElastiCache
for doing things in memory.