简体   繁体   English

Memcached on EC2

[英]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? 我是否正确地认为,在我能够负担得起专用服务器或拥有任何备用服务器之前,我可以通过EC2成功运行少量的memcached服务器?

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. 目前,我有一个专用服务器,没有memcached服务器。 I want to use the power of EC2 to setup a few instances and run such memcached servers. 我想使用EC2的强大功能来设置几个实例并运行这样的memcached服务器。 That's my current setup. 这是我目前的设置。

  • Load balancing has nothing to do with Memcached -- it uses a hash algorithm for connecting to servers 负载平衡与Memcached无关 - 它使用哈希算法连接到服务器
  • I highly recommend not using autoscaling with Memcached -- adding servers breaks the hashing algorithm and invalidates your cache. 我强烈建议不要对Memcached使用自动缩放 - 添加服务器会破坏散列算法并使缓存无效。 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. 您需要检查从服务器到EC2的延迟 - 如果超过50毫秒,您将大大损害您的性能。 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. 否则,每个请求会为脚本的执行时间增加50毫秒(或更多)。

Consider the data your trying to cache. 考虑您尝试缓存的数据。 Is a 64mb slab large enough to help you? 一块64mb的大板足够帮你吗? You can probably run it on your main servers. 您可以在主服务器上运行它。

To really take advantage of memcached you need to have your memcache communicating with your code as quickly as possible. 要真正利用memcached,您需要让memcache尽快与代码进行通信。 You may want to investigate how much latency you'd have between the EC2 servers and your own. 您可能想要调查EC2服务器与您自己的服务器之间的延迟时间。

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. 最终,你可能会更好地将当前盒子上的ram提升到类似4演出(应该运行大约50美元)并将memcached放在主服务器上。 The documentation actually recommends that you install memcached on the same server that is serving out requests. 该文档实际上建议您在提供请求的同一服务器上安装memcached。 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. 根据应用程序的大小及其作用,具有一两个演出的memcached实例可能比您需要的更多。

Also, if you're not using a php object caching engine like APC or Eaccelerator, that will also help. 此外,如果您没有使用像APC或Eaccelerator这样的php对象缓存引擎,那也会有所帮助。

Recently AWS has released a new web service - Amazon ElasticCache. 最近AWS发布了一项新的Web服务--Amazon ElasticCache。 This service is protocol-complaint with Memcached. 此服务是Memcached的协议投诉。

For more details refer to : http://aws.amazon.com/elasticache/ 有关更多详细信息,请访问: http//aws.amazon.com/elasticache/

More in general: If you want to use any type of caching mechanism, it makes sense to have your servers VERY CLOSE to your cache servers. 更一般地说:如果您想使用任何类型的缓存机制,那么让您的服务器非常接近您的缓存服务器是有意义的。 Example: Database servers and Memcached servers, they should be in the same colocation, or same AWS "Region". 示例:数据库服务器和Memcached服务器,它们应位于相同的主机托管中,或相同的AWS“区域”。 If you try to use a caching system, is because you want to improve performance. 如果您尝试使用缓存系统,那是因为您希望提高性能。 If you put the caching system away from your servers, you're basically wasting all the benefits. 如果您将缓存系统远离服务器,那么您基本上就是在浪费所有的好处。

Best, 最好,

How much free memory do you normally have on your current box? 你当前的盒子里通常有多少可用内存? Could you not just set up a memcached instance there? 你能不能在那里设置一个memcached实例? I'm thinking that it's possible the latency/overhead/etc. 我认为这可能是延迟/开销等。 from having remote caches is such that you'd negate any benefits, but perhaps that's not the case. 从拥有远程缓存可以否定任何好处,但也许情况并非如此。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM