git压测出现访问500

git 启动之后根据cpu的内核数据创建和内核数目相等的进程数:

root     29694 29669  0  2017 ?        00:00:00 runsv redis
root     29743 29669  0  2017 ?        00:00:00 runsv unicorn
root     29744 29743  0  2017 ?        00:00:00 svlogd -tt /var/log/gitlab/unicorn
root     29775 29669  0  2017 ?        00:00:00 runsv sidekiq
root     29786 29669  0  2017 ?        00:00:00 runsv gitlab-workhorse
root     29800 29669  0  2017 ?        00:00:00 runsv nginx
root     29848 29669  0  2017 ?        00:00:00 runsv logrotate
git      30489 29786  0 15:57 ?        00:00:02 /opt/gitlab/embedded/bin/gitlab-workhorse -listenNetwork unix -listenUmask 0 -listenAddr /var/opt/gitlab/gitlab-workhorse/socket -authBackend http://localhost:8080 -authSocket /var/opt/gitlab/gitlab-rails/sockets/gitlab.socket -documentRoot /opt/gitlab/embedded/service/gitlab-rails/public -pprofListenAddr  -secretPath /opt/gitlab/embedded/service/gitlab-rails/.gitlab_workhorse_secret
git      30551 29743  0 15:57 ?        00:00:01 /bin/bash /opt/gitlab/embedded/bin/gitlab-unicorn-wrapper
git      30567     1  0 15:57 ?        00:00:14 unicorn master -D -E production -c /var/opt/gitlab/gitlab-rails/etc/unicorn.rb /opt/gitlab/embedded/service/gitlab-rails/config.ru                                                            
git      30609 30567  0 15:58 ?        00:00:15 unicorn worker[0] -D -E production -c /var/opt/gitlab/gitlab-rails/etc/unicorn.rb /opt/gitlab/embedded/service/gitlab-rails/config.ru                                                         
git      30612 30567  0 15:58 ?        00:00:20 unicorn worker[1] -D -E production -c /var/opt/gitlab/gitlab-rails/etc/unicorn.rb /opt/gitlab/embedded/service/gitlab-rails/config.ru                                                         
git      30615 30567  0 15:58 ?        00:00:14 unicorn worker[2] -D -E production -c /var/opt/gitlab/gitlab-rails/etc/unicorn.rb /opt/gitlab/embedded/service/gitlab-rails/config.ru                                                         
git      30618 30567  0 15:58 ?        00:00:17 unicorn worker[3] -D -E production -c /var/opt/gitlab/gitlab-rails/etc/unicorn.rb /opt/gitlab/embedded/service/gitlab-rails/config.ru                                                         
git      30621 30567  0 15:58 ?        00:00:13 unicorn worker[4] -D -E production -c /var/opt/gitlab/gitlab-rails/etc/unicorn.rb /opt/gitlab/embedded/service/gitlab-rails/config.ru                                                         
git      30624 30567  0 15:58 ?        00:00:18 unicorn worker[5] -D -E production -c /var/opt/gitlab/gitlab-rails/etc/unicorn.rb /opt/gitlab/embedded/service/gitlab-rails/config.ru                                                         
git      30627 30567  0 15:58 ?        00:00:14 unicorn worker[6] -D -E production -c /var/opt/gitlab/gitlab-rails/etc/unicorn.rb /opt/gitlab/embedded/service/gitlab-rails/config.ru                                                         
git      30630 30567  0 15:58 ?        00:00:14 unicorn worker[7] -D -E production -c /var/opt/gitlab/gitlab-rails/etc/unicorn.rb /opt/gitlab/embedded/service/gitlab-rails/config.ru                                                         
git      30633 30567  0 15:58 ?        00:00:15 unicorn worker[8] -D -E production -c /var/opt/gitlab/gitlab-rails/etc/unicorn.rb /opt/gitlab/embedded/service/gitlab-rails/config.ru 

每一个git 任务过来就会放进一个进程里面去处理。

每一个git 进程就是一个unicorn(独角兽),也可以理解成一个git rails(git 执行轨道)。

并发的几个线程,其中一个是master pid = 30567

其他的slave worker都是master 创建的,父进程id都是30567


/var/opt/gitlab/gitlab-rails/etc/unicorn.rb   文件:

# This file is managed by gitlab-ctl. Manual changes will be
# erased! To change the contents below, edit /etc/gitlab/gitlab.rb
# and run `sudo gitlab-ctl reconfigure`.


# What ports/sockets to listen on, and what options for them.
listen "127.0.0.1:8080", :tcp_nopush => true
listen "/var/opt/gitlab/gitlab-rails/sockets/gitlab.socket", :backlog => 1024

working_directory '/var/opt/gitlab/gitlab-rails/working'

# What the timeout for killing busy workers is, in seconds
timeout 60

# Whether the app should be pre-loaded
preload_app true

# How many worker processes
worker_processes 9

# What to do before we fork a worker
before_fork do |server, worker|
        old_pid = "#{server.config[:pid]}.oldbin"
      if old_pid != server.pid
        begin
          sig = (worker.nr + 1) >= server.worker_processes ? :QUIT : :TTOU
          Process.kill(sig, File.read(old_pid).to_i)
        rescue Errno::ENOENT, Errno::ESRCH
        end
      end

      ActiveRecord::Base.connection.disconnect! if defined?(ActiveRecord::Base)

end

# What to do after we fork a worker
after_fork do |server, worker|
        ActiveRecord::Base.establish_connection if defined?(ActiveRecord::Base)

end

# Where to drop a pidfile
pid '/opt/gitlab/var/unicorn/unicorn.pid'

# Where stderr gets logged
stderr_path '/var/log/gitlab/unicorn/unicorn_stderr.log'

# Where stdout gets logged
stdout_path '/var/log/gitlab/unicorn/unicorn_stdout.log'

# Min memory size (RSS) per worker
ENV['GITLAB_UNICORN_MEMORY_MIN'] = (400 * 1 << 20).to_s

# Max memory size (RSS) per worker
ENV['GITLAB_UNICORN_MEMORY_MAX'] = (650 * 1 << 20).to_s


在unicorn.rb中设置了 timeout, 压测返回500 就是 这个造成的,将timeout设置600.





评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值