简体   繁体   中英

memcached in a aws environment, best practice?

We are about the implement memcached in our php application using memcache php client. We are hosted on a AWS environment currently using 7 front end servers to access just one database. 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"?

I would go with an ElastiCache instance which runs a memcahced engine (if you want to stick to 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.
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. Therefore, your front end servers will inherently share the Memcached cluster without worrying about which node is currently holding data.

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; 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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