Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Memcached on EC2

Am I right in thinking that until I am able to afford dedicated servers or have any spare servers, I could successfully run a small number of memcached servers through EC2?

With the annoucement of the new auto-scaling and load balancing by Amazon today, do you guys think this would be a viable option?

And what would be the basic technical steps you'd recommend me taking?

Thanks

Currently, I have one dedicated server and no memcached servers. I want to use the power of EC2 to setup a few instances and run such memcached servers. That's my current setup.

like image 639
James Avatar asked May 18 '09 19:05

James


People also ask

Is Memcached free?

Memcached is free and open-source software, licensed under the Revised BSD license.

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.


3 Answers

  • Load balancing has nothing to do with Memcached -- it uses a hash algorithm for connecting to servers
  • I highly recommend not using autoscaling with Memcached -- adding servers breaks the hashing algorithm and invalidates your cache. Data will go missing and you'll have to recache.
  • You'll want to check the latency from your servers to EC2 -- if it's more than 50ms, you'll be hurting your performance significantly. Well, I'd assume anyway.

You can pull multiple keys (see here for how) with one request to reduce the latency effect, but you'll still take the initial hit. And it also means you need to know all the keys your going to get before you make the call. Otherwise each request adds 50ms (or more) to the execution time of your script.

Consider the data your trying to cache. Is a 64mb slab large enough to help you? You can probably run it on your main servers.

like image 160
Gary Richardson Avatar answered Oct 21 '22 02:10

Gary Richardson


To really take advantage of memcached you need to have your memcache communicating with your code as quickly as possible. You may want to investigate how much latency you'd have between the EC2 servers and your own.

Ultimately, you might be better served upping the ram on your current box to something like 4 gigs (should run you about 50 bucks) and putting memcached on the main server. The documentation actually recommends that you install memcached on the same server that is serving out requests. Depending on the size of your application and what it does, a memcached instance with a gig or two may be way more than what you need.

Also, if you're not using a php object caching engine like APC or Eaccelerator, that will also help.

like image 20
jacobangel Avatar answered Oct 21 '22 02:10

jacobangel


Recently AWS has released a new web service - Amazon ElasticCache. This service is protocol-complaint with Memcached.

For more details refer to : http://aws.amazon.com/elasticache/

like image 45
RoYo Avatar answered Oct 21 '22 00:10

RoYo