Discourse-docker 使用 Unicorn 时出现内存问题

使用最新版本 discourse-docker 运行 Docker,内存 2GB,3 个 unicorn 线程。
出现了大量如下日志错误。

I, [2019-12-17T22:44:47.722151 #19487]  INFO -- : listening on addr=0.0.0.0:3000 fd=13
I, [2019-12-17T22:44:53.036892 #19487]  INFO -- : master process ready
I, [2019-12-17T22:44:55.704154 #19587]  INFO -- : worker=0 ready
I, [2019-12-17T22:44:56.644984 #19594]  INFO -- : worker=1 ready
I, [2019-12-17T22:44:57.595814 #19601]  INFO -- : worker=2 ready
I, [2019-12-18T05:12:51.517167 #19487]  INFO -- : reaped #<Process::Status: pid 19587 exit 0> worker=0
I, [2019-12-18T05:12:52.533342 #19487]  INFO -- : reaped #<Process::Status: pid 19594 exit 0> worker=1
检测到工作进程 19563 已死亡,正在重启...
I, [2019-12-18T05:12:53.551518 #19487]  INFO -- : reaped #<Process::Status: pid 19601 exit 0> worker=2
I, [2019-12-18T05:12:59.062671 #11689]  INFO -- : worker=1 ready
I, [2019-12-18T05:12:59.063307 #11680]  INFO -- : worker=0 ready
I, [2019-12-18T05:12:59.360555 #11706]  INFO -- : worker=2 ready
WARNING: V8 isolate was forked, it can not be disposed and memory will not be reclaimed till the Ruby process exits.
WARNING: V8 isolate was forked, it can not be disposed and memory will not be reclaimed till the Ruby process exits.
WARNING: V8 isolate was forked, it can not be disposed and memory will not be reclaimed till the Ruby process exits.
WARNING: V8 isolate was forked, it can not be disposed and memory will not be reclaimed till the Ruby process exits.
WARNING: V8 isolate was forked, it can not be disposed and memory will not be reclaimed till the Ruby process exits.
WARNING: V8 isolate was forked, it can not be disposed and memory will not be reclaimed till the Ruby process exits.
WARNING: V8 isolate was forked, it can not be disposed and memory will not be reclaimed till the Ruby process exits.
WARNING: V8 isolate was forked, it can not be disposed and memory will not be reclaimed till the Ruby process exits.
D, [2019-12-18T05:13:23.583306 #19487] DEBUG -- : waiting 16.0s after suspend/hibernation
I, [2019-12-18T05:13:44.194692 #19487]  INFO -- : reaped #<Process::Status: pid 11680 exit 0> worker=0
I, [2019-12-18T05:13:44.194960 #19487]  INFO -- : reaped #<Process::Status: pid 11689 exit 0> worker=1
I, [2019-12-18T05:13:44.195054 #19487]  INFO -- : reaped #<Process::Status: pid 11706 exit 0> worker=2
I, [2019-12-18T05:13:44.195120 #19487]  INFO -- : master complete
I, [2019-12-18T05:13:45.760881 #11795]  INFO -- : Refreshing Gem list

有人遇到过同样的问题吗?

您是否运行了任何非官方插件?或者在服务器上运行了其他什么东西?2GB 应该绰绰有余了…

感谢您的回复。该服务器仅运行 Sidekiq 和 Discourse。

请运行以下命令:

cd /var/discourse
./discourse-doctor

并将 URL 分享给我们?

@Falco
非常感谢,以下是诊断结果:

DISCOURSE DOCTOR 2019 年 12 月 20 日 03:42:31 UTC
操作系统:Linux int-communityweb-01w.our-internal-domain 3.10.0-1062.7.1.el7.x86_64 #1 SMP 2019 年 12 月 2 日 17:33:29 UTC x86_64 x86_64 x86_64 GNU/Linux


YML=web_only.yml
找到 containers/web_only.yml

==================== YML 设置 ====================
DISCOURSE_HOSTNAME=int-communityweb-vip.our-internal-domain
SMTP_ADDRESS=our_smtp_server # (必填)
DEVELOPER_EMAILS=已隐藏
SMTP_PASSWORD=已隐藏  (可选)
SMTP_PORT=25 # (可选)
SMTP_USER_NAME=# (可选)
LETSENCRYPT_ACCOUNT_EMAIL=已隐藏

==================== Docker 信息 ====================
Docker 版本:Docker version 17.05.0-ce, build 89658be

Docker 进程(docker ps -a)

容器 ID        镜像                                                                                                             命令             创建时间             状态                    端口                名称
e6c7024d0d4b        artifacts.our-internal-domain:8080/image/community:99-2.0.20191013-2320-tests-passed-b6b05d3b48-2019-12-16_09-28   "/sbin/boot"        43 小时前        运行中 43 小时               0.0.0.0:80->80/tcp   web_only
703de08548b0        artifacts.our-internal-domain:8080/image/community:90-2.0.20190625-0946-tests-passed-ac7d68a-2019-08-30_09-36      "/sbin/boot"        4 周前         已退出 (5) 46 小时前                        web_only_bak


Discourse 容器 web_only 正在运行


==================== 插件 ====================
          - git clone https://github.com/discourse/docker_manager.git
          - git clone https://gitlab.our-internal-domain/community/community-sso-plugin.git
          - git clone https://gitlab.our-internal-domain/community/community-ads-plugin.git
          - git clone  --branch upgarde-newrelic-gem https://gitlab.our-internal-domain/community/community-newrelic-plugin.git

警告:
您似乎安装了非官方插件。
如果您遇到问题,应禁用这些插件并尝试重新构建。

官方列表请参考:https://github.com/discourse/discourse/blob/master/lib/plugin/metadata.rb

========================================
int-communityweb-vip.our-internal-domain 上的 Discourse 版本:Discourse 2.4.0.beta8
localhost 上的 Discourse 版本:Discourse 2.4.0.beta8


==================== 内存信息 ====================
操作系统:Linux
RAM (MB): 1882

              总计        已用        空闲      共享    缓冲/缓存   可用
Mem:           1838        1340          66           7         430         306
Swap:          3071         388        2683

==================== 磁盘空间检查 ====================
---------- 操作系统磁盘空间 ----------
文件系统             大小  已用  可用  使用率 挂载点
/dev/mapper/vg00-root   19G   15G  3.3G  82% /
/dev/mapper/vg00-root   19G   15G  3.3G  82% /var/lib/docker/overlay
/dev/mapper/vg00-root   19G   15G  3.3G  82% /

---------- 容器磁盘空间 ----------


==================== 磁盘信息 ====================

磁盘 /dev/sda:21.5 GB,21474836480 字节,41943040 扇区
单位 = 扇区,1 * 512 = 512 字节
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最优):512 字节 / 512 字节
磁盘标签类型:dos
磁盘标识符:0x0005c8ec

   设备 启动      起始         结束      块数   Id  系统
/dev/sda1   *        2048     1050623      524288   83  Linux
/dev/sda2         1050624    16777215     7863296   8e  Linux LVM
/dev/sdimage        16777216    41943039    12582912   8e  Linux LVM

磁盘 /dev/mapper/vg00-root:19.9 GB,19851640832 字节,38772736 扇区
单位 = 扇区,1 * 512 = 512 字节
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最优):512 字节 / 512 字节


磁盘 /dev/mapper/vg00-swap:1073 MB,1073741824 字节,2097152 扇区
单位 = 扇区,1 * 512 = 512 字节
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最优):512 字节 / 512 字节

==================== 磁盘信息结束 ====================

==================== 邮件测试 ====================
如需进行可靠的测试,请从 http://www.mail-tester.com/ 获取一个地址
邮件测试已跳过。

==================== 完成! ====================
  1. 这里的内核版本相当老旧,能否在更现代的系统中运行?

  2. 这里的 Docker 版本也相当老旧,能否更新到受支持的版本?

  3. 你正在运行一个 web_only 容器,其内存占用甚至比独立容器还要低。不过,你运行了许多自定义插件,这些插件可能会或可能不会占用过多内存。

  4. 检查你的操作系统交换倾向(swapiness),它可能设置得太低。

  5. 你的 Unicorn 进程被终止了。没有更多日志很难确定原因……你的自定义插件是否同步地向外部系统发起请求?也许只是超时了?

这里变量太多,使得问题远离了简单安装的场景,因此我建议先尽量减少这些变量。

@Falco 谢谢,我会为此增加更多内存。关于内核和 Docker 升级相关事宜,将与 SE 团队讨论并做出决定。圣诞快乐。:dizzy: