dongwei1263 2012-02-20 16:26
浏览 103
已采纳

多个服务器和Memcached

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

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

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条回答 默认 最新

  • douqiju2520 2012-02-21 05:30
    关注

    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.

    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:

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

    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.

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

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog