多个服务器和Memcached [英] Multiple Servers And Memcached

查看:109
本文介绍了多个服务器和Memcached的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果服务器1同时拥有我的数据库和Memcached以及www.website1.co.uk-该站点将正常运行.

If Server 1 has both my database and Memcached as well as www.website1.co.uk - the site will work fine.

但是,如果我有以下情况怎么办:

But What if I have the following scenario:

Server 1 - Database - Memcached - website1.co.uk 
Server 2 - website2.co.uk
Server 3 - website3.co.uk

我将如何设置它,以便website2和website3都可以连接,读取和写入服务器1上的memcached数据库(它们已经可以连接到服务器1并在不使用memcache的情况下读取和写入DB).

How would I set this up so website2 and website3 can all connect, read and write to the memcached db on Server 1 (they can already connect to server 1 and read and write to the DB without memcache).

我是否需要在服务器2和服务器3上安装Memcache才能连接?

Would I need to install Memcache on server 2 and server 3 just to be able to connect?

我以前从未使用过内存缓存,因此这是一种学习体验.

I've never used memcache before so it's a learning experience.

推荐答案

如果服务器1至3在同一网络上,则可以在每个应用程序服务器上安装内存缓存,而不必担心,因为内存缓存是为群集体系结构设计的.这只是意味着您可以根据需要作为多个实例运行,但是您的应用程序将其视为" 1个巨型内存缓存.

If Servers 1 to 3 are on the same network, you could install memcache on each of the application servers without worry because Memcache is designed for clustered architecture. This simply means that you can run as MANY instances as you want but your application 'sees' it as 1 giant memory cache.

要从memcached的项目Wiki 进行解释:

To paraphrase from the memcached's project wiki:

//in your configuration file: 

$MEMCACHE_SERVERS = array(
    "10.1.1.1", //web1
    "10.1.1.2", //web2
    "10.1.1.3", //web3
);


//at the 'bootstrapping' phase of your app somewhere:

$memcache = new Memcache();
foreach($MEMCACHE_SERVERS as $server){
    $memcache->addServer ( $server );
}

您的问题与扩展有关吗?如果是这样:

Is your question is related to scaling? If so:

我已经看到有人说您的缓存服务器位于数据库服务器本身上.恕我直言,这不是很有效,因为您希望为数据库服务器提供尽可能多的物理RAM(取决于网络应用在流量和负载方面的大小).

I've seen some people say to have your cache server on the DB server itself. IMHO, this is not very effective as you would want to give your DB server as much physical RAM as you can possibly afford (depending on how large your web app is in terms of traffic and load).

我会在每个应用程序服务器(服务器2和服务器3)上分配一部分内存以用于缓存.这样,如果要扩展,只需再提供一台应用程序服务器,签出源代码并将其添加到网络中.这样,在将应用程序服务器添加到服务器池时,内存缓存的大小将以线性方式(或多或少)增长.

I would allocate a portion of memory on each of the application servers (Server 2 and Server 3) for caching purposes. That way, if you want to scale out, you just provision one more application server, checkout your source code and add it to your network. This way the size of your memory cache would grow in a linear manner (more or less) as you add for application servers to your server pool.

以上所有假设显然所有服务器都在1个网络上.

All of the above assumes all the servers are on 1 network obviously.

这篇关于多个服务器和Memcached的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆