0

我已经使用 Memcached 作为 Radiant 缓存资源设置了一个 Radiant 实例,但是,缓存命中似乎没有记录到 Radiant。

这是缓存实现的示例:

# file: :rails_root/config/environments/[RAILS_ENV].rb
require 'dalli'
$cache = Dalli::Client.new(["remotehost.com:11211", "127.0.0.1:11211"], :compress => true)
config.middleware.use ::Radiant::Cache, :metastore => $cache, :entitystore => $cache

当我在 Radiant 实例(通过 httperf)上扔负载时,只有缓存未命中会在 NewRelic 中注册。

::编辑::

一些可能还值得注意的事情:

  1. 我正在使用 nginx 和独角兽。
  2. 我目前需要:rails_root/config.ru像这样的newrelic:

    begin
      require 'newrelic_rpm'
      NewRelic::Agent.after_fork(:force_reconnect => true)
    rescue LoadError
      # proceed without NewRelic
    end
    
  3. 我正在使用捆绑器,这是我的示例Gemfile

    source "http://my_gem_server"
    source :rubygems
    
    gem "radiant", "~> 1.1.0"
    gem 'unicorn'
    gem 'therubyracer', '~> 0.9'
    gem 'newrelic_rpm'
    gem 'rack-cache'
    gem 'dalli'
    gem "compass-rails", "~> 1.0.3"
    group :extensions do
      # radiant extensions
      gem "radiant-archive-extension",             "~> 1.0.7"
      gem "radiant-clipped-extension",             "~> 1.1.0"
      gem "radiant-debug-extension",               "~> 1.0.2"
      gem "radiant-exporter-extension",            "~> 1.1.0"
      gem "radiant-markdown_filter-extension",     "~> 1.0.2"
      gem "radiant-snippets-extension",            "~> 1.1.0"
      gem "radiant-site_templates-extension",      "~> 1.0.4"
      gem "radiant-smarty_pants_filter-extension", "~> 1.0.2"
      gem "radiant-textile_filter-extension",      "~> 1.0.4"
    
      # additional extensions
      gem "radiant-index_page-extension",          "~> 1.0.1"
      gem "radiant-vapor-extension",               "~> 2.1.4"
      gem "radiant-reorder_children-extension",    "~> 1.0.6"
      gem "radiant-layouts-extension",             "~> 1.1.3"
      gem "radiant-sibling_tags-extension",        "~> 0.2.1"
      gem "radiant-if_param_tags-extension",       "~> 1.0.1"
      gem "radiant-cache_buster-extension",        "~> 0.0.1"
    
      # forked extensions
      gem "radiant-sheets-extension",              "1.1.0my1"
    end
    
  4. 我试过的东西:
    • 将 newrelic 的 require 代码移动到 config.ru 的顶部和底部。
    • 移动gem "newrelic_rpm"到我的 Gemfile 的顶部和底部(底部:https ://newrelic.com/docs/ruby/does-new-relic-work-with-the-bundler-gem )
    • 将 newrelic 的 require 代码移动到我的底部:rails_root/config/enivornments/[RAILS_ENV].rb
    • 将 newrelic 的 require 代码移动到顶部:rails_env/config/boot.rb:rails_env/config/environment.rb底部。
    • newrelic_rpm在 Gemfile 中明确要求gem "newrelic_rpm", :require => 'newrelic_rpm'

::/编辑::

有人有想法么?

谢谢!

4

1 回答 1

0

在与 NewRelics 支持人员合作后,他们让我发了这篇文章: http: //newrelic.github.com/rpm/NewRelic/Agent/Instrumentation/Rack.html

然后我稍微解构了这个方法,并提出了以下解决方案:

https://gist.github.com/4076773

于 2012-11-26T21:06:50.970 回答