欢迎访问 生活随笔!

生活随笔

当前位置: 首页 > 编程资源 > 编程问答 >内容正文

编程问答

git压测出现访问500

发布时间:2023/12/19 编程问答 36 豆豆
生活随笔 收集整理的这篇文章主要介绍了 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 => 1024working_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.pidbeginsig = (worker.nr + 1) >= server.worker_processes ? :QUIT : :TTOUProcess.kill(sig, File.read(old_pid).to_i)rescue Errno::ENOENT, Errno::ESRCHendendActiveRecord::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.





总结

以上是生活随笔为你收集整理的git压测出现访问500的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。