amazon-ec2memcachedamazon-web-servicescloudamazon-elasticache

How can an app on EC2 autodiscover ElastiCache instances?


Say I have a webapp running on some number of load-balanced EC2 servers, storing and retrieving metadata from SimpleDB with larger chunks of data stored on S3 (due to the whole 1 KB limitation of SimpleDB). Since S3 is pretty high latency and I don't want to be making a ton of requests over there anyway, I'll want a caching layer for the info... enter ElastiCache.

Ok so I provision an ElastiCache server with endpoint X so I hardcode X into my app on EC2 and it's running happily until I get a few hundred thousand new users and all of a sudden my cache server is woefully underpowered for the demand. Fortunately I can just start up a few new larger cache servers... but then I realize I've got endpoints X, Y, and Z and my app only knows to try X, so I still have a problem.

So right now I'm just trying to get my head wrapped around the various pieces to this puzzle, and I haven't gotten to the coding part yet, but won't this be an issue? I've read the documentation for ElastiCache and it mentions that it is a cache cluster, but then each server in the cluster seems to have its own endpoint. Is there a way for an app running on EC2 to know about all the cache servers that are running, and more to the point which one contains the data for a particular key? Is it possible to ask the cluster as a whole to store or retrieve a piece of information?


Solution

  • Today Aws announced cache discovery. Your problem is solved. https://aws.amazon.com/blogs/aws/amazon-elasticache-now-with-auto-discovery