Redis用于Rails中的数据存储(作业)和片段缓存 [英] Redis for both data store (jobs) and fragment cache in Rails

查看:119
本文介绍了Redis用于Rails中的数据存储(作业)和片段缓存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在使用Redis(在Heroku上使用Redis Cloud)作为Resque的数据存储来处理我的后台作业。我想为我的应用程序添加一些片段缓存。



问题:


  1. 我们是否需要两个独立的Redis实例来实现这个目标?一个用于片段缓存(短暂数据),另一个用于作业(持久数据)?或者可以配置一个Redis实例来处理这两种情况?从配置和维护的角度来看,简单地使用memcached进行片段缓存和Redis作业更容易吗?有两种付费服务,而不是一种,主要是这样做的缺点吗?

  2. >同样的redis可以用于ephermal数据(用于fragmant缓存)和持久性数据,因为您已经配置了redis以将该数据写入磁盘,我认为这是因为当前redis被用于持久数据。
    单独的redis实例的评估可以基于引入fragmant缓存后的使用量来完成。如果fragmentation缓存会显着增加redis的负载,则使用不需要写入磁盘本身的不同redis。从配置和维护的角度来看,memcache和redis配置,集群在你自己的机器上使用它或者像现有的解决方案一样简单,缓存。
    鉴于您已经在使用redis,我会说扩展techstack总是会增加一点维护的开销,因为您将有额外的堆栈来调整和调整以获得更好的性能。

    I am already using Redis (with Redis Cloud on Heroku) as a data store for Resque to process my background jobs. I would like to add some fragment caching to my app.

    Questions:

    1. Do we need two separate instances of Redis to achieve this? One for the fragment caching (ephemeral data) and another for jobs (persistent data)? Or can the one Redis instances be configured to handle both scenarios?

    2. From a configuration and maintenance point of view, is it easier to simply have memcached for fragment caching and Redis for jobs? Is the main downfall to this having two paid services rather than one?

    解决方案

    Same redis can be used for both ephermal data(for fragmant caching) and persistent data given you have configured your redis to write that data to disk which i assume is there as the current redis is being used for persistent data. The evaluation of a separate redis instance can be done based on the volume of use after introduction of fragmant cache. If fragmant cache will significantly increase the load on redis then use a different redis which need not write to the disk itself.

    From a configuration and maintenance point of view, both memcache and redis configuration, clustering are equally straightforward when you use it on your own machine or go with existing solution like elastic-cache. Given you are already using redis i would say expanding techstack always adds a little maintenance overhead given you will have additional stack to tweak and tune for better performance.

    这篇关于Redis用于Rails中的数据存储(作业)和片段缓存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆