【发布时间】:2015-09-10 09:43:24
【问题描述】:
我正在 Heroku 上运行带有 Puma 服务器的 Rails 4 应用程序。我只使用一个基本的网络测功机(没有工人),内存为 512MB。
最近遇到很多R14错误(Memory Quota Exceeded),昨天我的服务器崩溃了3次。
这是我的 Puma 配置文件:
workers Integer(ENV['WEB_CONCURRENCY'] || 0)
threads_count = Integer(ENV['MAX_THREADS'] || 5)
threads threads_count, threads_count
preload_app!
rackup DefaultRackup
port ENV['PORT'] || 3000
environment ENV['RACK_ENV'] || 'development'
on_worker_boot do
# Worker specific setup for Rails 4.1+
# See: https://devcenter.heroku.com/articles/deploying-rails-applications-with-the-puma-web-server#on-worker-boot
ActiveRecord::Base.establish_connection
end
我每天在服务器上执行的耗时任务很少,我认为这是我收到这些 R14 错误和服务器崩溃的原因:
使用 Heroku Scheduler 执行的 rake 任务
在创建/更新名为 Thing 的模型时导入 10 张照片(最大尺寸:10 x 3MB)
从我的数据库中导出日志,最多可包含 6k 行
这是我的问题:
将这些耗时的任务放在新的工作人员测功机上可以帮助我避免 R14 错误/服务器崩溃吗?如果是,您推荐使用delayed_job_active_record gem 还是resque gem?
你认为我的 Puma 配置文件还可以吗?
我不知道如何将 Heroku Scheduler 执行的 rake 任务放在工作人员测功机上。有什么想法吗?
非常感谢您的帮助!
【问题讨论】:
-
下垂,我现在面临同样的问题。你能以某种方式解决它吗?
标签: ruby-on-rails ruby heroku web-worker puma