Debian 上部署的 GitLab 访问慢,原因通常可以分成网络层面、系统资源层面、GitLab 自身配置层面、以及使用方式层面几类。下面按常见程度给你一个排查清单。
GitLab 本身非常“重”,官方推荐:
git clone 特别慢free -h
top
htop
编辑:
/etc/gitlab/gitlab.rb
关闭不必要服务(示例):
prometheus_monitoring['enable'] = false
grafana['enable'] = false
然后:
gitlab-ctl reconfigure
ping gitlab.example.com
curl -I http://gitlab-ip
unicorn['worker_processes'] = 2
puma['worker_processes'] = 2
puma['min_threads'] = 1
puma['max_threads'] = 4
太多 worker 会吃光内存,太少会排队。
git config --global http.postBuffer 524288000
git clone --depth 1
GitLab 重度依赖 PostgreSQL。
gitlab-psql
SELECT * FROM pg_stat_activity;
postgresql['shared_buffers'] = "256MB"
postgresql['max_connections'] = 200
iostat -x 1
/var/opt/gitlab 单独挂载可临时测试:
curl -k https://gitlab-ip
旧版本在 Debian 新内核上有性能问题。
gitlab-rake gitlab:env:info
建议保持 次新版(非最新 nightly)
如果你愿意,可以告诉我:
我可以直接帮你给出一份针对性优化配置。