Gitlab 超时/初始页面加载缓慢

Gitlab timeouts / slow on initial page loads

我是 运行 Debian 上的 Gitlab,使用存储库中的包。大多数时候 Gitlab 运行 非常快,但是在较长的空闲时间后 Gitlab 非常慢甚至超时(错误 502)。有一次我也遇到了远程 git 访问超时(无法重现问题 - 内部 API 超时)。

在我的设置中,Debian 机器位于另一个 nginx 代理之后,该代理也可以很好地提供一些其他服务。我做了 gitlab-cli 检查,一切似乎都很好。

在我的反向代理的错误日志中,我只看到连接超时:

[error] 8643#0: *4139 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 10.1.1.10, server: gitlab.mydomain.tld, request: "GET / HTTP/1.1", upstream: "http://{SERVER-IP}:80/", host: "gitlab.mydomain.tld"

我可以在我的 unicorn_stderr.log

中看到一些错误
E, [2016-03-30T19:40:20.183991 #783] ERROR -- : worker=1 PID:16798 timeout (61s > 60s), killing
E, [2016-03-30T19:40:20.194969 #783] ERROR -- : reaped #<Process::Status: pid 16798 SIGKILL (signal 9)> worker=1
I, [2016-03-30T19:40:20.197554 #16871]  INFO -- : worker=1 spawned pid=16871
I, [2016-03-30T19:40:20.197909 #16871]  INFO -- : worker=1 ready
E, [2016-03-30T20:08:42.911429 #783] ERROR -- : worker=0 PID:16866 timeout (61s > 60s), killing
E, [2016-03-30T20:08:43.191151 #783] ERROR -- : reaped #<Process::Status: pid 16866 SIGKILL (signal 9)> worker=0
I, [2016-03-30T20:08:43.758363 #18728]  INFO -- : worker=0 spawned pid=18728
I, [2016-03-30T20:08:44.108244 #18728]  INFO -- : worker=0 ready

让我有点好奇的是gitlab自带的nginx的日志没有报错。

更多系统信息:

#sudo gitlab-rake gitlab:env:info

System information
System:         Debian 8.3
Current User:   git
Using RVM:      no
Ruby Version:   2.1.8p440
Gem Version:    2.5.1
Bundler Version:1.10.6
Rake Version:   10.5.0
Sidekiq Version:4.0.1

GitLab information
Version:        8.5.0
Revision:       a513e09
Directory:      /opt/gitlab/embedded/service/gitlab-rails
DB Adapter:     postgresql
URL:            http://gitlab.mydomain.tld
HTTP Clone URL: http://gitlab.mydomain.tld/some-group/some-project.git
SSH Clone URL:  git@gitlab.mydomain.tld:some-group/some-project.git
Using LDAP:     no
Using Omniauth: no

GitLab Shell
Version:        2.6.10
Repositories:   /var/opt/gitlab/git-data/repositories
Hooks:          /opt/gitlab/embedded/service/gitlab-shell/hooks/
Git:            /opt/gitlab/embedded/bin/git

编辑:

我在 "external" 反向代理上的 nginx 配置如下所示:

server {
        listen  443;
        ssl     on;
        server_name gitlab.mydomain.tld;

        access_log  /var/log/nginx/gitlab.mydomain.tld.access.log;
        error_log   /var/log/nginx/gitlab.mydomain.tld.error.log;

        ssl_certificate         /etc/nginx/ssl/gitlab.mydomain.tld_unified.crt;
        ssl_certificate_key     /etc/nginx/ssl/mydomain.tld.key;

        location / {
                proxy_pass http://gitlab:80;
                proxy_redirect default;
                proxy_set_header        Host    $http_host;
                proxy_set_header        X_FORWARDED_PROTO "https";
                satisfy any;
        }
}

编辑2:

我考虑了建议的答案,也考虑了这个来源:https://github.com/gitlabhq/gitlabhq/blob/master/doc/install/requirements.md

我现在给虚拟机分配了 2GB RAM,并且还添加了一个额外的 unicorn worker。

编辑 3:

问题似乎通过增加内存和使用 3 个 unicorn worker 来解决。

简,

虽然我们的盒子专用于 GITlab,但我有类似的设置。在不知道您的服务器规格(GITLAB 喜欢内存)和那个盒子上的负载的情况下,我建议进行以下诊断:

  1. 您的上游 nginx 使用与 gitlab nginx 配置相同的参数吗?他们调整了很多东西,包括超时。
  2. 什么样的请求会导致超时?某些操作(如生成差异)可能需要一些时间才能呈现。
  3. 如果您 运行 通过 SSH 发送请求,您是否也会遇到超时?
  4. 你检查过 /var/log 中的全局日志了吗?

仅供参考:我不得不扩大我的小型 GitLab 安装以拥有 4GB RAM,以免引发 OOM 错误

现在我想,我最好选择 gogs 或其他替代品。