Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Redis: Amazon EC2 vs Elasticache

I want to host a Redis Server by myself. I compared EC2 to Elasticache. And I would like to know what the disadvantage of EC2 are.

An EC2 tiny instance costs as much as the ELasticache tiny instance but hast 400 mb of ram more. Why should use Elasticache and not setup an own Redis Server on the ec2 tiny isntance?

like image 748
nohayeye Avatar asked Jan 17 '14 00:01

nohayeye


People also ask

What is difference between ElastiCache and Redis?

ElastiCache supports Memcached and Redis. On the other hand, Redis is detailed as "An in-memory database that persists on disk". Redis is an open source, BSD licensed, advanced key-value store. It is often referred to as a data structure server since keys can contain strings, hashes, lists, sets and sorted sets.

Does ElastiCache run on EC2?

Your Amazon ElastiCache instances are designed to be accessed through an Amazon EC2 instance. If you launched your ElastiCache instance in an Amazon Virtual Private Cloud (Amazon VPC), you can access your ElastiCache instance from an Amazon EC2 instance in the same Amazon VPC.

Is ElastiCache based on Redis?

Built on open-source Redis and compatible with the Redis APIs, ElastiCache for Redis works with your Redis clients and uses the open Redis data format to store your data.

What are 2 types of Amazon ElastiCache?

Amazon ElastiCache supports two major open source in-memory caching engines: Memcached and Redis. ElastiCache users typically select between the two caching engines, depending on the design of the corresponding application.


1 Answers

tl;dr: Elasticache forces you to use a single instance of redis, which is sub-optimal.

The long version:

I realize this is an old post (2 years at the time of this writing) but I think it's important to note a point I don't see here.

On elasticache your redis deployment is managed by Amazon. This means you're stuck with however they choose to run your redis.

Redis uses a single thread of execution for reads/writes. This ensures consistency w/o locking. It's a major asset in terms of performance not to manage locks and latches. The unfortunate consequence, though, is that if your EC2 has more than 1 vCPU they will go unused. This is the case for all elasticache instances with more than one vCPU.

The default elasticache instance size is cache.r3.large, which has two cores.

Amazon's Elasticache setup menu with defaults populated.

In fact, there are a number of instance sizes with multiple vCPUs. Lots of opportunity for this issue to manifest.

enter image description here

It seems Amazon is already aware of this issue, but they seem a bit dismissive of it.

enter image description here

The part that makes this especially relevant to this question is that on your EC2 (since you're managing your own deployment) you're able to implement multi-tenancy. This means you have many instances of the redis process listening on different ports. By choosing which port to read/write to/from in the application based on a hash of the record's key you can leverage all your vCPUs.

As a side note; an redis elasticache deployment on a multi-core machine should always under perform compared to memcached elasticache deployment on the instance size. With multi-tenancy redis tends to be the winner.

Update:

Amazon now provides separate metrics for your redis instance CPU, EngineCPUUtilization. You no longer need to compute your CPU with the shoddy multiplication, but multi-tenancy is still not implemented.

like image 145
KeatsKelleher Avatar answered Sep 29 '22 08:09

KeatsKelleher