Tag: unicorn

Rails,Heroku,Unicorn&Resque – 如何选择网络工作者/ resque工作者的数量?

我刚刚转向在Heroku上使用Unicorn。 我也将从delayed_job切换到resque并使用http://bugsplat.info/2011-11-27-concurrency-on-heroku-cedar.html中描述的设置 我不明白这是怎么配置/ unicorn.rb: worker_processes 3 timeout 30 @resque_pid = nil before_fork do |server, worker| @resque_pid ||= spawn(“bundle exec rake ” + \ “resque:work QUEUES=scrape,geocode,distance,mailer”) end 翻译成: “这实际上会导致每个网络dyno中的六个进程:1个独角兽大师,3个独角兽网络工作者,1个resque工作者,1个真正正在处理工作的resque童工” 有多少工人会实际处理后台工作? 1还是2? 让我们说我想增加resque工人的数量 – 我会改变什么?

无法使用Ruby 2.0运行Unicorn

在我的ubuntu机器上,我可以在ruby 1.9.3上运行独角兽,但是,它似乎不适用于ruby 2.0。 知道为什么吗? root@dev:/home/karan# rvm use 1.9 Using /usr/local/rvm/gems/ruby-1.9.3-p429 root@dev:/home/karan# unicorn -v unicorn v4.6.3 root@dev:/home/karan# rvm use 2.0 Using /usr/local/rvm/gems/ruby-2.0.0-p195 root@dev:/home/karan# unicorn -v /usr/local/rvm/rubies/ruby-2.0.0-p195/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require’: cannot load such file — unicorn/launcher (LoadError) from /usr/local/rvm/rubies/ruby-2.0.0-p195/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require’ from /usr/bin/unicorn:3:in `’

用于生产的Rails性能调优?

我正在接近部署基于Rails 3.1.x构建的应用程序,并开始运行一些性能测试。 在稍微摆弄ab之后,我看到一些非常令人沮丧的结果,在Heroku上产生大约15个请求/秒。 在本地测试时,我看到类似的结果,这些结果确实表明它是一个应用程序问题比什么都重要。 我正在运行Unicorn,比Celadon Cedar上的Thin快约40%。 此外,我正在使用PGSQL共享数据库。 我希望有人可以共享一份清单或基本上是一份发布清单,在准备生产应用程序并进入速度调整需求时,我应该通过该清单。 到目前为止,我还没有找到一个真正简明的可操作项目列表,根据我的情况,这似乎是有意义的。 或者,如果您在此类问题中有扎实的实践经验,那么任何输入都将受到赞赏!

Heroku上的Puma Cluster配置

我在RoR4 Heroku应用程序上配置Puma(multithreading+多核服务器)需要一些帮助。 Heroku上的文档并不是最新的。 我遵循了这个:配置的并发和数据库连接 ,没有提到集群的配置,所以我不得不同时使用这两种类型(线程和多核)。 我目前的配置: ./Procfile web: bundle exec puma -p $PORT -C config/puma.rb ./config/puma.rb environment production threads 0,16 workers 4 preload_app! on_worker_boot do ActiveRecord::Base.connection_pool.disconnect! ActiveSupport.on_load(:active_record) do config = Rails.application.config.database_configuration[Rails.env] config[‘reaping_frequency’] = ENV[‘DB_REAP_FREQ’] || 10 # seconds config[‘pool’] = ENV[‘DB_POOL’] || 5 ActiveRecord::Base.establish_connection end end 问题: a)我是否需要像Unicorn一样的before_fork / after_fork配置,因为群集工作者是分叉的? b)如何根据我的应用程序调整我的线程数 – 将它放下的原因是什么? /在什么情况下它会有所作为? 是不是已经优化了0:16? […]

Unicorn在资产预编译期间触发mongoid错误

我有一个使用在Heroku上运行的Mongoid 3的rails应用程序。 我刚刚更新它以使用Unicorn。 当我尝试将其部署到Heroku时,我收到以下错误: Running: rake assets:precompile rake aborted! undefined method `match’ for nil:NilClass /tmp/build_3nnbzpfmnjpns/vendor/bundle/ruby/1.9.1/gems/mongoid-3.0.21/lib/mongoid/sessions/mongo_uri.rb:49:in `initialize’ 完整的堆栈跟踪可以在http://pastebin.com/8YcJHEmS找到 但是如果我从我的Gemfile中删除Unicorn,资产编译就会成功。 查看Mongoid代码,我可以看到当mongoid.yml文件被解析时发生错误,但我无法弄清楚为什么Unicorn会导致失败。 我的mongoid.yml文件如下所示: production: sessions: default: uri: options: skip_version_check: true safe: true 我的Gemfile: source ‘https://rubygems.org’ ruby ‘1.9.3’ gem ‘rails’, ‘3.2.11’ gem ‘thin’ group :assets do gem ‘sass-rails’, ‘~> 3.2’ gem ‘coffee-rails’, ‘~> 3.2’ gem ‘uglifier’, ‘>= 1.0.3’ gem […]

在Heroku,Cedar,与Unicorn:获取ActiveRecord :: StatementInvalid:PGError:SSL SYSCALL错误:检测到EOF

Heroku支持称这与他们在共享数据库上的libssl版本有关,但我们也在一个专用数据库上的项目中遇到过它。 基本上这个错误经常发生(接近部署之后)我们已经转移到新的Cedar堆栈,而Unicorn配置为3个工作人员: 错误信息: ActiveRecord::StatementInvalid: PGError: SSL SYSCALL error: EOF detected : SELECT a.attname, format_type(a.atttypid, a.atttypmod), d.adsrc, a.attnotnull FROM pg_attribute a LEFT JOIN pg_attrdef d ON a.attrelid = d.adrelid AND a.attnum = d.adnum WHERE a.at Where: some_controller#index [PROJECT_ROOT]/vendor/bundle/ruby/1.9.1/gems/activerecord-3.0.11/lib/active_record/connection_adapters/postgresql_adapter.rb, line 505 没有heroku的答案,但也许等待谁知道我们升级我们的共享数据库服务器*多久,我没有在谷歌上找到任何东西。 他们还建议它与独角兽的工人重叠有关,我们应该切换到Thin,但性能提升非常值得偶尔出错(我想!)。 我希望有一种方法可以配置Unicorn以防止重叠。 有没有人遇到过这个,如果有的话,你做了什么来解决它? 谢谢! *不是他们的实际用语,而是他们回答后的感受。

为什么“rails runner -e production”不起作用?

为了解决我的问题,在“ 生产未定义方法’paginate’中的” will_paginate错误 “中讨论过,我尝试运行: script/rails runner -e production 和: bundle exec script/rails runner -e production 在服务器上像这个github问题中建议的那样: https : //github.com/mislav/will_paginate/issues/308#issuecomment-17167158 但是我收到以下错误: bundler: command not found: script/rails Install missing gem executables with `bundle install` 捆绑安装没有帮助。 有什么建议? 我正在使用:Ruby 2.0.0p247,Rails 4.0.0,Ubuntu 12.10 LTS,Unicorn,Capistrano