Redis与记忆快取 [英] Redis Vs. Memcached

查看:88
本文介绍了Redis与记忆快取的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我现在正在使用memcached作为LRU缓存来缓存大数据.我已将最大对象大小设置为128 MB(我知道这样做效率不高,不建议这样做),并且将全部内存缓存的大小设置为1 GB.但是128 MB不足以满足我的目的,因此我计划迁移到Redis.几个问题:

I am using memcached right now as a LRU cache to cache big data. I've set the max object size to 128 MB (I know this is inefficient and not recommended) and total memcached to 1 GB. But 128 MB is not enough for my purposes so I am planning to move to Redis. A couple questions:

  1. memcached非常慢-我当前的memcached设置需要3-4秒才能返回一个请求.这非常慢.有时我最多需要制作30个memcached请求才能满足一个用户请求.只需90秒钟即可完成!!我是在做错什么,还是memcached这么慢?
  2. Redis会更快吗? -我打算使用Redis列表来缓存数据.我将使用0到-1获取完整列表.我希望Redis更快,因为如果要花费90秒,我也可能不使用任何缓存!

谢谢!

推荐答案

我建议做一些性能分析,以了解瓶颈在哪里.我不知情的猜测是,对于如此大的对象,您可能会受到应用服务器与内存缓存之间的连接的限制,因此使用Redis会看到类似的结果.也可能是您的应用需要花费大量时间来编组和解组很多对象.如果简单的话,可能值得尝试一种缓存方案,在这种方案中,您只是缓存将发送给客户端的请求(我确定它远远少于128MB).

I'd recommend doing a little profiling to see where the bottleneck is. My uninformed guess is that with such large objects, you may be limited by the connection between your app server and memcached and thus you'll see similar results with redis. It could also be that your app is taking a lot of time marshaling and unmarshaling a lot of objects. If it's easy, it might be worth trying a caching scheme where you're just caching the request being sent down to the client (which I'm sure is much less than 128MB).

要尝试的另一件事是打开压缩.这样可以增加等待时间的压缩/解压缩,但如果确实存在问题,则可以减少网络等待时间.

Another thing to try would be turning on compression. This would give added latency compressing/uncompressing but would reduce network latency if that is indeed the issue.

这篇关于Redis与记忆快取的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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