简体   繁体   English

在AWS环境中使用Memcached,最佳做法?

[英]memcached in a aws environment, best practice?

We are about the implement memcached in our php application using memcache php client. 我们即将使用memcache php客户端在php应用程序中实现memcached。 We are hosted on a AWS environment currently using 7 front end servers to access just one database. 我们托管在当前使用7台前端服务器访问一个数据库的AWS环境中。 We want to share the cache between all servers, of course. 当然,我们希望在所有服务器之间共享缓存。 Should we install memcached in all the front end servers and just add them to the memcached pool (callind addserver(xx.xx.xxx.xx)) or we should have dedicated machines to be the "memcached servers"? 我们应该在所有前端服务器中安装memcached并将其添加到memcached池中(callind addserver(xx.xx.xxx.xx)),还是应该将专用计算机用作“ memcached服务器”?

I would go with an ElastiCache instance which runs a memcahced engine (if you want to stick to memcahced). 我将使用一个运行memcahced引擎的ElastiCache实例(如果您想坚持使用memcahced的话)。

We've used this setup in production and it's much easier to maintain than a number of separate installations. 我们已经在生产中使用了此设置,它比许多单独的安装要容易得多。 Plus, you don't have to deal with inconsistency issues. 另外,您不必处理不一致的问题。

You should go with ElastiCache cluster using Memcached engine with dedicated nodes/servers forming the cluster. 您应该使用带有Memcached引擎的ElastiCache群集, 群集具有专用的节点/服务器。
Note that in Memcached, the nodes are not aware about each other but the Memcached Client handles the data distribution and load balancing in the cluster. 请注意,在Memcached中,节点之间彼此不了解,但是Memcached客户端处理群集中的数据分发和负载平衡。 Therefore, your front end servers will inherently share the Memcached cluster without worrying about which node is currently holding data. 因此,您的前端服务器将固有地共享 Memcached群集,而不必担心当前哪个节点正在保存数据。

The important thing to do here is to leverage Auto-Discovery feature provided by ElastiCache in AWS deployment where your application does not need to manually connect to individual cache nodes; 此处要做的重要事情是在AWS部署中利用ElastiCache提供的自动发现功能,其中您的应用程序无需手动连接到单个缓存节点。 instead, your application connects to a configuration endpoint . 而是,您的应用程序连接到配置终结点 Application/front end servers don't need to be aware of the number of nodes in the cluster and any number of nodes can be added or removed depending upon throughput and load on the application. 应用程序/前端服务器不需要知道群集中的节点数,并且可以根据应用程序的吞吐量和负载来添加或删除任意数量的节点。
More details about Auto-Discovery feature can be found here . 可以在此处找到有关自动发现功能的更多详细信息。

It really helped us in our production deployment where we horizontally scaled our Memcached cluster from 2 to 16 nodes seamlessly without any application server restarts. 它确实对我们的生产部署有所帮助,在该部署中,无需重新启动任何应用程序服务器,即可将Memcached集群从2个节点无缝地水平扩展到16个节点。

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

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