【问题标题】:Heroku request timeout when Memcachier reaches cache limitMemcachier 达到缓存限制时 Heroku 请求超时
【发布时间】:2013-11-09 02:44:53
【问题描述】:

我有一个使用 Memcachier(Dalli 作为客户端)部署到 Heroku 的 Rails 应用程序。我正在使用免费插件(提供 25 MB 缓存)。

我们开始从heroku接收请求超时,调试后发现手动刷新Memcachier解决了这个问题。

当 Memcachier 达到接近其限制的级别时会发生超时,例如 20 MB(当限制为 25 MB 时)。

为什么 Memcachier 不随时间释放缓存空间?是否有任何缺少配置告诉 Memcachier 当缓存达到一定大小时刷新

我的会议:

应用程序.rb

config.cache_store = :dalli_store

生产.rb

client = Dalli::Client.new
config.action_dispatch.rack_cache = {
    :metastore    => client,
    :entitystore  => client,
    :allow_reload => false
}

【问题讨论】:

    标签: ruby-on-rails heroku timeout memcached


    【解决方案1】:

    也许尝试更新您的 production.rb 以包含 socket_timeoutsocket_failure_delay 选项。

    require 'dalli'
    cache = Dalli::Client.new((ENV["MEMCACHIER_SERVERS"] || "").split(","),
                        {:username => ENV["MEMCACHIER_USERNAME"],
                         :password => ENV["MEMCACHIER_PASSWORD"],
                         :failover => true,
                         :socket_timeout => 1.5,
                         :socket_failure_delay => 0.2
                        })
    

    -- 或者--

    如果您使用的是 Puma,则需要安装 connection_pool gem。

    宝石文件

    gem 'connection_pool'
    

    这个配置在你的production.rb中

    config.cache_store = :dalli_store,
                        (ENV["MEMCACHIER_SERVERS"] || "").split(","),
                        {:username => ENV["MEMCACHIER_USERNAME"],
                         :password => ENV["MEMCACHIER_PASSWORD"],
                         :failover => true,
                         :socket_timeout => 1.5,
                         :socket_failure_delay => 0.2,
                         :pool_size => 5
                        }
    

    【讨论】:

      猜你喜欢
      • 2017-06-14
      • 2019-09-13
      • 2015-12-19
      • 2013-07-13
      • 2020-06-20
      • 2018-05-10
      • 2013-02-05
      • 1970-01-01
      • 2021-04-17
      相关资源
      最近更新 更多