Ruby on rails 使用Unicorn+运行带外垃圾回收;架子
我试图在RubyonRails应用程序中运行带外垃圾收集(一旦请求完成响应服务)。我在config.ru中添加了以下内容:Ruby on rails 使用Unicorn+运行带外垃圾回收;架子,ruby-on-rails,ruby,performance,garbage-collection,unicorn,Ruby On Rails,Ruby,Performance,Garbage Collection,Unicorn,我试图在RubyonRails应用程序中运行带外垃圾收集(一旦请求完成响应服务)。我在config.ru中添加了以下内容: # This file is used by Rack-based servers to start the application. require ::File.expand_path('../config/environment', __FILE__) begin require 'unicorn/oob_gc' rescue LoadError, NameEr
# This file is used by Rack-based servers to start the application.
require ::File.expand_path('../config/environment', __FILE__)
begin
require 'unicorn/oob_gc'
rescue LoadError, NameError
end
# Out-of-band GC, runs GC after every 10th request and after the response
# has been delivered.
begin
use Unicorn::OobGC, interval=10
rescue NameError
end
run MyApp::Application
GC.start
然而,我正在查看我的NewRelic门户,大多数web事务确实表明,平均至少有110-150毫秒用于垃圾收集。Unicorn::OoobGC是否应该在实际请求的范围之外执行此操作?如果是,为什么这会出现在web事务中?我如何让垃圾收集的时间在web请求的上下文之外发生,以便感知到的客户端响应时间更快?花费的CPU时间仍然相同,因为它需要在后台进行,但是,在后台进行比占用请求管道更好。如果单个请求分配了足够的对象来触发GC,那么尽管使用unicorn中间件移动了最后一个GC OOB,您仍然会看到为请求报告的GC时间 使用Ruby1.9.3和REE,您可以旋转各种GC旋钮来帮助控制触发GC的频率。有关设置RUBY_HEAP_MIN_插槽、RUBY_GC_MALLOC_LIMIT和RUBY_FREE_MIN的示例,请参阅,以在长时间运行的服务应用程序中获得更好的性能