在部署gitlab后发现gitlab启动了非常多的bundle。

百度了一下原来是我的服务器cpu核心数太多了,gitlab建议如果您这台机器只使用与gitlab的话unicorn['worker_processes'] 这个默认是cpu核心数加一,所以开启的进程就会很多,我们只要把这个参数指定一下就好了,编辑配置文件gitlab.rb

去掉下面的注释

unicorn['worker_processes'] = 2

之后执行

docker exec -it gitlab gitlab-ctl reconfigure

docker exec -it gitlab gitlab-ctl restart

也可以重启容器。

但是发现没有效果,我的gitlab版本为13.10.5。后来又采用和很多方法包括限制docker容器的CPU和内存,限制docker容器的内存有效果但是无法减少bundle的数量,治标不治本。

最后仔细研究配置文件gitlab.rb,发现如下:

################################################################################

#unicorn['enable'] = false
# unicorn['worker_timeout'] = 60
###! Minimum worker_processes is 2 at this moment
###! See https://gitlab.com/gitlab-org/gitlab-foss/issues/18771
unicorn['worker_processes'] = 4

### Advanced settings
# unicorn['listen'] = 'localhost'
# unicorn['port'] = 8080
# unicorn['socket'] = '/var/opt/gitlab/gitlab-rails/sockets/gitlab.socket'
# unicorn['pidfile'] = '/opt/gitlab/var/unicorn/unicorn.pid'
# unicorn['tcp_nopush'] = true
# unicorn['backlog_socket'] = 1024

###! **Make sure somaxconn is equal or higher then backlog_socket**
# unicorn['somaxconn'] = 1024

###! **We do not recommend changing this setting**
# unicorn['log_directory'] = "/var/log/gitlab/unicorn"

### **Only change these settings if you understand well what they mean**
###! Docs: https://docs.gitlab.com/ee/administration/operations/unicorn.html#unicorn-worker-killer
###!       https://github.com/kzk/unicorn-worker-killer
unicorn['worker_memory_limit_min'] = "200 * 1 << 20"
unicorn['worker_memory_limit_max'] = "300 * 1 << 20"

# unicorn['exporter_enabled'] = false
# unicorn['exporter_address'] = "127.0.0.1"
# unicorn['exporter_port'] = 8083

################################################################################
## GitLab Puma
##! Tweak puma settings. You should only use Unicorn or Puma, not both.
##! Docs: https://docs.gitlab.com/omnibus/settings/puma.html
################################################################################

# puma['enable'] = true
# puma['ha'] = false
# puma['worker_timeout'] = 60
puma['worker_processes'] = 4

注意#unicorn['enable'] = false和下面的# puma['enable'] = true

原因找到了,这个版本的gitlab不是使用的unicorn而是puma,所以应该修改的配置是

puma['worker_processes'] = 4

修改后然后重启服务,问题解决

Logo

权威|前沿|技术|干货|国内首个API全生命周期开发者社区

更多推荐