简体   繁体   English

如何限制 docker 容器内的 ArangoDB RAM 使用?

[英]How to limit ArangoDB RAM usage inside of a docker container?

We use ArangoDB 3.3.14 (Community Edition) with MMFiles storage engine for a relatively large data set (a bit over 30 GB when you back it up).我们将 ArangoDB 3.3.14(社区版)与 MMFiles 存储引擎一起用于相对较大的数据集(备份时超过 30 GB)。 We run it inside of a docker container using ECS.我们使用 ECS 在 docker 容器内运行它。 Our host VM has 64 GB of RAM and we have dedicated 55 GBs exclusively for ArangoDB container (we set a hard limit for that container to 55 GBs).我们的主机 VM 有 64 GB 的 RAM,我们有 55 GB 专用于 ArangoDB 容器(我们将该容器的硬限制设置为 55 GB)。

When ArangoDB is just started and have all the collections loaded into the RAM it would take about 45 GBs, so we have about 10 GBs of free RAM to be used for queries, etc.当 ArangoDB 刚刚启动并将所有集合加载到 RAM 中时,大约需要 45 GB,因此我们有大约 10 GB 的空闲 RAM 可用于查询等。

The problem is that after some period of time (depending on usage) ArangoDB eats all the 55 GB of RAM and does not stop there.问题是一段时间后(取决于使用情况)ArangoDB 吃掉了所有 55 GB 的 RAM 并且并没有停在那里。 It continues to consume the RAM over the set hard limit and at some point, docker kills the container with exit code 137 and the status reason OutOfMemoryError: Container killed due to memory usage.它继续消耗超过设置的硬限制的 RAM,并且在某些时候,docker 使用退出代码 137 和状态原因杀死容器,OutOfMemoryError:由于内存使用而导致容器被杀死。

The restart causes a lot of problems for us because we need to wait until all the collections and graphs are loaded back into the RAM again.重启给我们带来了很多问题,因为我们需要等到所有集合和图形再次加载回 RAM 中。 It takes about 1-1.5 hours for our data set and you can not use ArangoDB while it is "restarting".我们的数据集大约需要 1-1.5 小时,并且您无法在“重新启动”时使用 ArangoDB。

My question is how can I limit ArangoDB RAM usage, let's say to 54 GBs, so it never reaches a hard memory limit set for a docker container?我的问题是如何限制 ArangoDB RAM 的使用,比如 54 GB,所以它永远不会达到为 docker 容器设置的硬内存限制?

In 3.3.20, ArangoDB introduces the parameter {{total-write-buffer-size}} which limits the write buffer.在 3.3.20 中,ArangoDB 引入了限制写入缓冲区的参数 {{total-write-buffer-size}}。 You can try adding this to your configuration file:您可以尝试将其添加到您的配置文件中:

[rocksdb]
block-cache-size = <value in bytes>  # 30% RAM
total-write-buffer-size = <value in bytes>  # 30% RAM
enforce-block-cache-size-limit = true

[cache]
size = <value in bytes>  # 20% RAM

or you can pass parameter to the command line:或者您可以将参数传递给命令行:

arangod --cache.size <value in bytes>  # 20% RAM \
    --rocksdb.block-cache-size <value in bytes>  # 30% RAM \
    --rocksdb.total-write-buffer-size <value in bytes>  # 30% RAM \
    --rocksdb.enforce-block-cache-size-limit true 

You can also tune how much memory assign per single component as per your usage.您还可以根据您的使用情况调整每个组件分配的内存量。 But you have to upgrade at least to 3.3.20.但是你至少要升级到 3.3.20。

yes, right, those specific parameters are for RocksDB (apart --cache.size).是的,对,这些特定参数是针对 RocksDB 的(除了 --cache.size)。 Probably in your case is better to move to ROcksDB, which has several advantages:可能在你的情况下最好转向 ROcksDB,它有几个优点:

  • document-level locks文档级锁
  • support for large data-sets支持大数据集
  • persistent indexes持久索引

And you can limit the memory consumption as well (starting from 3.3.20 on Linux).您还可以限制内存消耗(从 Linux 上的 3.3.20 开始)。 With MMFILES both collections and indexes have to fit in memory.使用 MMFILES,集合和索引都必须适合内存。

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

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