从 GitLab 13.0
开始,Puma
是默认的应用程序服务器
. 计划在 GitLab 14.0
中删除对 Unicorn 的支持.
Puma 具有多线程体系结构,与像 Unicorn 这样的多进程应用程序服务器相比,它使用的内存更少. 在 GitLab.com 上,我们发现内存消耗减少了 40%.
大多数 Rails 应用程序请求通常都包含一定比例的 I / O 等待时间. 在 I / O 等待时间内,MRI Ruby 将释放 GVL(全局 VM 锁定)到其他线程. 因此,多线程 Puma 仍然可以处理比单个进程更多的请求.
环境:
CentOS 7.9
GitLab 13.10.3
cat /opt/gitlab/embedded/service/gitlab-rails/VERSION # 查看版本
解决:
1.修改 puma.rb
配置
vim /var/opt/gitlab/gitlab-rails/etc/puma.rb
# Bind the server to "url". "tcp://", "unix://" and "ssl://" are the only
# accepted protocols.
bind 'unix:///var/opt/gitlab/gitlab-rails/sockets/gitlab.socket'
bind 'tcp://127.0.0.1:8092' ## 默认8080,修改为自己服务不冲突的端口,这里我改为8092
directory '/var/opt/gitlab/gitlab-rails/working'
workers 6
require_relative "/opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/cluster/lifecycle_events"
require_relative "/opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/cluster/puma_worker_killer_initializer"
on_restart do
2. 修改gitlab.rb
配置
vim /etc/gitlab/gitlab.rb
################################################################################
## 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'] = 2
# puma['min_threads'] = 4
# puma['max_threads'] = 4
### Advanced settings
# puma['listen'] = '127.0.0.1'
puma['port'] = 8092 # 默认8080,去掉注释修改为同 `puma.rb` 中配置的端口:8092
# puma['socket'] = '/var/opt/gitlab/gitlab-rails/sockets/gitlab.socket'
# puma['somaxconn'] = 1024
# puma['pidfile'] = '/opt/gitlab/var/puma/puma.pid'
# puma['state_path'] = '/opt/gitlab/var/puma/puma.state'
###! **We do not recommend changing this setting**
# puma['log_directory'] = "/var/log/gitlab/puma"
### **Only change these settings if you understand well what they mean**
###! Docs: https://github.com/schneems/puma_worker_killer
# puma['per_worker_max_memory_mb'] = 850
# puma['exporter_enabled'] = false
# puma['exporter_address'] = "127.0.0.1"
# puma['exporter_port'] = 8083
3. 生效配置,重启GitLab服务
gitlab-ctl reconfigu
gitlab-ctl restart
4. 检查端口情况
查询到有8092
端口说明,服务启动正常配置生效。
netstat -tunlp | grep 端口号