git Gitlab CE 的高内存使用率
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/36122421/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
High memory usage for Gitlab CE
提问by delmalki
Look at this picture showing gitlab ce memory consumption.
I really dont need all of those workers, sidekiq or unicorn or all of those daemon. This is on IDLE. I mean, I installed this to manage 1 project, with like 4 people, I dont need all those daemon. Is there any way to reduce this ?
我真的不需要所有这些工人、sidekiq 或独角兽或所有这些守护进程。这是在空闲状态。我的意思是,我安装它是为了管理 1 个项目,大约有 4 个人,我不需要所有这些守护程序。有什么办法可以减少这种情况吗?
采纳答案by BrokenBinary
From your image it looks like Sidekiq and all its workers are using a total sum of 257mb of memory, which is normal. Remember that all the Sidekiq workers use the same memory pool, so they're using 257mb total, not 257mb each. As you've seen from your own answer, decreasing the number of Sidekiq workers will not drastically decrease the memory usage, but will cause background jobs to take longer because they have to wait around for a Sidekiq process to be available. I would leave this value at the default, but if you really want to decrease it then I wouldn't decrease it below 4 since you have 4 cores.
从您的图像来看,Sidekiq 及其所有工作人员总共使用了 257mb 的内存,这是正常的。请记住,所有 Sidekiq 工作进程都使用相同的内存池,因此他们总共使用了 257mb,而不是每个 257mb。正如您从自己的答案中看到的那样,减少 Sidekiq 工作线程的数量不会显着降低内存使用量,但会导致后台作业需要更长的时间,因为它们必须等待 Sidekiq 进程可用。我会将此值保留为默认值,但如果您真的想减少它,那么我不会将其减少到 4 以下,因为您有 4 个内核。
The Unicorn processes also share a memory pool, but each worker has 1 pool that is shared between its 2 processes. In your original image it looks like you have 5 workers, which is recommended for a 4 core system, and each is using about ~250mb of memory. You shouldn't notice any performance differences if you decreased the number of workers to 3.
Unicorn 进程也共享一个内存池,但每个 worker 有 1 个在其 2 个进程之间共享的池。在您的原始图像中,您似乎有 5 个工作人员,建议用于 4 核系统,每个工作人员使用大约 250 mb 的内存。如果您将工人数量减少到 3,您应该不会注意到任何性能差异。
Also, you might want to read this docon how to configure Unicorn. You definitely don't want the number of workers to be less than 2 because it causes issues when editing files from within the GitLab UI, as discussed here, and it also disables cloning over HTTPS according to this quote from the doc I linked:
此外,您可能想阅读有关如何配置 Unicorn 的文档。您绝对不希望工作人员的数量少于 2,因为它会导致在 GitLab UI 中编辑文件时出现问题,如此处所述,并且根据我链接的文档中的引用,它还禁用了通过 HTTPS 的克隆:
With one Unicorn worker only git over ssh access will work because the git over HTTP access requires two running workers (one worker to receive the user request and one worker for the authorization check).
使用一个 Unicorn worker 时,只有通过 ssh 访问的 git 才能工作,因为通过 HTTP 访问的 git 需要两个正在运行的 worker(一个 worker 接收用户请求,一个 worker 进行授权检查)。
Finally, recent versions of GitLab seem to allocate more memory to the postgresql database cache. I'd recommend configuring this property postgresql['shared_buffers']
in /etc/gitlab/gitlab.rb
to be 1/4 of your total free RAM. See René Link's answerbelow for more information on that.
最后,最近版本的 GitLab 似乎为 postgresql 数据库缓存分配了更多内存。我建议配置该物业postgresql['shared_buffers']
在/etc/gitlab/gitlab.rb
为你的总可用内存的1/4。有关更多信息,请参阅下面的René Link 的回答。
回答by René Link
I also had problems with gitlab's high memory consumption. So I ran the linux tool htop
.
我也遇到了 gitlab 的高内存消耗问题。所以我运行了 linux 工具htop
。
In my case I found out that the postgresl service used most of the memory.
就我而言,我发现 postgresl 服务使用了大部分内存。
With postgres service running14.5G of 16G were used
I stopped one gitlab service after the other and found out that when I stop postgresa lot of memory was freed.
我一个接一个地停止了 gitlab 服务,发现当我停止 postgres 时,很多内存被释放了。
You can try it
你可以试试看
gitlab-ctl stop postgresql
and start the service again with
并再次启动服务
gitlab-ctl start postgresql
Finally I came across the following configuration in /etc/gitlab/gitlab.rb
最后我遇到了以下配置 /etc/gitlab/gitlab.rb
##! **recommend value is 1/4 of total RAM, up to 14GB.**
# postgresql['shared_buffers'] = "256MB"
I just set the shared buffers to 256MB by removing the comment #
, because 256MB is sufficient for me.
我只是通过删除注释将共享缓冲区设置为 256MB #
,因为 256MB 对我来说已经足够了。
postgresql['shared_buffers'] = "256MB"
and executed gitlab-ctl reconfigure
. gitlab-ctl restarts the affected services and the memory consumption is now very moderate.
并执行gitlab-ctl reconfigure
。gitlab-ctl 重新启动受影响的服务,内存消耗现在非常适中。
Hopefully that helps someone else.
希望这能帮助别人。
回答by anon
Since GitLab 9.0, prometheus is enabled by default which I noticed was using a lot of memory over 1.5GB in my case, this can be disabled with prometheus_monitoring['enable'] = false
从 GitLab 9.0 开始,prometheus 默认启用,我注意到在我的情况下使用了超过 1.5GB 的大量内存,这可以禁用 prometheus_monitoring['enable'] = false
回答by delmalki
2 Options I found browsing the gitlab.rb
我发现浏览的 2 个选项 gitlab.rb
sidekiq['concurrency'] = 1 #25 is the default
unicorn['worker_processes'] = 1 #2 is the default
sidekiq['concurrency'] = 1 #25 is the default
unicorn['worker_processes'] = 1 #2 is the default
And this which needs understanding according to their warning:
根据他们的警告,这需要理解:
## Only change these settings if you understand well what they mean
## see https://about.gitlab.com/2015/06/05/how-gitlab-uses-unicorn-and- unicorn-worker-killer/
## and https://github.com/kzk/unicorn-worker-killer
# unicorn['worker_memory_limit_min'] = "300*(1024**2)"
# unicorn['worker_memory_limit_max'] = "350*(1024**2)"
This is after config modifications
这是配置修改后
Still WAY too much in my opinion.
在我看来还是太多了。
回答by u6770361
I have already fixed this case.
Which used the most memory is the unicorn!
My gitlab's version was "GitLab Community Edition 10.6.3".
And it was deploied on my server , it's cpu , INTEL Core i5 8400 for six cores.
So gitlab allocate 7 progresses for unicorn, each progress occuped 6% mem.
我已经修复了这个案例。
其中占用内存最多的是独角兽!
我的 gitlab 版本是“GitLab Community Edition 10.6.3”。
它部署在我的服务器上,它是 CPU,六核的 INTEL Core i5 8400。
所以gitlab为unicorn分配了7个进度,每个进度占用6%的内存。
Method:
vim /var/opt/gitlab/gitlab-rails/etc/unicorn.rb
How to edit the unicorn.rb
Edit and Save changes.
And execute "gitlab-ctl restart unicorn"
The htop behind unicorn.rb changes
方法:
vim /var/opt/gitlab/gitlab-rails/etc/unicorn.rb
如何编辑unicorn.rb
编辑并保存更改。并执行“gitlab-ctl restart unicorn”
unicorn.rb 后面的htop变化
回答by David Valdivieso
When I changed the /etc/gitlab/gitlab.rbas mentioned in other answers it did not worked for me.
当我像其他答案中提到的那样更改/etc/gitlab/gitlab.rb时,它对我不起作用。
This is what I did, I edited the following file:
这就是我所做的,我编辑了以下文件:
/var/opt/gitlab/gitlab-rails/etc/unicorn.rb
(Perhaps the path to the file in your machine is different)
/var/opt/gitlab/gitlab-rails/etc/unicorn.rb
(可能你机器里文件的路径不一样)
And changed worker_processes 9
to worker_processes 2
.
而改变worker_processes 9
对worker_processes 2
。