为服务/数据/缓存部署多个实例的好处 [英] The benefits of deploying multiple instances for serving/data/cache

查看:140
本文介绍了为服务/数据/缓存部署多个实例的好处的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尽管我编写代码很多,我没有太多经验的部署事情。我正在编写一个使用mongodb进行持久化的项目,redis用于元缓存,并为服务页面播放。我决定是否购买一台专用服务器,而不是从亚马逊/ linode购买多个中小型企业(一个为mongo,redis,play)。我想到了如下的权衡,我想知道是否有人可以添加到列表中或提供进一步的见解。我倾向于(b)从亚麻和亚马逊购买两套实例,所以如果其中一个发生中断,那么它将失败给另一个提供商。另外,如果有任何人有任何提示部署scala / maven群集或工具,请非常感谢。



A。将所有内容放在一个实例中

优点:


  1. 数据库和页面servlet(同一主机)之间的速度更快。

  2. 更便宜。

  3. 更少的安全点。

缺点


  1. 管理。 (在我看来)

  2. 更难升级单个模块。如果有安装问题,可能会导致整个系统出现问题。

B。将每个模块(mongo,redis,play)放在不同的实例中

优点:


  1. 分片更容易。

  2. 更容易为单个目的创建集群。 (即redis集群)

  3. 更容易在模块之间分配资源。

  4. 不太可能一切都会一次失败。

缺点:


  1. 每个连接和终点之间的带宽 - > $



解决方案

我只能评论技术方面(不是成本,可维护性等)。



没有提到专用实例是一个物理盒子,或者一个大型虚拟机。如果应用程序生成了对MongoDB或Redis的大量往返,那么差异就会相当大。



使用虚拟机,I / O的成本,OS调度和系统调用较高。这些元素往往是MongoDB或Redis等高效远程数据存储的性能成本的重要组成部分,虚拟化费用更高。



从系统点如果MongoDB数据库预计大于可用内存,我不会将MongoDB和Redis / Play放在同一个框上。 MongoDB将数据文件映射到内存中,并依赖于操作系统进行内存交换。它是为此设计的。其他过程不是。 MongoDB引发的交换将对Redis和Play响应时间造成灾难性后果,如果它们都在同一个框上。所以我至少将MongoDB与Redis / Play分开。



如果您打算使用Redis进行缓存,将其保留在与Play服务器相同的框上是有意义的。 Redis会使用内存,但是CPU数量很少。播放会使用CPU,但内存不会太多。所以看起来很适合此外,我不确定是否可以从Play,但如果您使用unix域套接字连接到Redis而不是TCP环回,您可以免费获得大约50%的吞吐量。


although I've much experience writing code. I don't really have much experience deploying things. I am writing a project that uses mongodb for persistence, redis for meta-caching, and play for serving pages. I am deciding whether to buy a dedicated server vs buying multiple small/medium instance from amazon/linode (one for each, mongo, redis, play). I have thought of the trade-offs as below, I wonder if anyone can add to the list or provide further insights. I am leaning toward (b) buying two sets of instances from linode and amazon, so if one of them have an outage it will fail over to the other provider. Also if anyone has any tips for deploying scala/maven cluster or tools to do so, much appreciated.

A. put everything in one instance
Pros:

  1. faster speed between database and page servlet (same host).
  2. cheaper.
  3. less end points to secure.

Cons:

  1. harder to manage. (in my opinion)
  2. harder to upgrade a single module. if there are installation issues, it might bring down the whole system.

B. put each module (mongo,redis,play) in different instances
Pros:

  1. sharding is easier.
  2. easier to create cluster for a single purpose. (i.e. cluster of redis)
  3. easier to allocate resources between module.
  4. less likely everything will fail at once.

Cons:

  1. bandwidth between modules -> $
  2. secure each connection and end point.

解决方案

I can only comment about the technical aspects (not cost, serviceability, etc ...)

It is not mentioned whether the dedicated instance is a physical box, or simply a large VM. If the application generates a lot of roundtrips to MongoDB or Redis, then the difference will be quite significant.

With a VM, the cost of I/Os, OS scheduling and system calls is higher. These elements tend to represent an important part in the performance cost of efficient remote data stores like MongoDB or Redis, and the virtualization toll is higher for them.

From a system point of view, I would not put MongoDB and Redis/Play on the same box if the MongoDB database is expected to be larger than the available memory. MongoDB maps data files in memory, and relies on the OS to perform memory swapping. It is designed for this. The other processes are not. Swapping induced by MongoDB will have catastrophic consequences on Redis and Play response time if they are all on the same box. So I would at least separate MongoDB from Redis/Play.

If you plan to use Redis for caching, it makes sense to keep it on the same box than the Play server. Redis will use memory, but low CPU. Play will use CPU, but not much memory. So it seems a good fit. Also, I'm not sure it is possible from Play, but if you use a unix domain socket to connect to Redis instead of the TCP loopback, you can achieve about 50% more throughput for free.

这篇关于为服务/数据/缓存部署多个实例的好处的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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