Linux 上的 GitLab 出现严重卡顿,通常不是单一原因,而是资源、配置或架构问题叠加。下面按最常见 → 较少见的顺序给你系统性排查思路。
GitLab 是资源大户,尤其是:
free -h
top / htop
df -h
iostat -x 1
✅ 建议最低配置
GitLab 极度怕 swap
swapon --show
如果 swap 使用明显,会非常卡。
✅ 解决:
sudo swapoff -a
GitLab 强依赖 PostgreSQL
gitlab-psql
SELECT * FROM pg_stat_activity;
✅ 优化:
gitlab-ctl reconfigure
gitlab-rake gitlab:db:vacuum:all
GitLab 默认会“尽量吃满资源”
cat /etc/gitlab/gitlab.rb | grep -E "worker|process"
sidekiq 进程太多unicorn/puma worker 过多✅ 示例(8G 内存):
puma['worker_processes'] = 2
sidekiq['concurrency'] = 10
然后:
gitlab-ctl reconfigure
gitlab-ctl restart
很多人开了:
✅ 建议关闭用不到的:
registry['enable'] = false
mattermost['enable'] = false
prometheus['enable'] = false
GitLab:
✅ 检查:
iostat -x 1
✅ 建议:
du -sh /var/log/gitlab
✅ 清理 & 限制:
logging['logrotate_frequency'] = "daily"
如果你用了:
常见问题:
✅ 检查:
proxy_timeout
client_max_body_size
旧版 GitLab 有明显性能问题
✅ 查看:
gitlab-rake gitlab:env:info
✅ 建议:
free -h
top
df -h
gitlab-ctl status
你可以直接贴:
gitlab.rb 关键配置我可以直接帮你给出优化方案或配置文件。